Files

2 lines
577 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*! For license information please see sculptgl.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.sculptgl=t():e.sculptgl=t()}(self,(function(){return(()=>{var __webpack_modules__={751:function(e,t,r){var i,n,a,s;function o(e){return(o="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)}e=r.nmd(e),s=function(){return function(e){function t(i){if(r[i])return r[i].exports;var n=r[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){function i(e){if(!e)throw new Error("SketchfabOAuth2 config is missing.");if(e.hasOwnProperty("hostname")||(e.hostname="sketchfab.com"),!e.hasOwnProperty("client_id"))throw new Error("client_id is missing. Please check the config of SketchfabOAuth2.");if(!e.hasOwnProperty("redirect_uri"))throw new Error("redirect_uri is missing. Please check the config of SketchfabOAuth2.");this.config=e}r(5);var n=r(2),a=r(6),s=a.buildQueryString,o=a.parseQueryString;i.prototype.connect=function(e){return new n(function(t,r){if(this.config.client_id)var i={response_type:"token",state:+new Date,client_id:this.config.client_id,redirect_uri:this.config.redirect_uri},n=Object.assign({},i,e),a="https://"+this.config.hostname+"/oauth2/authorize/?"+s(n),l=window.open(a,"loginWindow","width=640,height=400"),u=setInterval(function(){try{var e=l.location.href;if(void 0===e)return clearInterval(u),void r(new Error("Access denied (User closed popup)"));if(-1!==e.indexOf("?error=access_denied"))return clearInterval(u),void r(new Error("Access denied (User canceled)"));if(-1!==e.indexOf(this.config.redirect_uri)){clearInterval(u);var i,n=l.location.hash,a=RegExp("access_token=([^&]+)");return n.match(a)?(i=o(n.substring(1)),void t(i)):void r(new Error("Access denied (missing token)"))}}catch(e){}}.bind(this),1e3);else r(new Error("client_id is missing."))}.bind(this))},e.exports=i},function(e,t){function r(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function n(e){if(u===setTimeout)return setTimeout(e,0);if((u===r||!u)&&setTimeout)return u=setTimeout,setTimeout(e,0);try{return u(e,0)}catch(t){try{return u.call(null,e,0)}catch(t){return u.call(this,e,0)}}}function a(){_&&d&&(_=!1,d.length?f=d.concat(f):p=-1,f.length&&s())}function s(){if(!_){var e=n(a);_=!0;for(var t=f.length;t;){for(d=f,f=[];++p<t;)d&&d[p].run();p=-1,t=f.length}d=null,_=!1,function(e){if(c===clearTimeout)return clearTimeout(e);if((c===i||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(e);try{c(e)}catch(t){try{return c.call(null,e)}catch(t){return c.call(this,e)}}}(e)}}function o(e,t){this.fun=e,this.array=t}function l(){}var u,c,h=e.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:r}catch(e){u=r}try{c="function"==typeof clearTimeout?clearTimeout:i}catch(e){c=i}}();var d,f=[],_=!1,p=-1;h.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];f.push(new o(e,t)),1!==f.length||_||n(s)},o.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=l,h.addListener=l,h.once=l,h.off=l,h.removeListener=l,h.removeAllListeners=l,h.emit=l,h.prependListener=l,h.prependOnceListener=l,h.listeners=function(e){return[]},h.binding=function(e){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},function(e,t,r){(function(t){"use strict";function r(){}function i(e){if(!(this instanceof i))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],c(e,this)}function n(e,t){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(t):(e._handled=!0,void i._immediateFn((function(){var r=1===e._state?t.onFulfilled:t.onRejected;if(null!==r){var i;try{i=r(e._value)}catch(e){return void s(t.promise,e)}a(t.promise,i)}else(1===e._state?a:s)(t.promise,e._value)})))}function a(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==o(t)||"function"==typeof t)){var r=t.then;if(t instanceof i)return e._state=3,e._value=t,void l(e);if("function"==typeof r)return void c(function(e,t){return function(){e.apply(t,arguments)}}(r,t),e)}e._state=1,e._value=t,l(e)}catch(t){s(e,t)}}function s(e,t){e._state=2,e._value=t,l(e)}function l(e){2===e._state&&0===e._deferreds.length&&i._immediateFn((function(){e._handled||i._unhandledRejectionFn(e._value)}));for(var t=0,r=e._deferreds.length;t<r;t++)n(e,e._deferreds[t]);e._deferreds=null}function u(e,t,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=r}function c(e,t){var r=!1;try{e((function(e){r||(r=!0,a(t,e))}),(function(e){r||(r=!0,s(t,e))}))}catch(e){if(r)return;r=!0,s(t,e)}}var h=setTimeout;i.prototype.catch=function(e){return this.then(null,e)},i.prototype.then=function(e,t){var i=new this.constructor(r);return n(this,new u(e,t,i)),i},i.prototype.finally=function(e){var t=this.constructor;return this.then((function(r){return t.resolve(e()).then((function(){return r}))}),(function(r){return t.resolve(e()).then((function(){return t.reject(r)}))}))},i.all=function(e){return new i((function(t,r){function i(e,s){try{if(s&&("object"==o(s)||"function"==typeof s)){var l=s.then;if("function"==typeof l)return void l.call(s,(function(t){i(e,t)}),r)}n[e]=s,0==--a&&t(n)}catch(e){r(e)}}if(!e||void 0===e.length)throw new TypeError("Promise.all accepts an array");var n=Array.prototype.slice.call(e);if(0===n.length)return t([]);for(var a=n.length,s=0;s<n.length;s++)i(s,n[s])}))},i.resolve=function(e){return e&&"object"==o(e)&&e.constructor===i?e:new i((function(t){t(e)}))},i.reject=function(e){return new i((function(t,r){r(e)}))},i.race=function(e){return new i((function(t,r){for(var i=0,n=e.length;i<n;i++)e[i].then(t,r)}))},i._immediateFn="function"==typeof t&&function(e){t(e)}||function(e){h(e,0)},i._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)},e.exports=i}).call(t,r(4).setImmediate)},function(e,t,r){(function(e,t){!function(e,r){"use strict";function i(e){delete o[e]}function n(e){if(l)setTimeout(n,0,e);else{var t=o[e];if(t){l=!0;try{!function(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(void 0,r)}}(t)}finally{i(e),l=!1}}}}if(!e.setImmediate){var a,s=1,o={},l=!1,u=e.document,c=Object.getPrototypeOf&&Object.getPrototypeOf(e);c=c&&c.setTimeout?c:e,"[object process]"==={}.toString.call(e.process)?a=function(e){t.nextTick((function(){n(e)}))}:function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?function(){var t="setImmediate$"+Math.random()+"$",r=function(r){r.source===e&&"string"==typeof r.data&&0===r.data.indexOf(t)&&n(+r.data.slice(t.length))};e.addEventListener?e.addEventListener("message",r,!1):e.attachEvent("onmessage",r),a=function(r){e.postMessage(t+r,"*")}}():e.MessageChannel?function(){var e=new MessageChannel;e.port1.onmessage=function(e){n(e.data)},a=function(t){e.port2.postMessage(t)}}():u&&"onreadystatechange"in u.createElement("script")?function(){var e=u.documentElement;a=function(t){var r=u.createElement("script");r.onreadystatechange=function(){n(t),r.onreadystatechange=null,e.removeChild(r),r=null},e.appendChild(r)}}():a=function(e){setTimeout(n,0,e)},c.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];var i={callback:e,args:t};return o[s]=i,a(s),s++},c.clearImmediate=i}}("undefined"==typeof self?void 0===e?this:e:self)}).call(t,function(){return this}(),r(1))},function(e,t,r){(function(e){function i(e,t){this._id=e,this._clearFn=t}var n=Function.prototype.apply;t.setTimeout=function(){return new i(n.call(setTimeout,window,arguments),clearTimeout)},t.setInterval=function(){return new i(n.call(setInterval,window,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r(3),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(t,function(){return this}())},function(e,t){"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){"use strict";if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(e),i=1;i<arguments.length;i++){var n=arguments[i];if(null!=n)for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r},writable:!0,configurable:!0})},function(e,t){e.exports={parseQueryString:function(e){var t={};return e.split("&").forEach((function(e){var r=e.split("=");t[r[0]]=decodeURIComponent(r[1])})),t},buildQueryString:function(e){for(var t=Object.keys(e),r=[],i=0,n=t.length;i<n;i++)r.push(t[i]+"="+encodeURIComponent(e[t[i]]));return r.join("&")}}}])},"object"==o(t)&&"object"==o(e)?e.exports=s():(n=[],void 0===(a="function"==typeof(i=s)?i.apply(t,n):i)||(e.exports=a))},141:function(){!function(e){"use strict";var t,r="File format is not recognized.",i="Error while reading zip file.",n="Error while reading file data.",a=524288,s="text/plain";try{t=0===new Blob([new DataView(new ArrayBuffer(0))]).size}catch(e){}function o(){this.crc=-1}function l(){}function u(e,t){var r,i;return r=new ArrayBuffer(e),i=new Uint8Array(r),t&&i.set(t,0),{buffer:r,array:i,view:new DataView(r)}}function c(){}function h(e){var t,r=this;r.size=0,r.init=function(i,n){var a=new Blob([e],{type:s});(t=new f(a)).init((function(){r.size=t.size,i()}),n)},r.readUint8Array=function(e,r,i,n){t.readUint8Array(e,r,i,n)}}function d(t){var r,i=this;i.size=0,i.init=function(e){for(var n=t.length;"="==t.charAt(n-1);)n--;r=t.indexOf(",")+1,i.size=Math.floor(.75*(n-r)),e()},i.readUint8Array=function(i,n,a){var s,o=u(n),l=4*Math.floor(i/3),c=4*Math.ceil((i+n)/3),h=e.atob(t.substring(l+r,c+r)),d=i-3*Math.floor(l/4);for(s=d;s<d+n;s++)o.array[s-d]=h.charCodeAt(s);a(o.array)}}function f(e){var t=this;t.size=0,t.init=function(r){t.size=e.size,r()},t.readUint8Array=function(t,r,i,n){var a=new FileReader;a.onload=function(e){i(new Uint8Array(e.target.result))},a.onerror=n;try{a.readAsArrayBuffer(function(e,t,r){if(t<0||r<0||t+r>e.size)throw new RangeError("offset:"+t+", length:"+r+", size:"+e.size);return e.slice?e.slice(t,t+r):e.webkitSlice?e.webkitSlice(t,t+r):e.mozSlice?e.mozSlice(t,t+r):e.msSlice?e.msSlice(t,t+r):void 0}(e,t,r))}catch(e){n(e)}}}function _(){}function p(e){var r,i=this;i.init=function(e){r=new Blob([],{type:s}),e()},i.writeUint8Array=function(e,i){r=new Blob([r,t?e:e.buffer],{type:s}),i()},i.getData=function(t,i){var n=new FileReader;n.onload=function(e){t(e.target.result)},n.onerror=i,n.readAsText(r,e)}}function g(t){var r=this,i="",n="";r.init=function(e){i+="data:"+(t||"")+";base64,",e()},r.writeUint8Array=function(t,r){var a,s=n.length,o=n;for(n="",a=0;a<3*Math.floor((s+t.length)/3)-s;a++)o+=String.fromCharCode(t[a]);for(;a<t.length;a++)n+=String.fromCharCode(t[a]);o.length>2?i+=e.btoa(o):n=o,r()},r.getData=function(t){t(i+e.btoa(n))}}function m(e){var r,i=this;i.init=function(t){r=new Blob([],{type:e}),t()},i.writeUint8Array=function(i,n){r=new Blob([r,t?i:i.buffer],{type:e}),n()},i.getData=function(e){e(r)}}function v(e,t,r,i,n,s,o,l,u,c){var h,d,f,_=0,p=t.sn;function g(){e.removeEventListener("message",m,!1),l(d,f)}function m(t){var r=t.data,n=r.data,a=r.error;if(a)return a.toString=function(){return"Error: "+this.message},void u(a);if(r.sn===p)switch("number"==typeof r.codecTime&&(e.codecTime+=r.codecTime),"number"==typeof r.crcTime&&(e.crcTime+=r.crcTime),r.type){case"append":n?(d+=n.length,i.writeUint8Array(n,(function(){v()}),c)):v();break;case"flush":f=r.crc,n?(d+=n.length,i.writeUint8Array(n,(function(){g()}),c)):g();break;case"progress":o&&o(h+r.loaded,s);break;case"importScripts":case"newTask":case"echo":break;default:console.warn("zip.js:launchWorkerProcess: unknown message: ",r)}}function v(){(h=_*a)<s?r.readUint8Array(n+h,Math.min(a,s-h),(function(r){o&&o(h,s);var i=0===h?t:{sn:p};i.type="append",i.data=r,e.postMessage(i,[r.buffer]),_++}),u):e.postMessage({sn:p,type:"flush"})}d=0,e.addEventListener("message",m,!1),v()}function y(e,t,r,i,n,s,l,u,c,h){var d,f=0,_=0,p="input"===s,g="output"===s,m=new o;!function s(){var o;if((d=f*a)<n)t.readUint8Array(i+d,Math.min(a,n-d),(function(t){var i;try{i=e.append(t,(function(e){l&&l(d+e,n)}))}catch(e){return void c(e)}i?(_+=i.length,r.writeUint8Array(i,(function(){f++,setTimeout(s,1)}),h),g&&m.append(i)):(f++,setTimeout(s,1)),p&&m.append(t),l&&l(d,n)}),c);else{try{o=e.flush()}catch(e){return void c(e)}o?(g&&m.append(o),_+=o.length,r.writeUint8Array(o,(function(){u(_,m.get())}),h)):u(_,m.get())}}()}function b(t,r,i,n,a,s,o,u,c,h,d){var f="input";e.zip.useWebWorkers&&o?v(t,{sn:r,codecClass:"NOOP",crcType:f},i,n,a,s,c,u,h,d):y(new l,i,n,a,s,f,c,u,h,d)}function T(e){var t,r,i="",n=["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","ø","£","Ø","×","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","®","¬","½","¼","¡","«","»","_","_","_","¦","¦","Á","Â","À","©","¦","¦","+","+","¢","¥","+","+","-","-","+","-","+","ã","Ã","+","+","-","-","¦","-","+","¤","ð","Ð","Ê","Ë","È","i","Í","Î","Ï","+","+","_","_","¦","Ì","_","Ó","ß","Ô","Ò","õ","Õ","µ","þ","Þ","Ú","Û","Ù","ý","Ý","¯","´","­","±","_","¾","¶","§","÷","¸","°","¨","·","¹","³","²","_"," "];for(t=0;t<e.length;t++)i+=(r=255&e.charCodeAt(t))>127?n[r-128]:String.fromCharCode(r);return i}function M(e){return decodeURIComponent(escape(e))}function S(e){var t,r="";for(t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return r}function k(e,t,r,i,n){e.version=t.view.getUint16(r,!0),e.bitFlag=t.view.getUint16(r+2,!0),e.compressionMethod=t.view.getUint16(r+4,!0),e.lastModDateRaw=t.view.getUint32(r+6,!0),e.lastModDate=function(e){var t=(4294901760&e)>>16,r=65535&e;try{return new Date(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&r)>>11,(2016&r)>>5,2*(31&r),0)}catch(e){}}(e.lastModDateRaw),1!=(1&e.bitFlag)?((i||8!=(8&e.bitFlag))&&(e.crc32=t.view.getUint32(r+10,!0),e.compressedSize=t.view.getUint32(r+14,!0),e.uncompressedSize=t.view.getUint32(r+18,!0)),4294967295!==e.compressedSize&&4294967295!==e.uncompressedSize?(e.filenameLength=t.view.getUint16(r+22,!0),e.extraFieldLength=t.view.getUint16(r+24,!0)):n("File is using Zip64 (4gb+ file size).")):n("File contains encrypted entry.")}function E(e){return unescape(encodeURIComponent(e))}function A(e){var t,r=[];for(t=0;t<e.length;t++)r.push(e.charCodeAt(t));return r}function C(t,r,i,a){var s={},o=[],l=0,c=0;function h(e){i(e||"Error while writing zip file.")}function d(e){i(e||n)}var f={add:function(r,n,f,_,p){var g,m,T,M=this._worker;function S(e,r){var i=u(16);l+=e||0,i.view.setUint32(0,1347094280),void 0!==r&&(g.view.setUint32(10,r,!0),i.view.setUint32(4,r,!0)),n&&(i.view.setUint32(8,e,!0),g.view.setUint32(14,e,!0),i.view.setUint32(12,n.size,!0),g.view.setUint32(18,n.size,!0)),t.writeUint8Array(i.array,(function(){l+=16,f()}),h)}function k(){var f;p=p||{},r=r.trim(),p.directory&&"/"!=r.charAt(r.length-1)&&(r+="/"),s.hasOwnProperty(r)?i("File already exists."):(m=A(E(r)),o.push(r),T=p.lastModDate||new Date,g=u(26),s[r]={headerArray:g.array,directory:p.directory,filename:m,offset:l,comment:A(E(p.comment||""))},g.view.setUint32(0,335546376),p.version&&g.view.setUint8(0,p.version),a||0===p.level||p.directory||g.view.setUint16(4,2048),g.view.setUint16(6,(T.getHours()<<6|T.getMinutes())<<5|T.getSeconds()/2,!0),g.view.setUint16(8,(T.getFullYear()-1980<<4|T.getMonth()+1)<<5|T.getDate(),!0),g.view.setUint16(22,m.length,!0),(f=u(30+m.length)).view.setUint32(0,1347093252),f.array.set(g.array,4),f.array.set(m,30),l+=f.array.length,t.writeUint8Array(f.array,(function(){n?a||0===p.level?b(M,c++,n,t,0,n.size,!0,S,_,d,h):function(t,r,i,n,a,s,o,l,u){var c="input";e.zip.useWebWorkers?v(t,{sn:r,options:{level:a},codecClass:"Deflater",crcType:c},i,n,0,i.size,o,s,l,u):y(new e.zip.Deflater,i,n,0,i.size,c,o,s,l,u)}(M,c++,n,t,p.level,S,_,d,h):S()}),h))}n?n.init(k,d):k()},close:function(e){this._worker&&(this._worker.terminate(),this._worker=null);var r,i,n,a=0,c=0;for(i=0;i<o.length;i++)a+=46+(n=s[o[i]]).filename.length+n.comment.length;for(r=u(a+22),i=0;i<o.length;i++)n=s[o[i]],r.view.setUint32(c,1347092738),r.view.setUint16(c+4,5120),r.array.set(n.headerArray,c+6),r.view.setUint16(c+32,n.comment.length,!0),n.directory&&r.view.setUint8(c+38,16),r.view.setUint32(c+42,n.offset,!0),r.array.set(n.filename,c+46),r.array.set(n.comment,c+46+n.filename.length),c+=46+n.filename.length+n.comment.length;r.view.setUint32(c,1347093766),r.view.setUint16(c+8,o.length,!0),r.view.setUint16(c+10,o.length,!0),r.view.setUint32(c+12,a,!0),r.view.setUint32(c+16,l,!0),t.writeUint8Array(r.array,(function(){t.getData(e)}),h)},_worker:null};e.zip.useWebWorkers?R("deflater",(function(e){f._worker=e,r(f)}),(function(e){i(e)})):r(f)}o.prototype.append=function(e){for(var t=0|this.crc,r=this.table,i=0,n=0|e.length;i<n;i++)t=t>>>8^r[255&(t^e[i])];this.crc=t},o.prototype.get=function(){return~this.crc},o.prototype.table=function(){var e,t,r,i=[];for(e=0;e<256;e++){for(r=e,t=0;t<8;t++)1&r?r=r>>>1^3988292384:r>>>=1;i[e]=r}return i}(),l.prototype.append=function(e,t){return e},l.prototype.flush=function(){},h.prototype=new c,h.prototype.constructor=h,d.prototype=new c,d.prototype.constructor=d,f.prototype=new c,f.prototype.constructor=f,_.prototype.getData=function(e){e(this.data)},p.prototype=new _,p.prototype.constructor=p,g.prototype=new _,g.prototype.constructor=g,m.prototype=new _,m.prototype.constructor=m;var w={deflater:["z-worker.js","deflate.js"],inflater:["z-worker.js","inflate.js"]};function R(t,r,i){if(null===e.zip.workerScripts||null===e.zip.workerScriptsPath){var n,a,s;if(e.zip.workerScripts){if(n=e.zip.workerScripts[t],!Array.isArray(n))return void i(new Error("zip.workerScripts."+t+" is not an array!"));a=n,s=document.createElement("a"),n=a.map((function(e){return s.href=e,s.href}))}else(n=w[t].slice(0))[0]=(e.zip.workerScriptsPath||"")+n[0];var o=new Worker(n[0]);o.codecTime=o.crcTime=0,o.postMessage({type:"importScripts",scripts:n.slice(1)}),o.addEventListener("message",(function e(t){var n=t.data;if(n.error)return o.terminate(),void i(n.error);"importScripts"===n.type&&(o.removeEventListener("message",e),o.removeEventListener("error",l),r(o))})),o.addEventListener("error",l)}else i(new Error("Either zip.workerScripts or zip.workerScriptsPath may be set, not both."));function l(e){o.terminate(),i(e)}}function x(e){console.error(e)}e.zip={Reader:c,Writer:_,BlobReader:f,Data64URIReader:d,TextReader:h,BlobWriter:m,Data64URIWriter:g,TextWriter:p,createReader:function(t,a,s){s=s||x,t.init((function(){!function(t,a,s){var o=0;function l(){}l.prototype.getData=function(i,a,l,c){var h=this;function d(e,t){c&&!function(e){var t=u(4);return t.view.setUint32(0,e),h.crc32==t.view.getUint32(0)}(t)?s("CRC failed."):i.getData((function(e){a(e)}))}function f(e){s(e||n)}function _(e){s(e||"Error while writing file data.")}t.readUint8Array(h.offset,30,(function(n){var a,p=u(n.length,n);1347093252==p.view.getUint32(0)?(k(h,p,4,!1,s),a=h.offset+30+h.filenameLength+h.extraFieldLength,i.init((function(){0===h.compressionMethod?b(h._worker,o++,t,i,a,h.compressedSize,c,d,l,f,_):function(t,r,i,n,a,s,o,l,u,c,h){var d=o?"output":"none";e.zip.useWebWorkers?v(t,{sn:r,codecClass:"Inflater",crcType:d},i,n,a,s,u,l,c,h):y(new e.zip.Inflater,i,n,a,s,d,u,l,c,h)}(h._worker,o++,t,i,a,h.compressedSize,c,d,l,f,_)}),_)):s(r)}),f)};var c={getEntries:function(e){var n=this._worker;!function(e){function n(r,n){t.readUint8Array(t.size-r,r,(function(t){for(var r=t.length-22;r>=0;r--)if(80===t[r]&&75===t[r+1]&&5===t[r+2]&&6===t[r+3])return void e(new DataView(t.buffer,r,22));n()}),(function(){s(i)}))}t.size<22?s(r):n(22,(function(){n(Math.min(65558,t.size),(function(){s(r)}))}))}((function(a){var o,c;o=a.getUint32(16,!0),c=a.getUint16(8,!0),o<0||o>=t.size?s(r):t.readUint8Array(o,t.size-o,(function(t){var i,a,o,h,d=0,f=[],_=u(t.length,t);for(i=0;i<c;i++){if((a=new l)._worker=n,1347092738!=_.view.getUint32(d))return void s(r);k(a,_,d+6,!0,s),a.commentLength=_.view.getUint16(d+32,!0),a.directory=16==(16&_.view.getUint8(d+38)),a.offset=_.view.getUint32(d+42,!0),o=S(_.array.subarray(d+46,d+46+a.filenameLength)),a.filename=2048==(2048&a.bitFlag)?M(o):T(o),a.directory||"/"!=a.filename.charAt(a.filename.length-1)||(a.directory=!0),h=S(_.array.subarray(d+46+a.filenameLength+a.extraFieldLength,d+46+a.filenameLength+a.extraFieldLength+a.commentLength)),a.comment=2048==(2048&a.bitFlag)?M(h):T(h),f.push(a),d+=46+a.filenameLength+a.extraFieldLength+a.commentLength}e(f)}),(function(){s(i)}))}))},close:function(e){this._worker&&(this._worker.terminate(),this._worker=null),e&&e()},_worker:null};e.zip.useWebWorkers?R("inflater",(function(e){c._worker=e,a(c)}),(function(e){s(e)})):a(c)}(t,a,s)}),s)},createWriter:function(e,t,r,i){r=r||x,i=!!i,e.init((function(){C(e,t,r,i)}),r)},useWebWorkers:!0,workerScriptsPath:null,workerScripts:null}}(this)},866:(e,t,r)=>{"use strict";r.r(t),r(50);var i=r(928),n=r(297),a=r(522),s=r(839),o=r(781),l=r(89),u=r(52),c=r(663);function h(){var e=new c.WT(9);return c.WT!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function d(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}function f(e,t){if(e===t){var r=t[1],i=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=i,e[7]=n}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function _(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],f=t[11],_=t[12],p=t[13],g=t[14],m=t[15],v=r*o-i*s,y=r*l-n*s,b=r*u-a*s,T=i*l-n*o,M=i*u-a*o,S=n*u-a*l,k=c*p-h*_,E=c*g-d*_,A=c*m-f*_,C=h*g-d*p,w=h*m-f*p,R=d*m-f*g,x=v*R-y*w+b*C+T*A-M*E+S*k;return x?(x=1/x,e[0]=(o*R-l*w+u*C)*x,e[1]=(l*A-s*R-u*E)*x,e[2]=(s*w-o*A+u*k)*x,e[3]=(n*w-i*R-a*C)*x,e[4]=(r*R-n*A+a*E)*x,e[5]=(i*A-r*w-a*k)*x,e[6]=(p*S-g*M+m*T)*x,e[7]=(g*b-_*S-m*y)*x,e[8]=(_*M-p*b+m*v)*x,e):null}function p(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const g=function(){function e(t,r,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._gl=t,this._buffer=t.createBuffer(),this._type=r,this._hint=i,this._size=0}var t,r;return t=e,(r=[{key:"bind",value:function(){this._buffer||(this._buffer=this._gl.createBuffer()),this._gl.bindBuffer(this._type,this._buffer)}},{key:"release",value:function(){this._gl.deleteBuffer(this._buffer),this._buffer=null,this._size=0}},{key:"update",value:function(e,t){this.bind(),void 0!==t&&t!==e.length&&(e=e.subarray(0,t)),e.length>this._size?(this._gl.bufferData(this._type,e,this._hint),this._size=e.length):this._gl.bufferSubData(this._type,0,e)}}])&&p(t.prototype,r),e}();function m(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const v=function(){function e(t,r,i,n,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._gl=t,this._location=t.getAttribLocation(r,i),this._size=n,this._type=a}var t,r;return t=e,(r=[{key:"unbind",value:function(){this._gl.disableVertexAttribArray(this._location)}},{key:"bindToBuffer",value:function(e){var t=this._gl;e.bind(),t.enableVertexAttribArray(this._location),t.vertexAttribPointer(this._location,this._size,this._type,!1,0,0)}}])&&m(t.prototype,r),e}(),y="// reference\n// https://www.khronos.org/registry/gles/extensions/EXT/EXT_sRGB.txt\n\n#define LIN_SRGB(x) x < 0.0031308 ? x * 12.92 : 1.055 * pow(x, 1.0/2.4) - 0.055\nfloat linearTosRGB(const in float c) {\n return LIN_SRGB(c);\n}\nvec3 linearTosRGB(const in vec3 c) {\n return vec3(LIN_SRGB(c.r), LIN_SRGB(c.g), LIN_SRGB(c.b));\n}\nvec4 linearTosRGB(const in vec4 c) {\n return vec4(LIN_SRGB(c.r), LIN_SRGB(c.g), LIN_SRGB(c.b), c.a);\n}\n\n#define SRGB_LIN(x) x < 0.04045 ? x * (1.0 / 12.92) : pow((x + 0.055) * (1.0 / 1.055), 2.4)\nfloat sRGBToLinear(const in float c) {\n return SRGB_LIN(c);\n}\nvec3 sRGBToLinear(const in vec3 c) {\n return vec3(SRGB_LIN(c.r), SRGB_LIN(c.g), SRGB_LIN(c.b));\n}\nvec4 sRGBToLinear(const in vec4 c) {\n return vec4(SRGB_LIN(c.r), SRGB_LIN(c.g), SRGB_LIN(c.b), c.a);\n}\n\n#define RANGE 5.0\n// http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html\nvec4 encodeRGBM(const in vec3 col) {\n vec4 rgbm;\n vec3 color = col / RANGE;\n rgbm.a = clamp( max( max( color.r, color.g ), max( color.b, 1e-6 ) ), 0.0, 1.0 );\n rgbm.a = ceil( rgbm.a * 255.0 ) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n\nvec3 decodeRGBM(const in vec4 col) {\n return RANGE * col.rgb * col.a;\n}\n";var b={vertexName:"VertexName",fragmentName:"FragmentName",activeAttributes:{vertex:!0,normal:!0,material:!0,color:!0}};b.showSymmetryLine=(0,u.Z)().mirrorline,b.darkenUnselected=(0,u.Z)().darkenunselected,b.sectionCut=!1,b.sectionCutAxis=0,b.sectionCutOffset=0,b.sectionCutInvert=!1,b.uniformNames={},b.uniformNames.commonUniforms=["uMV","uMVP","uN","uEM","uEN","uFlat","uPlaneO","uPlaneN","uSym","uCurvature","uAlpha","uFov","uDarken","uClipPlaneO","uClipPlaneN","uClipEnabled","uClipInvert"],b.strings={},b.strings.colorSpaceGLSL=y,b.strings.vertUniforms=["uniform mat4 uMV;","uniform mat4 uMVP;","uniform mat3 uN;","uniform mat4 uEM;","uniform mat3 uEN;","uniform float uAlpha;"].join("\n"),b.strings.fragColorUniforms=["uniform vec3 uClipPlaneN;","uniform vec3 uClipPlaneO;","uniform int uClipEnabled;","uniform int uClipInvert;","uniform vec3 uPlaneN;","uniform vec3 uPlaneO;","uniform int uSym;","uniform int uDarken;","uniform float uCurvature;","uniform float uFov;","varying float vMasking;","uniform int uFlat;"].join("\n"),b.strings.fragColorFunction=["// http://madebyevan.com/shaders/curvature/\n#extension GL_OES_standard_derivatives : enable\nvec3 computeCurvature( const in vec3 vertex, const in vec3 normal, const in vec3 color, const in float str, const in float fov) {\n if(str < 1e-3)\n return color;\n#ifndef GL_OES_standard_derivatives\n return color * pow(length(normal), str * 100.0);\n#else\n vec3 n = normalize(normal);\n // Compute curvature\n vec3 dx = dFdx(n);\n vec3 dy = dFdy(n);\n vec3 xneg = n - dx;\n vec3 xpos = n + dx;\n vec3 yneg = n - dy;\n vec3 ypos = n + dy;\n // fov < 0.0 means ortho\n float depth = fov > 0.0 ? length(vertex) * fov : -fov;\n float cur = (cross(xneg, xpos).y - cross(yneg, ypos).x) * str * 80.0 / depth;\n return mix(mix(color, color * 0.3, clamp(-cur * 15.0, 0.0, 1.0)), color * 2.0, clamp(cur * 25.0, 0.0, 1.0));\n#endif\n}\n",y,"#extension GL_OES_standard_derivatives : enable","bool isClipped(const in vec3 pos) {"," if (uClipEnabled == 0) return false;"," float side = dot(uClipPlaneN, pos - uClipPlaneO);"," return uClipInvert == 0 ? side > 0.0 : side < 0.0;","}","vec3 getNormal() {"," #ifndef GL_OES_standard_derivatives"," return normalize(gl_FrontFacing ? vNormal : -vNormal);"," #else"," return uFlat == 0 ? normalize(gl_FrontFacing ? vNormal : -vNormal) : -normalize(cross(dFdy(vVertex), dFdx(vVertex)));"," #endif","}","vec4 encodeFragColor(const in vec3 frag, const in float alpha) {"," if (isClipped(vVertex)) discard;"," vec3 col = computeCurvature(vVertex, vNormal, frag, uCurvature, uFov);"," if(uDarken == 1) col *= 0.3;"," col *= (0.3 + 0.7 * vMasking);"," if(uSym == 1 && abs(dot(uPlaneN, vVertex - uPlaneO)) < 0.15)"," col = min(col * 1.5, 1.0);"," return alpha != 1.0 ? vec4(col * alpha, alpha) : encodeRGBM(col);","}"].join("\n");var T,M,S,k,E,A,C,w,R=function(e){var t="",r=e.match(/^\s*(#extension).*/gm);if(r)for(var i={},n=0,a=r.length;n<a;++n){var s=r[n].substr(r[n].indexOf("#extension"));e=e.replace(r[n],""),i[s]||(i[s]=!0,t+=s+"\n")}var o="";-1===e.indexOf("#version")&&(o+="#version 100\n");var l="";return/precision\s+(high|low|medium)p\s+float/.test(e)||(l+="#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n#else\n precision mediump float;\n#endif\n"),o+t+l+e};b.getOrCreate=function(e){if(this.program)return this;var t="\n#define SHADER_NAME "+this.vertexName+"\n",r="\n#define SHADER_NAME "+this.fragmentName+"\n",i=e.createShader(e.VERTEX_SHADER);e.shaderSource(i,R(this.vertex+t)),e.compileShader(i);var n=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(n,R(this.fragment+r)),e.compileShader(n);var a=this.program=e.createProgram();e.attachShader(a,i),e.attachShader(a,n),e.linkProgram(a),e.useProgram(a);var s=e.getShaderInfoLog(i),o=e.getShaderInfoLog(n),l=e.getProgramInfoLog(a);return s&&console.warn(this.vertexName+" (vertex)\n"+s),o&&console.warn(this.fragmentName+" (fragment)\n"+o),l&&console.warn(this.fragmentName+" (program)\n"+l),this.initAttributes(e),this.initUniforms(e),this},b.initUniforms=function(e){for(var t=this.program,r=this.uniformNames,i=this.uniforms,n=0,a=r.length;n<a;++n){var s=r[n];i[s]=e.getUniformLocation(t,s)}},b.updateClipUniforms=(T=i.Ue(),M=i.Ue(),S=i.Ue(),k=i.Ue(),E=h(),A=i.Ue(),C=[[1,0,0],[0,1,0],[0,0,1]],function(e,t,r,n){if(r.getClipDisabled&&r.getClipDisabled())return e.uniform1i(t.uClipEnabled,0),void e.uniform1i(t.uClipInvert,0);var a=n.getMesh()||r,s=b.sectionCut&&a;if(e.uniform1i(t.uClipEnabled,s?1:0),e.uniform1i(t.uClipInvert,b.sectionCutInvert?1:0),s){var o=0|b.sectionCutAxis;(o<0||o>2)&&(o=0),A[0]=C[o][0],A[1]=C[o][1],A[2]=C[o][2];var l=a.computeLocalRadius()*a.getScale(),u=b.sectionCutOffset*l;i.fF(T,a.getCenter(),a.getMatrix()),i.od(M,T,A,u);var c=n.getCamera().getView();i.fF(S,M,c),d(E,c),i.Fv(k,i.kK(k,A,E)),e.uniform3fv(t.uClipPlaneO,S),e.uniform3fv(t.uClipPlaneN,k)}}),b.updateUniforms=(w=[0,0,0],function(e,t){var r=e.getGL(),n=b.darkenUnselected&&t.getIndexSelectMesh(e)<0,a=b.showSymmetryLine&&e.getID()===t.getMesh().getID()&&t.getSculptManager().getSymmetry(),s=this.uniforms;r.uniformMatrix4fv(s.uEM,!1,e.getEditMatrix()),r.uniformMatrix3fv(s.uEN,!1,e.getEN()),r.uniformMatrix4fv(s.uMV,!1,e.getMV()),r.uniformMatrix4fv(s.uMVP,!1,e.getMVP()),r.uniformMatrix3fv(s.uN,!1,e.getN()),r.uniform1i(s.uDarken,n?1:0),r.uniform1i(s.uFlat,e.getFlatShading()),r.uniform3fv(s.uPlaneO,i.fF(w,e.getSymmetryOrigin(),e.getMV())),r.uniform3fv(s.uPlaneN,i.Fv(w,i.kK(w,e.getSymmetryNormal(),e.getN()))),r.uniform1i(s.uSym,a?1:0),r.uniform1f(s.uAlpha,e.getOpacity()),b.updateClipUniforms(r,s,e,t),r.uniform1f(s.uCurvature,e.getCurvature());var o=t.getCamera();r.uniform1f(s.uFov,o.isOrthographic()?25*-Math.abs(o._trans[2]):o.getFov())}),b.draw=function(e,t){e.getGL().useProgram(this.program),this.bindAttributes(e),this.updateUniforms(e,t),this.drawBuffer(e)},b.drawBuffer=function(e){var t=e.getGL();e.isUsingDrawArrays()?t.drawArrays(e.getMode(),0,e.getCount()):(e.getIndexBuffer().bind(),t.drawElements(e.getMode(),e.getCount(),t.UNSIGNED_INT,0)),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),this.unbindAttributes()},b.setTextureParameters=function(e,t){e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),o.Z.isPowerOfTwo(t.width)&&o.Z.isPowerOfTwo(t.height)?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.generateMipmap(e.TEXTURE_2D)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE))},b.onLoadTexture0=function(e,t,r){this.texture0=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),b.setTextureParameters(e,t),e.bindTexture(e.TEXTURE_2D,null),r&&r.render()},b.getDummyTexture=function(e){return this._dummyTex||(this._dummyTex=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this._dummyTex),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array(4)),e.bindTexture(e.TEXTURE_2D,null)),this._dummyTex},b.getOrCreateTexture0=function(e,t,r){if(void 0!==this.texture0)return this.texture0;this.texture0=null;var i=new Image;return i.src=t,i.onload=this.onLoadTexture0.bind(this,e,i,r),!1},b.initAttributes=function(e){var t=this.program,r=this.attributes;r.aVertex=new v(e,t,"aVertex",3,e.FLOAT),r.aNormal=new v(e,t,"aNormal",3,e.FLOAT),r.aColor=new v(e,t,"aColor",3,e.FLOAT),r.aMaterial=new v(e,t,"aMaterial",3,e.FLOAT)},b.bindAttributes=function(e){var t=this.attributes,r=this.activeAttributes;r.vertex&&t.aVertex.bindToBuffer(e.getVertexBuffer()),r.normal&&t.aNormal.bindToBuffer(e.getNormalBuffer()),r.color&&t.aColor.bindToBuffer(e.getColorBuffer()),r.material&&t.aMaterial.bindToBuffer(e.getMaterialBuffer())},b.unbindAttributes=function(){var e=this.attributes,t=this.activeAttributes;t.vertex&&e.aVertex.unbind(),t.normal&&e.aNormal.unbind(),t.color&&e.aColor.unbind(),t.material&&e.aMaterial.unbind()},b.getCopy=function(){for(var e=Object.keys(b),t={},r=0,i=e.length;r<i;++r)t[e[r]]=this[e[r]];return t.program=null,t};const x=b,P="#define PI 3.1415926535897932384626433832795\n#define PI_2 (2.0 * 3.1415926535897932384626433832795)\n#define INV_PI 1.0 / PI\n#define INV_LOG2 1.4426950408889634073599246810019\n\nuniform sampler2D uTexture0;\nuniform float uExposure;\nuniform mat3 uIblTransform;\nuniform vec3 uSPH[9];\n\nuniform vec2 uEnvSize;\n#define LIMIT_LOD 5.0\n\n// https://mynameismjp.wordpress.com/2008/12/12/logluv-encoding-for-hdr/\nconst mat3 LUVInverse = mat3(6.0013, -2.700, -1.7995, -1.332, 3.1029, -5.7720,\n 0.3007, -1.088, 5.6268);\nvec3 decodeLUV(const in vec4 logLuv) {\n float Le = logLuv.z * 255.0 + logLuv.w;\n vec3 xp;\n xp.y = exp2((Le - 127.0) / 2.0);\n xp.z = xp.y / logLuv.y;\n xp.x = logLuv.x * xp.z;\n return max(LUVInverse * xp, 0.0);\n}\n\nvec2 toUVMipmap(const in float lod, const in vec2 uv) {\n float widthForLevel = uEnvSize.x / exp2(lod);\n vec2 uvSpaceLocal = vec2(1.0) + uv * (widthForLevel - 2.0);\n uvSpaceLocal.y += uEnvSize.y - widthForLevel * 2.0;\n return uvSpaceLocal / uEnvSize;\n}\n\nvec2 directionToUV(const in vec3 dir) {\n vec3 signOct = sign(dir);\n vec3 uvOct = dir / dot(dir, signOct);\n if (uvOct.z < 0.0) {\n uvOct.xy = signOct.xy * (1.0 - abs(uvOct)).yx;\n }\n return uvOct.xy * 0.5 + 0.5;\n}\n\nvec3 texturePanoramaLod(const in vec3 direction, const in float rLinear) {\n float lod = rLinear * (LIMIT_LOD - 1.0);\n vec2 uvBase = directionToUV(direction);\n return decodeLUV(mix(texture2D(uTexture0, toUVMipmap(floor(lod), uvBase)),\n texture2D(uTexture0, toUVMipmap(ceil(lod), uvBase)),\n fract(lod)));\n}\n\nvec3 integrateBRDFApprox(const in vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\n vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\n return specular * AB.x + AB.y;\n}\n\nvec3 getSpecularDominantDir(const in vec3 N, const in vec3 R,\n const in float realRoughness) {\n float smoothness = 1.0 - realRoughness;\n return mix(N, R, smoothness * (sqrt(smoothness) + realRoughness));\n}\n\nvec3 approximateSpecularIBL(const in vec3 specularColor, float rLinear,\n const in vec3 N, const in vec3 V) {\n float NoV = clamp(dot(N, V), 0.0, 1.0);\n vec3 R = normalize((2.0 * NoV) * N - V);\n R = getSpecularDominantDir(N, R, rLinear);\n vec3 prefilteredColor = texturePanoramaLod(uIblTransform * R, rLinear);\n return prefilteredColor * integrateBRDFApprox(specularColor, rLinear, NoV);\n}\n\n// expect shCoefs uniform\n// https://github.com/cedricpinson/envtools/blob/master/Cubemap.cpp#L523\nvec3 sphericalHarmonics(const in vec3 N) {\n float x = N.x;\n float y = N.y;\n float z = -N.z;\n vec3 result = uSPH[0] + uSPH[1] * y + uSPH[2] * z + uSPH[3] * x +\n uSPH[4] * y * x + uSPH[5] * y * z +\n uSPH[6] * (3.0 * z * z - 1.0) + uSPH[7] * (z * x) +\n uSPH[8] * (x * x - y * y);\n return max(result, vec3(0.0));\n}\n\nvec3 computeIBL_UE4(const in vec3 N, const in vec3 V, const in vec3 albedo,\n const in float roughness, const in vec3 specular) {\n vec3 color = albedo * sphericalHarmonics(uIblTransform * N);\n color += approximateSpecularIBL(specular, roughness, N, V);\n return color;\n}\n";var D=x.getCopy();D.vertexName=D.fragmentName="ShadingPBR",D.textures={};var I="resources/environments/";D.environments=[{path:I+"mpumalanga_veld_1k.png",sph:[.136819,.174125,.253762,.027778,.056838,.131221,.074356,.086793,.099181,-.07904,-.091269,-.102346,-.02755,-.0323,-.039217,.031822,.034773,.039945,.017235,.021044,.026136,-.106608,-.11864,-.132761,.041,.049794,.061183],exposure:2.5,name:"Mpumalanga veld"},{path:I+"venetian_crossroads_1k.png",sph:[.200626,.198426,.209579,.090452,.127807,.18839,.093188,.103245,.106131,.033349,.054751,.067044,.07435,.08167,.079716,.063127,.08594,.10171,.007751,.00571,-791e-6,.104134,.103979,.094236,-.022747,-.028166,-.037714],exposure:2.5,name:"Venetian crossroads"},{path:I+"studio_small_01_1k.png",sph:[.534107,.589985,.617478,.119999,.13048,.128019,.089872,.088707,.088017,.099999,.151282,.138458,.005015,.035588,.027592,.114999,.116739,.120579,-.057997,-.069532,-.070401,.385123,.411714,.454725,.303242,.333004,.35027],exposure:.5,name:"Studio small 01"},{path:I+"moonless_golf_1k.png",sph:[.137579,.112906,.09347,.070711,.066043,.065337,-.029564,-.02072,-.007737,-.037254,-.03327,-.028294,-.023847,-.021208,-.018767,-.007873,-.002587,.003955,.009241,.007711,.006063,.017917,.011733,.007669,.036859,.026285,.01474],exposure:1,name:"Moonless golf"},{path:I+"winter_river_1k.png",sph:[.560145,.554695,.513523,-.213105,-.15519,-.063568,.135182,.114211,.069349,.172852,.15182,.105477,.065753,.06405,.052622,.096352,.086557,.063826,.02183,.01656,.008804,.186193,.16372,.119627,.025363,.022278,.014461],exposure:.5,name:"Winter river"}];var F=(0,u.Z)();D.idEnv=Math.min(F.environment,D.environments.length-1),D.exposure=void 0===F.exposure?D.environments[D.idEnv].exposure:Math.min(F.exposure,5),D.uniforms={},D.attributes={},D.uniformNames=["uIblTransform","uTexture0","uAlbedo","uRoughness","uMetallic","uExposure","uSPH","uEnvSize"],Array.prototype.push.apply(D.uniformNames,x.uniformNames.commonUniforms),D.vertex=["attribute vec3 aVertex;","attribute vec3 aNormal;","attribute vec3 aColor;","attribute vec3 aMaterial;",x.strings.vertUniforms,"uniform float uRoughness;","uniform float uMetallic;","uniform vec3 uAlbedo;","varying vec3 vVertex;","varying vec3 vNormal;","varying vec3 vAlbedo;","varying float vRoughness;","varying float vMetallic;","varying float vMasking;","void main() {"," vAlbedo = uAlbedo.x >= 0.0 ? uAlbedo : aColor;"," vRoughness = uRoughness >= 0.0 ? uRoughness : aMaterial.x;"," vMetallic = uMetallic >= 0.0 ? uMetallic : aMaterial.y;"," vMasking = aMaterial.z;"," vNormal = mix(aNormal, uEN * aNormal, vMasking);"," vNormal = normalize(uN * vNormal);"," vec4 vertex4 = vec4(aVertex, 1.0);"," vertex4 = mix(vertex4, uEM * vertex4, vMasking);"," vVertex = vec3(uMV * vertex4);"," gl_Position = uMVP * vertex4;","}"].join("\n"),D.fragment=["varying vec3 vVertex;","varying vec3 vNormal;","varying vec3 vAlbedo;","varying float vRoughness;","varying float vMetallic;","uniform float uAlpha;",x.strings.fragColorUniforms,x.strings.fragColorFunction,P,"","void main(void) {"," vec3 normal = getNormal();"," float roughness = max( 0.0001, vRoughness );"," vec3 linColor = sRGBToLinear(vAlbedo);"," vec3 albedo = linColor * (1.0 - vMetallic);"," vec3 specular = mix( vec3(0.04), linColor, vMetallic);",""," vec3 color = uExposure * computeIBL_UE4( normal, -normalize(vVertex), albedo, roughness, specular );"," gl_FragColor = encodeFragColor(color, uAlpha);","}"].join("\n"),D.onLoadEnvironment=function(e,t,r,i){if(!e.status||200===e.status||e.response&&e.response.byteLength){var n=e.width||Math.sqrt(e.response.byteLength/8),a=2*n;i.size=[n,a],i.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,i.texture),e.response?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,n,a,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(e.response)):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.bindTexture(t.TEXTURE_2D,null),r&&r.render()}},D.getOrCreateEnvironment=function(e,t,r){if(void 0!==r.texture)return r.texture;if(r.texture=null,r.path.endsWith("png")){var i=new Image;return i.src=r.path,i.onload=D.onLoadEnvironment.bind(this,i,e,t,r),null}var n=new XMLHttpRequest;return n.open("GET",r.path,!0),n.responseType="arraybuffer",n.onload=D.onLoadEnvironment.bind(this,n,e,t,r),n.send(null),null};var O=h();D.updateUniforms=function(e,t){var r=e.getGL(),i=this.uniforms;d(O,t.getCamera().getView()),r.uniformMatrix3fv(i.uIblTransform,!1,f(O,O)),r.uniform3fv(i.uAlbedo,e.getAlbedo()),r.uniform1f(i.uRoughness,e.getRoughness()),r.uniform1f(i.uMetallic,e.getMetallic()),r.uniform1f(i.uExposure,D.exposure);var n=D.environments[D.idEnv];r.uniform3fv(i.uSPH,n.sph),n.size&&r.uniform2fv(i.uEnvSize,n.size),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,D.getOrCreateEnvironment(r,t,n)||this.getDummyTexture(r)),r.uniform1i(i.uTexture0,0),x.updateUniforms.call(this,e,t)};const L=D;var V=r(183),N=x.getCopy();N.vertexName=N.fragmentName="Matcap",N.textures={},N.createTexture=function(e,t,r){var i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),N.setTextureParameters(e,t),e.bindTexture(e.TEXTURE_2D,null),N.textures[r]=i},N.matcaps=[{path:"resources/matcaps/matcapFV.jpg",name:"matcap FV"},{path:"resources/matcaps/redClay.jpg",name:"Red clay"},{path:"resources/matcaps/skinHazardousarts.jpg",name:"Skin hazardousarts"},{path:"resources/matcaps/skinHazardousarts2.jpg",name:"Skin Hazardousarts2"},{path:"resources/matcaps/pearl.jpg",name:(0,V.Z)("matcapPearl")},{path:"resources/matcaps/clay.jpg",name:(0,V.Z)("matcapClay")},{path:"resources/matcaps/skin.jpg",name:(0,V.Z)("matcapSkin")},{path:"resources/matcaps/green.jpg",name:(0,V.Z)("matcapGreen")},{path:"resources/matcaps/white.jpg",name:(0,V.Z)("matcapWhite")}],N.uniforms={},N.attributes={},N.uniformNames=["uTexture0","uAlbedo"],Array.prototype.push.apply(N.uniformNames,x.uniformNames.commonUniforms),N.vertex=["attribute vec3 aVertex;","attribute vec3 aNormal;","attribute vec3 aColor;","attribute vec3 aMaterial;",x.strings.vertUniforms,"varying vec3 vVertex;","varying vec3 vNormal;","varying vec3 vColor;","varying float vMasking;","varying vec3 vVertexPres;","uniform vec3 uAlbedo;","void main() {"," vColor = uAlbedo.x >= 0.0 ? uAlbedo : aColor;"," vMasking = aMaterial.z;"," vNormal = mix(aNormal, uEN * aNormal, vMasking);"," vNormal = normalize(uN * vNormal);"," vec4 vertex4 = vec4(aVertex, 1.0);"," vertex4 = mix(vertex4, uEM * vertex4, vMasking);"," vVertex = vec3(uMV * vertex4);"," vVertexPres = vVertex / max(1.0, abs(uMV[3][2]));"," gl_Position = uMVP * vertex4;","}"].join("\n"),N.fragment=["uniform sampler2D uTexture0;","varying vec3 vVertex;","varying vec3 vVertexPres;","varying vec3 vNormal;","varying vec3 vColor;","uniform float uAlpha;",x.strings.fragColorUniforms,x.strings.fragColorFunction,"void main() {"," vec3 normal = getNormal();"," vec3 nm_z = normalize(vVertexPres);"," vec3 nm_x = vec3(-nm_z.z, 0.0, nm_z.x);"," vec3 nm_y = cross(nm_x, nm_z);"," vec2 texCoord = 0.5 + 0.5 * vec2(dot(normal, nm_x), dot(normal, nm_y));"," vec3 color = sRGBToLinear(texture2D(uTexture0, texCoord).rgb) * sRGBToLinear(vColor);"," gl_FragColor = encodeFragColor(color, uAlpha);","}"].join("\n"),N.updateUniforms=function(e,t){var r=e.getGL(),i=this.uniforms;r.activeTexture(r.TEXTURE0),e.setTexture0(N.textures[e.getMatcap()]),r.bindTexture(r.TEXTURE_2D,e.getTexture0()||this.getDummyTexture(r)),r.uniform1i(i.uTexture0,0),r.uniform3fv(i.uAlbedo,e.getAlbedo()),x.updateUniforms.call(this,e,t)};const B=N;var U=x.getCopy();U.vertexName=U.fragmentName="ShowNormal",U.uniforms={},U.attributes={},U.activeAttributes={vertex:!0,normal:!0,material:!0},U.uniformNames=[],Array.prototype.push.apply(U.uniformNames,x.uniformNames.commonUniforms),U.vertex=["attribute vec3 aVertex;","attribute vec3 aNormal;","attribute vec3 aMaterial;",x.strings.vertUniforms,"varying vec3 vVertex;","varying vec3 vNormal;","varying float vMasking;","void main() {"," vMasking = aMaterial.z;"," vNormal = mix(aNormal, uEN * aNormal, vMasking);"," vNormal = normalize(uN * vNormal);"," vec4 vertex4 = vec4(aVertex, 1.0);"," vertex4 = mix(vertex4, uEM *vertex4, vMasking);"," vVertex = vec3(uMV * vertex4);"," gl_Position = uMVP * vertex4;","}"].join("\n"),U.fragment=["varying vec3 vVertex;","varying vec3 vNormal;","uniform float uAlpha;",x.strings.fragColorUniforms,x.strings.fragColorFunction,"void main() {"," gl_FragColor = encodeFragColor(sRGBToLinear(getNormal() * 0.5 + 0.5), uAlpha);","}"].join("\n");const Z=U;var G=x.getCopy();G.vertexName=G.fragmentName="ShowUV",G.texPath="resources/uv.png",G.uniforms={},G.attributes={},G.uniformNames=["uTexture0","uAlbedo"],Array.prototype.push.apply(G.uniformNames,x.uniformNames.commonUniforms),G.vertex=["attribute vec3 aVertex;","attribute vec3 aNormal;","attribute vec3 aColor;","attribute vec2 aTexCoord;","attribute vec3 aMaterial;",x.strings.vertUniforms,"varying vec3 vVertex;","varying vec3 vNormal;","varying vec3 vColor;","varying vec2 vTexCoord;","varying float vMasking;","uniform vec3 uAlbedo;","void main() {"," vColor = uAlbedo.x >= 0.0 ? uAlbedo : aColor;"," vTexCoord = aTexCoord;"," vMasking = aMaterial.z;"," vNormal = mix(aNormal, uEN * aNormal, vMasking);"," vNormal = normalize(uN * vNormal);"," vec4 vertex4 = vec4(aVertex, 1.0);"," vertex4 = mix(vertex4, uEM *vertex4, vMasking);"," vVertex = vec3(uMV * vertex4);"," gl_Position = uMVP * vertex4;","}"].join("\n"),G.fragment=["uniform sampler2D uTexture0;","varying vec3 vVertex;","varying vec3 vNormal;","varying vec3 vColor;","varying vec2 vTexCoord;","uniform float uAlpha;",x.strings.fragColorUniforms,x.strings.fragColorFunction,"void main() {"," vec3 color = sRGBToLinear(texture2D(uTexture0, vTexCoord).rgb) * sRGBToLinear(vColor);"," gl_FragColor = encodeFragColor(color, uAlpha);","}"].join("\n"),G.draw=x.draw,G.drawBuffer=x.drawBuffer,G.getOrCreate=x.getOrCreate,G.initUniforms=x.initUniforms,G.initAttributes=function(e){x.initAttributes.call(this,e),G.attributes.aTexCoord=new v(e,G.program,"aTexCoord",2,e.FLOAT)},G.bindAttributes=function(e){x.bindAttributes.call(this,e),G.attributes.aTexCoord.bindToBuffer(e.getTexCoordBuffer())},G.updateUniforms=function(e,t){var r=e.getGL(),i=this.uniforms;r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.getOrCreateTexture0(r,G.texPath,t)||this.getDummyTexture(r)),r.uniform1i(i.uTexture0,0),r.uniform3fv(i.uAlbedo,e.getAlbedo()),x.updateUniforms.call(this,e,t)};const W=G;var j=x.getCopy();j.vertexName=j.fragmentName="Wireframe",j.uniforms={},j.attributes={},j.activeAttributes={vertex:!0,material:!0},j.uniformNames=["uMVP","uMV","uEM","uClipPlaneO","uClipPlaneN","uClipEnabled","uClipInvert"],j.vertex=["attribute vec3 aVertex;","attribute vec3 aMaterial;","uniform mat4 uMVP;","uniform mat4 uMV;","uniform mat4 uEM;","varying vec3 vVertex;","void main() {"," vec4 vertex4 = vec4(aVertex, 1.0);"," vec4 skinned = mix(vertex4, uEM * vertex4, aMaterial.z);"," vVertex = vec3(uMV * skinned);"," vec4 pos = uMVP * skinned;"," pos[3] += 0.0001;"," gl_Position = pos;","}"].join("\n"),j.fragment=["uniform vec3 uClipPlaneN;","uniform vec3 uClipPlaneO;","uniform int uClipEnabled;","uniform int uClipInvert;","varying vec3 vVertex;","void main() {"," if (uClipEnabled == 1) {"," float side = dot(uClipPlaneN, vVertex - uClipPlaneO);"," if ((uClipInvert == 0 && side > 0.0) || (uClipInvert == 1 && side < 0.0)) discard;"," }"," gl_FragColor = vec4(0.0, 0.0, 0.0, 0.4);","}"].join("\n"),j.getOrCreate=x.getOrCreate,j.draw=function(e,t){var r=e.getGL();r.useProgram(this.program),this.bindAttributes(e),this.updateUniforms(e,t),e.getWireframeBuffer().bind(),r.drawElements(r.LINES,2*e.getRenderNbEdges(),r.UNSIGNED_INT,0)},j.updateUniforms=function(e,t){var r=e.getGL();r.uniformMatrix4fv(this.uniforms.uMVP,!1,e.getMVP()),r.uniformMatrix4fv(this.uniforms.uMV,!1,e.getMV()),r.uniformMatrix4fv(this.uniforms.uEM,!1,e.getEditMatrix()),x.updateClipUniforms(r,this.uniforms,e,t)};const z=j;var X=x.getCopy();X.vertexName=X.fragmentName="FlatColor",X.uniforms={},X.attributes={},X.activeAttributes={vertex:!0,material:!0},X.uniformNames=["uColor"],Array.prototype.push.apply(X.uniformNames,x.uniformNames.commonUniforms),X.vertex=["attribute vec3 aVertex;","attribute vec3 aMaterial;",x.strings.vertUniforms,"varying vec3 vVertex;","void main() {"," vec4 vertex4 = vec4(aVertex, 1.0);"," vec4 skinned = mix(vertex4, uEM * vertex4, aMaterial.z);"," vVertex = vec3(uMV * skinned);"," gl_Position = uMVP * skinned;","}"].join("\n"),X.fragment=["uniform vec3 uColor;","uniform vec3 uClipPlaneN;","uniform vec3 uClipPlaneO;","uniform int uClipEnabled;","uniform int uClipInvert;","varying vec3 vVertex;","void main() {"," if (uClipEnabled == 1) {"," float side = dot(uClipPlaneN, vVertex - uClipPlaneO);"," if ((uClipInvert == 0 && side > 0.0) || (uClipInvert == 1 && side < 0.0)) discard;"," }"," gl_FragColor = vec4(uColor, 1.0);","}"].join("\n"),X.updateUniforms=function(e,t){e.getGL().uniform3fv(this.uniforms.uColor,e.getFlatColor()),x.updateUniforms.call(this,e,t)};const K=X;var H=x.getCopy();H.vertexName=H.fragmentName="ShowSelection",H.uniforms={},H.attributes={},H.activeAttributes={vertex:!0},H.uniformNames=["uMVP","uColor"],H.vertex=["attribute vec3 aVertex;","uniform mat4 uMVP;","void main() {"," gl_Position = uMVP * vec4(aVertex, 1.0);","}"].join("\n"),H.fragment=["uniform vec3 uColor;","void main() {"," gl_FragColor = vec4(uColor, 1.0);","}"].join("\n"),H.draw=function(e,t,r){var i=e.getGL();i.useProgram(this.program),i.uniform3fv(this.uniforms.uColor,e.getColor()),t&&(i.uniformMatrix4fv(this.uniforms.uMVP,!1,e.getCircleMVP()),H.attributes.aVertex.bindToBuffer(e.getCircleBuffer()),i.drawArrays(i.LINE_LOOP,0,e.getCircleBuffer()._size/3)),i.uniformMatrix4fv(this.uniforms.uMVP,!1,e.getDotMVP()),H.attributes.aVertex.bindToBuffer(e.getDotBuffer()),i.drawArrays(i.TRIANGLE_FAN,0,e.getDotBuffer()._size/3),r&&(i.uniformMatrix4fv(this.uniforms.uMVP,!1,e.getDotSymmetryMVP()),i.drawArrays(i.TRIANGLE_FAN,0,e.getDotBuffer()._size/3))};const Y=H;var q=x.getCopy();q.vertexName=q.fragmentName="Background",q.uniforms={},q.attributes={},q.uniformNames=["uTexture0","uBackgroundType","uIblTransform","uSPH","uBlur","uEnvSize"],q.vertex=["attribute vec2 aVertex;","attribute vec2 aTexCoord;","varying vec2 vTexCoord;","void main() {"," vTexCoord = aTexCoord;"," gl_Position = vec4(aVertex, 1.0, 1.0);","}"].join("\n"),q.fragment=["varying vec2 vTexCoord;",x.strings.colorSpaceGLSL,P,"uniform int uBackgroundType;\nuniform float uBlur;\n\nvoid main() {\n vec3 color;\n if (uBackgroundType == 0) {\n color = sRGBToLinear(texture2D(uTexture0, vTexCoord).rgb);\n } else {\n vec3 dir = uIblTransform * vec3(vTexCoord.xy * 2.0 - 1.0, -1.0);\n dir = normalize(dir);\n if (uBackgroundType == 1) {\n color = texturePanoramaLod(dir, uBlur * uBlur);\n } else {\n color = sphericalHarmonics(dir);\n }\n }\n gl_FragColor = encodeRGBM(color);\n}\n"].join("\n"),q.draw=function(e){var t=e.getGL();t.useProgram(this.program),this.bindAttributes(e),this.updateUniforms(e),t.drawArrays(t.TRIANGLE_STRIP,0,4)},q.initAttributes=function(e){var t=q.program,r=q.attributes;r.aVertex=new v(e,t,"aVertex",2,e.FLOAT),r.aTexCoord=new v(e,t,"aTexCoord",2,e.FLOAT)},q.bindAttributes=function(e){var t=q.attributes;t.aVertex.bindToBuffer(e.getVertexBuffer()),t.aTexCoord.bindToBuffer(e.getTexCoordBuffer())};var J=h();q.updateUniforms=function(e){var t,r=this.uniforms,i=e._main,n=L.environments[L.idEnv],a=e.getGL();a.uniform1i(r.uBackgroundType,e.getType()),t=0===e.getType()?e.getTexture():L.getOrCreateEnvironment(a,i,n)||e.getTexture(),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,t),a.uniform1i(r.uTexture0,0),d(J,i.getCamera().getView()),a.uniformMatrix3fv(r.uIblTransform,!1,f(J,J)),a.uniform3fv(r.uSPH,n.sph),n.size&&a.uniform2fv(r.uEnvSize,n.size),a.uniform1f(r.uBlur,e.getBlur())};const Q=q;var $=x.getCopy();$.vertexName=$.fragmentName="Merge",$.FILMIC=(0,u.Z)().filmic,$.uniforms={},$.attributes={},$.uniformNames=["uTexture0","uTexture1","uFilmic"],$.vertex=["attribute vec2 aVertex;","varying vec2 vTexCoord;","void main() {"," vTexCoord = aVertex * 0.5 + 0.5;"," gl_Position = vec4(aVertex, 0.5, 1.0);","}"].join("\n"),$.fragment=["uniform sampler2D uTexture0;","uniform sampler2D uTexture1;","uniform int uFilmic;","varying vec2 vTexCoord;",x.strings.colorSpaceGLSL,"void main() {"," vec4 transparent = texture2D(uTexture1, vTexCoord);"," vec3 color = decodeRGBM(texture2D(uTexture0, vTexCoord))*(1.0-transparent.a) + transparent.rgb;"," if(uFilmic == 1){"," vec3 x = max(vec3(0.0), color - vec3(0.004));"," gl_FragColor = vec4((x*(6.2*x+0.5))/(x*(6.2*x+1.7)+0.06), 1.0);"," }else{"," gl_FragColor = vec4(linearTosRGB(color), 1.0);"," }","}"].join("\n"),$.draw=function(e,t){var r=e.getGL();r.useProgram(this.program),$.attributes.aVertex.bindToBuffer(e.getVertexBuffer()),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,t._rttOpaque.getTexture()),r.uniform1i(this.uniforms.uTexture0,0),r.activeTexture(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,t._rttTransparent.getTexture()),r.uniform1i(this.uniforms.uTexture1,1),r.uniform1i(this.uniforms.uFilmic,$.FILMIC),r.drawArrays(r.TRIANGLES,0,3)},$.initAttributes=function(e){$.attributes.aVertex=new v(e,$.program,"aVertex",2,e.FLOAT)};const ee=$;var te=x.getCopy();te.vertexName=te.fragmentName="Fxaa",te.FILMIC=(0,u.Z)().filmic,te.uniforms={},te.attributes={},te.uniformNames=["uTexture0","uInvSize"],te.vertex=["attribute vec2 aVertex;","uniform vec2 uInvSize;","varying vec2 vUVNW;","varying vec2 vUVNE;","varying vec2 vUVSW;","varying vec2 vUVSE;","varying vec2 vUVM;","void main() {"," vUVM = aVertex * 0.5 + 0.5;"," vUVNW = vUVM + vec2(-1.0, -1.0) * uInvSize;"," vUVNE = vUVM + vec2(1.0, -1.0) * uInvSize;"," vUVSW = vUVM + vec2(-1.0, 1.0) * uInvSize;"," vUVSE = vUVM + vec2(1.0, 1.0) * uInvSize;"," gl_Position = vec4(aVertex, 0.5, 1.0);","}"].join("\n"),te.fragment=["uniform sampler2D uTexture0;","uniform vec2 uInvSize;","varying vec2 vUVNW;","varying vec2 vUVNE;","varying vec2 vUVSW;","varying vec2 vUVSE;","varying vec2 vUVM;","// https://github.com/mattdesl/glsl-fxaa\n#define FXAA_REDUCE_MIN (1.0/ 128.0)\n#define FXAA_REDUCE_MUL (1.0 / 8.0)\n#define FXAA_SPAN_MAX 8.0\n\nvec3 fxaa(const in sampler2D tex, const in vec2 uvNW, const in vec2 uvNE, const in vec2 uvSW, const in vec2 uvSE, const in vec2 uvM, const in vec2 invRes) {\n const vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(texture2D(tex, uvNW).xyz, luma);\n float lumaNE = dot(texture2D(tex, uvNE).xyz, luma);\n float lumaSW = dot(texture2D(tex, uvSW).xyz, luma);\n float lumaSE = dot(texture2D(tex, uvSE).xyz, luma);\n float lumaM = dot(texture2D(tex, uvM).xyz, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec2 dir = vec2(-((lumaNW + lumaNE) - (lumaSW + lumaSE)), ((lumaNW + lumaSW) - (lumaNE + lumaSE)));\n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * invRes;\n \n vec3 rgbA = 0.5 * ( texture2D(tex, uvM + dir * (1.0 / 3.0 - 0.5)).xyz + texture2D(tex, uvM + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * ( texture2D(tex, uvM - dir * 0.5).xyz + texture2D(tex, uvM + dir * 0.5).xyz);\n \n float lumaB = dot(rgbB, luma);\n if((lumaB < lumaMin) || (lumaB > lumaMax))\n return rgbA;\n return rgbB;\n}",x.strings.colorSpaceGLSL,"void main() {"," gl_FragColor = vec4(fxaa(uTexture0, vUVNW, vUVNE, vUVSW, vUVSE, vUVM, uInvSize), 1.0);","}"].join("\n"),te.draw=function(e,t){var r=e.getGL();r.useProgram(this.program),te.attributes.aVertex.bindToBuffer(e.getVertexBuffer()),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,t._rttMerge.getTexture()),r.uniform1i(this.uniforms.uTexture0,0),r.uniform2fv(this.uniforms.uInvSize,e.getInverseSize()),r.drawArrays(r.TRIANGLES,0,3)},te.initAttributes=function(e){te.attributes.aVertex=new v(e,te.program,"aVertex",2,e.FLOAT)};const re=te;var ie=x.getCopy();ie.vertexName=ie.fragmentName="SobelContour",ie.color=(0,u.Z)().outlinecolor,ie.uniforms={},ie.attributes={},ie.uniformNames=["uTexture0","uColor","uInvSize"],ie.vertex=["attribute vec2 aVertex;","varying vec2 vTexCoord;","void main() {"," vTexCoord = aVertex * 0.5 + 0.5;"," gl_Position = vec4(aVertex, 0.0, 1.0);","}"].join("\n"),ie.fragment=["#extension GL_OES_standard_derivatives : enable","uniform sampler2D uTexture0;","uniform vec4 uColor;","varying vec2 vTexCoord;","uniform vec2 uInvSize;","\nfloat outlineDistance( const in vec2 uv, const in sampler2D tex, const in vec2 invSize ) {\n float fac0 = 2.0;\n float fac1 = 1.0;\n float ox = invSize.x;\n float oy = invSize.y;\n vec4 texel0 = texture2D(tex, uv + vec2(ox, oy));\n vec4 texel1 = texture2D(tex, uv + vec2(ox, 0.0));\n vec4 texel2 = texture2D(tex, uv + vec2(ox, -oy));\n vec4 texel3 = texture2D(tex, uv + vec2(0.0, -oy));\n vec4 texel4 = texture2D(tex, uv + vec2(-ox, -oy));\n vec4 texel5 = texture2D(tex, uv + vec2(-ox, 0.0));\n vec4 texel6 = texture2D(tex, uv + vec2(-ox, oy));\n vec4 texel7 = texture2D(tex, uv + vec2(0.0, oy));\n vec4 rowx = -fac0 * texel5 + fac0 * texel1 + -fac1 * texel6 + fac1 * texel0 + -fac1 * texel4 + fac1 * texel2;\n vec4 rowy = -fac0 * texel3 + fac0 * texel7 + -fac1 * texel4 + fac1 * texel6 + -fac1 * texel2 + fac1 * texel0;\n return dot(rowy, rowy) + dot(rowx, rowx);\n}\n",x.strings.colorSpaceGLSL,"void main() {"," float mag = outlineDistance(vTexCoord, uTexture0, uInvSize);"," if (mag < 1.5) discard;"," gl_FragColor = vec4(sRGBToLinear(uColor.rgb) * uColor.a, uColor.a);","}"].join("\n"),ie.draw=function(e){var t=e.getGL();t.useProgram(this.program),ie.attributes.aVertex.bindToBuffer(e.getVertexBuffer()),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,e.getTexture()),t.uniform1i(this.uniforms.uTexture0,0),t.uniform4fv(this.uniforms.uColor,ie.color),t.uniform2fv(this.uniforms.uInvSize,e.getInverseSize()),t.drawArrays(t.TRIANGLES,0,3)},ie.initAttributes=function(e){ie.attributes.aVertex=new v(e,ie.program,"aVertex",2,e.FLOAT)};const ne=ie;var ae=x.getCopy();ae.CHANNEL_VALUE=0,ae.vertexName=ae.fragmentName="PaintUV",ae.uniforms={},ae.attributes={},ae.uniformNames=["uChannelPaint"],ae.activeAttributes={color:!0,material:!0},ae.vertex=["attribute vec2 aTexCoord;","attribute vec3 aColor;","attribute vec3 aMaterial;","varying vec3 vColor;","varying vec2 vMaterial;","void main() {"," vColor = aColor;"," vMaterial = aMaterial.xy;"," gl_Position = vec4((aTexCoord * 2.0 - 1.0) * vec2(1.0, -1.0), 0.5, 1.0);","}"].join("\n"),ae.fragment=["varying vec3 vColor;","varying vec2 vMaterial;","uniform int uChannelPaint;","void main() {"," gl_FragColor = vec4(uChannelPaint == 0 ? vColor : uChannelPaint == 1 ? vMaterial.xxx : vMaterial.yyy, 1.0);","}"].join("\n"),ae.initAttributes=function(e){x.initAttributes.call(this,e),ae.attributes.aTexCoord=new v(e,ae.program,"aTexCoord",2,e.FLOAT)},ae.bindAttributes=function(e){x.bindAttributes.call(this,e),ae.attributes.aTexCoord.bindToBuffer(e.getTexCoordBuffer())},ae.updateUniforms=function(e){e.getGL().uniform1i(this.uniforms.uChannelPaint,ae.CHANNEL_VALUE)};const se=ae;var oe=x.getCopy();oe.vertexName=oe.fragmentName="Blur",oe.INPUT_TEXTURE=null,oe.uniforms={},oe.attributes={},oe.uniformNames=["uTexture0","uInvSize"],oe.vertex=["attribute vec2 aVertex;","varying vec2 vTexCoord;","void main() {"," vTexCoord = aVertex * 0.5 + 0.5;"," gl_Position = vec4(aVertex, 0.5, 1.0);","}"].join("\n"),oe.fragment=["uniform sampler2D uTexture0;","varying vec2 vTexCoord;","uniform vec2 uInvSize;",x.strings.colorSpaceGLSL,"void main() {"," const int KER_SIZE = 8;"," vec4 avg = texture2D(uTexture0, vTexCoord);"," if (avg.a < 0.1) {"," for (int i = -KER_SIZE; i <= KER_SIZE; ++i) {"," for (int j = -KER_SIZE; j <= KER_SIZE; ++j) {"," if (i == 0 && j == 0) continue;"," vec4 fetch = texture2D(uTexture0, vTexCoord + vec2(i, j) * uInvSize);"," avg.rgb += sRGBToLinear(fetch.rgb) * fetch.a;"," avg.a += fetch.a;"," }"," }"," avg.rgb = avg.a == 0.0 ? vec3(0.0) : linearTosRGB(avg.rgb / avg.a);"," }"," gl_FragColor = vec4(avg.rgb, 1.0);","}"].join("\n"),oe.draw=function(e){var t=e.getGL();t.useProgram(this.program),oe.attributes.aVertex.bindToBuffer(e.getVertexBuffer()),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,oe.INPUT_TEXTURE.getTexture()),t.uniform1i(this.uniforms.uTexture0,0),t.uniform2fv(this.uniforms.uInvSize,oe.INPUT_TEXTURE.getInverseSize()),t.drawArrays(t.TRIANGLES,0,3)},oe.initAttributes=function(e){oe.attributes.aVertex=new v(e,oe.program,"aVertex",2,e.FLOAT)};const le=oe;var ue=x.getCopy();ue.vertexName=ue.fragmentName="ComparisonImage",ue.uniforms={},ue.attributes={},ue.uniformNames=["uMVP","uTexture","uOpacity","uBorderColor","uIsBorder"],ue.vertex=["attribute vec3 aPosition;","attribute vec2 aTexCoord;","uniform mat4 uMVP;","varying vec2 vTexCoord;","void main() {"," gl_Position = uMVP * vec4(aPosition, 1.0);"," vTexCoord = aTexCoord;","}"].join("\n"),ue.fragment=["#ifdef GL_FRAGMENT_PRECISION_HIGH"," precision highp float;","#else"," precision mediump float;","#endif","uniform sampler2D uTexture;","uniform float uOpacity;","uniform vec3 uBorderColor;","uniform int uIsBorder;","varying vec2 vTexCoord;","void main() {"," if (uIsBorder == 1) {"," gl_FragColor = vec4(uBorderColor, 1.0);"," } else {"," vec4 color = texture2D(uTexture, vTexCoord);"," gl_FragColor = vec4(color.rgb, color.a * uOpacity);"," }","}"].join("\n"),ue.initAttributes=function(e){var t=ue.program;if(t){var r=ue.attributes;r.aPosition=new v(e,t,"aPosition",3,e.FLOAT),r.aTexCoord=new v(e,t,"aTexCoord",2,e.FLOAT)}else console.error("ShaderComparisonImage: program not initialized")},ue.initUniforms=function(e){x.initUniforms.call(this,e)},ue.bindAttributes=function(e){};const ce=ue;var he=[];he[s.Z.Shader.PBR]=L,he[s.Z.Shader.MATCAP]=B,he[s.Z.Shader.NORMAL]=Z,he[s.Z.Shader.UV]=W,he[s.Z.Shader.WIREFRAME]=z,he[s.Z.Shader.FLAT]=K,he[s.Z.Shader.SELECTION]=Y,he[s.Z.Shader.BACKGROUND]=Q,he[s.Z.Shader.MERGE]=ee,he[s.Z.Shader.FXAA]=re,he[s.Z.Shader.CONTOUR]=ne,he[s.Z.Shader.PAINTUV]=se,he[s.Z.Shader.BLUR]=le,he[s.Z.Shader.COMPARISON_IMAGE]=ce;const de=he;function fe(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var _e=l.Ue(),pe=l.Ue(),ge=[0,0,0],me=[0,0,0],ve=[0,0,1];const ye=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._gl=t,this._circleBuffer=new g(t,t.ARRAY_BUFFER,t.STATIC_DRAW),this._dotBuffer=new g(t,t.ARRAY_BUFFER,t.STATIC_DRAW),this._cacheDotMVP=l.Ue(),this._cacheDotSymMVP=l.Ue(),this._cacheCircleMVP=l.Ue(),this._color=new Float32Array([.8,0,0]),this._offsetX=0,this._isEditMode=!1,this.init()}var t,r;return t=e,(r=[{key:"getGL",value:function(){return this._gl}},{key:"getCircleBuffer",value:function(){return this._circleBuffer}},{key:"getDotBuffer",value:function(){return this._dotBuffer}},{key:"getCircleMVP",value:function(){return this._cacheCircleMVP}},{key:"getDotMVP",value:function(){return this._cacheDotMVP}},{key:"getDotSymmetryMVP",value:function(){return this._cacheDotSymMVP}},{key:"getColor",value:function(){return this._color}},{key:"setIsEditMode",value:function(e){this._isEditMode=e}},{key:"getIsEditMode",value:function(){return this._isEditMode}},{key:"setOffsetX",value:function(e){this._offsetX=e}},{key:"getOffsetX",value:function(){return this._offsetX}},{key:"init",value:function(){this.getCircleBuffer().update(this._getCircleVertices(1)),this.getDotBuffer().update(this._getDotVertices(.05,10))}},{key:"release",value:function(){this.getCircleBuffer().release(),this.getDotBuffer().release()}},{key:"_getCircleVertices",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:50,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=2*Math.PI,n=r?1:0,a=r?t+2:t,s=new Float32Array(3*a),o=n;o<a;++o){var l=3*o,u=i*o/t;s[l]=Math.cos(u)*e,s[l+1]=Math.sin(u)*e}return s}},{key:"_getDotVertices",value:function(e,t){return this._getCircleVertices(e,t,!0)}},{key:"_updateMatricesBackground",value:function(e,t){var r=t.getSculptManager().getCurrentTool().getScreenRadius(),n=.5*e._width,a=.5*e._height;l.M5(_e,-n,n,-a,a,-10,10),l.yR(pe),l.Iu(pe,pe,i.t8(ge,-n+t._mouseX+this._offsetX,a-t._mouseY,0)),l.bA(this._cacheCircleMVP,pe,i.t8(ge,r,r,r)),l.dC(this._cacheCircleMVP,_e,this._cacheCircleMVP),l.bA(this._cacheDotMVP,pe,i.t8(ge,50,50,50)),l.dC(this._cacheDotMVP,_e,this._cacheDotMVP),l.bA(this._cacheDotSymMVP,this._cacheDotSymMVP,[0,0,0])}},{key:"_updateMatricesMesh",value:function(e,t){var r=t.getPicking(),n=t.getPickingSymmetry(),a=Math.sqrt(r.computeWorldRadius2(!0)),s=t.getSculptManager().getCurrentTool().getScreenRadius(),o=r.getMesh(),u=a/s*50;r.polyLerp(o.getNormals(),me),i.kK(me,me,_(pe,o.getMatrix())),i.Fv(me,me);var c=Math.acos(i.AK(ve,me));i.kC(me,ve,me),l.yR(pe),l.Iu(pe,pe,i.fF(ge,r.getIntersectionPoint(),o.getMatrix())),l.U1(pe,pe,c,me),l.dC(_e,e.getProjection(),e.getView()),l.bA(this._cacheCircleMVP,pe,i.t8(ge,a,a,a)),l.dC(this._cacheCircleMVP,_e,this._cacheCircleMVP),l.bA(this._cacheDotMVP,pe,i.t8(ge,u,u,u)),l.dC(this._cacheDotMVP,_e,this._cacheDotMVP),i.fF(ge,n.getIntersectionPoint(),o.getMatrix()),l.yR(pe),l.Iu(pe,pe,ge),l.U1(pe,pe,c,me),l.bA(pe,pe,i.t8(ge,u,u,u)),l.dC(this._cacheDotSymMVP,_e,pe)}},{key:"render",value:function(e){var t=e.getPicking().getMesh()&&!this._isEditMode;t?this._updateMatricesMesh(e.getCamera(),e):this._updateMatricesBackground(e.getCamera(),e);var r=e._action===s.Z.Action.NOTHING;i.t8(this._color,.8,r&&t?0:.4,0),de[s.Z.Shader.SELECTION].getOrCreate(this._gl).draw(this,r,e.getSculptManager().getSymmetry()),this._isEditMode=!1}}])&&fe(t.prototype,r),e}();function be(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Te=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=t,this._cbContinuous=this.updateContinuous.bind(this),this._lastMouseX=0,this._lastMouseY=0}var t,r;return t=e,(r=[{key:"setToolMesh",value:function(e){this._forceToolMesh=e}},{key:"getMesh",value:function(){return this._forceToolMesh||this._main.getMesh()}},{key:"start",value:function(e){var t=this._main,r=t.getPicking();if(!r.intersectionMouseMeshes())return!1;var i=t.setOrUnsetMesh(r.getMesh(),e);if(!i)return!1;r.initAlpha();var n=t.getSculptManager().getSymmetry()?t.getPickingSymmetry():null;return n&&(n.intersectionMouseMesh(i),n.initAlpha()),this.pushState(),this._lastMouseX=t._mouseX,this._lastMouseY=t._mouseY,this.startSculpt(),!0}},{key:"end",value:function(){this.getMesh()&&this.getMesh().balanceOctree()}},{key:"pushState",value:function(){this._main.getStateManager().pushStateGeometry(this.getMesh())}},{key:"startSculpt",value:function(){!0!==this._lockPosition&&this.sculptStroke()}},{key:"preUpdate",value:function(e){var t=this._main,r=t.getPicking(),i=t._action===s.Z.Action.SCULPT_EDIT;if(!i||e){i?r.intersectionMouseMesh():r.intersectionMouseMeshes();var n=r.getMesh();n&&t.getSculptManager().getSymmetry()&&t.getPickingSymmetry().intersectionMouseMesh(n)}}},{key:"update",value:function(e){if(!0===this._lockPosition)return this.updateSculptLock(e);this.sculptStroke()}},{key:"updateSculptLock",value:function(e){var t=this._main;e||this._main.getStateManager().getCurrentState().undo();var r=t.getPicking(),i=this._radius,n=t.getSculptManager().getSymmetry()?t.getPickingSymmetry():null,a=t._mouseX-this._lastMouseX,s=t._mouseY-this._lastMouseY;this._radius=Math.sqrt(a*a+s*s);var o=a/this._radius,l=s/this._radius;this.makeStroke(this._lastMouseX+.001*o,this._lastMouseY+.001*l,r,n),this._radius=i,this.updateRender(),t.setCanvasCursor("default")}},{key:"sculptStroke",value:function(){var e=this._main,t=e.getPicking(),r=e.getSculptManager().getSymmetry()?e.getPickingSymmetry():null,i=e._mouseX-this._lastMouseX,n=e._mouseY-this._lastMouseY,a=Math.sqrt(i*i+n*n),s=.15*this._radius*e.getPixelRatio();if(!(a<=s)){var o=1/Math.floor(a/s);i*=o,n*=o;for(var l=this._lastMouseX+i,u=this._lastMouseY+n,c=o;c<=1&&this.makeStroke(l,u,t,r);c+=o)l+=i,u+=n;this.updateRender(),this._lastMouseX=e._mouseX,this._lastMouseY=e._mouseY}}},{key:"updateRender",value:function(){this.updateMeshBuffers(),this._main.render()}},{key:"makeStroke",value:function(e,t,r,i){var n=this.getMesh();r.intersectionMouseMesh(n,e,t);var a=r.getMesh();a&&(r.pickVerticesInSphere(r.getLocalRadius2()),r.computePickedNormal());var s,o=n.isDynamic&&!this._lockPosition;return o&&a&&this.stroke(r,!1),i&&(i.intersectionMouseMesh(n,e,t),(s=i.getMesh())&&(i.setLocalRadius2(r.getLocalRadius2()),i.pickVerticesInSphere(i.getLocalRadius2()),i.computePickedNormal())),!o&&a&&this.stroke(r,!1),s&&this.stroke(i,!0),a||s}},{key:"updateMeshBuffers",value:function(){var e=this.getMesh();e.isDynamic?e.updateBuffers():e.updateGeometryBuffers()}},{key:"updateContinuous",value:function(){if(this._lockPosition)return this.update(!0);var e=this._main,t=e.getPicking(),r=e.getSculptManager().getSymmetry()?e.getPickingSymmetry():null;this.makeStroke(e._mouseX,e._mouseY,t,r),this.updateRender()}},{key:"getFrontVertices",value:function(e,t){for(var r=e.length,i=new Uint32Array(o.Z.getMemory(4*r),0,r),n=0,a=this.getMesh().getNormals(),s=t[0],l=t[1],u=t[2],c=0;c<r;++c){var h=e[c],d=3*h;a[d]*s+a[d+1]*l+a[d+2]*u<=0&&(i[n++]=h)}return new Uint32Array(i.subarray(0,n))}},{key:"areaNormal",value:function(e){for(var t=this.getMesh(),r=t.getNormals(),i=t.getMaterials(),n=0,a=0,s=0,o=0,l=e.length;o<l;++o){var u=3*e[o],c=i[u+2];n+=r[u]*c,a+=r[u+1]*c,s+=r[u+2]*c}var h=Math.sqrt(n*n+a*a+s*s);if(0!==h)return[n*(h=1/h),a*h,s*h]}},{key:"areaCenter",value:function(e){for(var t=this.getMesh(),r=t.getVertices(),i=t.getMaterials(),n=e.length,a=0,s=0,o=0,l=0,u=0;u<n;++u){var c=3*e[u],h=i[c+2];l+=h,a+=r[c]*h,s+=r[c+1]*h,o+=r[c+2]*h}return[a/l,s/l,o/l]}},{key:"updateProxy",value:function(e){var t=this.getMesh(),r=t.getVertices(),i=t.getVerticesProxy();if(r!==i)for(var n=t.getVerticesStateFlags(),a=o.Z.STATE_FLAG,s=0,l=e.length;s<l;++s){var u=e[s];if(n[u]!==a){var c=3*u;i[c]=r[c],i[c+1]=r[c+1],i[c+2]=r[c+2]}}}},{key:"laplacianSmooth",value:function(e,t,r){for(var i=this.getMesh(),n=i.getVerticesRingVertStartCount(),a=i.getVerticesRingVert(),s=a instanceof Array?a:null,o=i.getVerticesOnEdge(),l=r||i.getVertices(),u=e.length,c=0;c<u;++c){var h,d,f=3*c,_=e[c];s?(h=0,d=(a=s[_]).length):d=(h=n[2*_])+n[2*_+1];var p=0,g=d-h;if(g<=2)p=3*_,t[f]=l[p],t[f+1]=l[p+1],t[f+2]=l[p+2];else{var m=0,v=0,y=0,b=0;if(1===o[_]){var T=0;for(b=h;b<d;++b)1===o[p=a[b]]&&(m+=l[p*=3],v+=l[p+1],y+=l[p+2],++T);if(T>=2){t[f]=m/T,t[f+1]=v/T,t[f+2]=y/T;continue}m=v=y=0}for(b=h;b<d;++b)m+=l[p=3*a[b]],v+=l[p+1],y+=l[p+2];t[f]=m/g,t[f+1]=v/g,t[f+2]=y/g}}}},{key:"dynamicTopology",value:function(e){var t=this.getMesh(),r=e.getPickedVertices();if(!t.isDynamic)return r;var i=t.getSubdivisionFactor(),n=t.getDecimationFactor();if(0===i&&0===n)return r;0===r.length&&(r=t.getVerticesFromFaces([e.getPickedFace()]),this._main.getStateManager().pushVertices(r));var a=t.getFacesFromVertices(r),s=e.getLocalRadius2(),l=e.getIntersectionPoint(),u=s*(1.1-i)*.2,c=u/4.2025*n;this._main.getStateManager().pushFaces(a),i&&(a=t.subdivide(a,l,s,u,this._main.getStateManager())),n&&(a=t.decimate(a,l,s,c,this._main.getStateManager()));for(var h=(r=t.getVerticesFromFaces(a)).length,d=o.Z.SCULPT_FLAG,f=t.getVerticesSculptFlags(),_=new Uint32Array(o.Z.getMemory(4*h),0,h),p=0,g=0;g<h;++g){var m=r[g];f[m]===d&&(_[p++]=m)}return _=new Uint32Array(_.subarray(0,p)),t.updateTopology(a,r),t.updateGeometry(a,r),_}},{key:"getUnmaskedVertices",value:function(){return this.filterMaskedVertices(0,1/0)}},{key:"getMaskedVertices",value:function(){return this.filterMaskedVertices(-1/0,1)}},{key:"filterMaskedVertices",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1/0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,r=this.getMesh(),i=r.getMaterials(),n=r.getNbVertices(),a=new Uint32Array(o.Z.getMemory(4*n),0,n),s=0,l=0;l<n;++l){var u=i[3*l+2];u>e&&u<t&&(a[s++]=l)}return new Uint32Array(a.subarray(0,s))}},{key:"postRender",value:function(e){e.render(this._main)}},{key:"addSculptToScene",value:function(){}},{key:"getScreenRadius",value:function(){return(this._radius||1)*this._main.getPixelRatio()}}])&&be(t.prototype,r),e}();function Me(e){return(Me="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 Se(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function ke(e,t){return(ke=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ee(e,t){return!t||"object"!==Me(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Ae(e){return(Ae=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const Ce=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ke(e,t)}(o,e);var t,r,i,n,s=(i=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Ae(i);if(n){var r=Ae(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return Ee(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e))._radius=50,t._intensity=.75,t._negative=!0,t._culling=!1,t._idAlpha=0,t._lockPosition=!1,t}return t=o,(r=[{key:"stroke",value:function(e){var t=e.getPickedVertices(),r=this._intensity*a.Z.getPressureIntensity();this._main.getStateManager().pushVertices(t),t=this.dynamicTopology(e);var i=this.getFrontVertices(t,e.getEyeDirection());this._culling&&(t=i);var n=this.areaNormal(i);if(n){var s=this.areaCenter(i);e.updateAlpha(this._lockPosition),e.setIdAlpha(this._idAlpha),this.flatten(t,n,s,e.getIntersectionPoint(),e.getLocalRadius2(),r,e);var o=this.getMesh();o.updateGeometry(o.getFacesFromVertices(t),t)}}},{key:"flatten",value:function(e,t,r,i,n,a,s){for(var o=this.getMesh(),l=o.getVertices(),u=o.getMaterials(),c=Math.sqrt(n),h=!1===this._accumulate&&!1===this._lockPosition?o.getVerticesProxy():l,d=i[0],f=i[1],_=i[2],p=r[0],g=r[1],m=r[2],v=t[0],y=t[1],b=t[2],T=this._negative?-1:1,M=0,S=e.length;M<S;++M){var k=3*e[M],E=l[k],A=l[k+1],C=l[k+2],w=(E-p)*v+(A-g)*y+(C-m)*b;if(!(w*T>0)){var R=h[k]-d,x=h[k+1]-f,P=h[k+2]-_,D=Math.sqrt(R*R+x*x+P*P)/c;if(!(D>=1)){var I=D*D;I=3*I*I-4*I*D+1,I*=w*a*u[k+2]*s.getAlpha(E,A,C),l[k]-=v*I,l[k+1]-=y*I,l[k+2]-=b*I}}}}}])&&Se(t.prototype,r),o}(Te);function we(e){return(we="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 Re(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function xe(e,t){return(xe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Pe(e,t){return!t||"object"!==we(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function De(e){return(De=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const Ie=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&xe(e,t)}(l,e);var t,r,n,s,o=(n=l,s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=De(n);if(s){var r=De(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return Pe(this,e)});function l(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(t=o.call(this,e))._radius=50,t._intensity=.5,t._negative=!1,t._clay=!0,t._culling=!1,t._accumulate=!0,t._idAlpha=0,t._lockPosition=!1,t}return t=l,(r=[{key:"stroke",value:function(e){var t=e.getPickedVertices(),r=this._intensity*a.Z.getPressureIntensity();this._accumulate||this._lockPosition||this.updateProxy(t),this._main.getStateManager().pushVertices(t),this._lockPosition||(t=this.dynamicTopology(e));var n=this.getFrontVertices(t,e.getEyeDirection());this._culling&&(t=n);var s=e.getLocalRadius2();if(e.updateAlpha(this._lockPosition),e.setIdAlpha(this._idAlpha),this._clay){var o=this.areaNormal(n);if(!o)return;var l=this._lockPosition?e.getIntersectionPoint():this.areaCenter(n),u=.1*Math.sqrt(s);i.od(l,l,o,this._negative?-u:u),Ce.prototype.flatten.call(this,t,o,l,e.getIntersectionPoint(),s,r,e)}else this.brush(t,e.getPickedNormal(),e.getIntersectionPoint(),s,r,e);var c=this.getMesh();c.updateGeometry(c.getFacesFromVertices(t),t)}},{key:"brush",value:function(e,t,r,i,n,a){var s=this.getMesh(),o=s.getVertices(),l=s.getMaterials(),u=this._accumulate||this._lockPosition?o:s.getVerticesProxy(),c=Math.sqrt(i),h=n*c*.1;this._negative&&(h=-h);for(var d=r[0],f=r[1],_=r[2],p=t[0],g=t[1],m=t[2],v=0,y=e.length;v<y;++v){var b=3*e[v],T=u[b]-d,M=u[b+1]-f,S=u[b+2]-_,k=Math.sqrt(T*T+M*M+S*S)/c;if(!(k>=1)){var E=o[b],A=o[b+1],C=o[b+2],w=k*k;w=3*w*w-4*w*k+1,w*=l[b+2]*h*a.getAlpha(E,A,C),o[b]=E+p*w,o[b+1]=A+g*w,o[b+2]=C+m*w}}}}])&&Re(t.prototype,r),l}(Te);function Fe(e){return(Fe="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 Oe(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Le(e,t){return(Le=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ve(e,t){return!t||"object"!==Fe(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Ne(e){return(Ne=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const Be=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Le(e,t)}(o,e);var t,r,i,n,s=(i=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Ne(i);if(n){var r=Ne(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return Ve(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e))._radius=50,t._intensity=.3,t._negative=!1,t._culling=!1,t._idAlpha=0,t._lockPosition=!1,t}return t=o,(r=[{key:"stroke",value:function(e){var t=e.getPickedVertices(),r=this._intensity*a.Z.getPressureIntensity();this.updateProxy(t),this._main.getStateManager().pushVertices(t),t=this.dynamicTopology(e),this._culling&&(t=this.getFrontVertices(t,e.getEyeDirection())),e.updateAlpha(this._lockPosition),e.setIdAlpha(this._idAlpha),this.inflate(t,e.getIntersectionPoint(),e.getLocalRadius2(),r,e);var i=this.getMesh();i.updateGeometry(i.getFacesFromVertices(t),t)}},{key:"inflate",value:function(e,t,r,i,n){var a=this.getMesh(),s=a.getVertices(),o=a.getMaterials(),l=a.getVerticesProxy(),u=a.getNormals(),c=Math.sqrt(r),h=i*c*.1;this._negative&&(h=-h);for(var d=t[0],f=t[1],_=t[2],p=0,g=e.length;p<g;++p){var m=3*e[p],v=l[m]-d,y=l[m+1]-f,b=l[m+2]-_,T=Math.sqrt(v*v+y*y+b*b)/c;if(!(T>=1)){var M=T*T;M=3*M*M-4*M*T+1,M*=h;var S=s[m],k=s[m+1],E=s[m+2],A=u[m],C=u[m+1],w=u[m+2];M/=Math.sqrt(A*A+C*C+w*w),M*=o[m+2]*n.getAlpha(S,k,E),s[m]=S+A*M,s[m+1]=k+C*M,s[m+2]=E+w*M}}}}])&&Oe(t.prototype,r),o}(Te);function Ue(e,t,r){return e[0]=t,e[1]=r,e}function Ze(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e}function Ge(e,t){var r=t[0],i=t[1],n=r*r+i*i;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e}function We(e,t){return e[0]*t[0]+e[1]*t[1]}var je,ze=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e},Xe=function(e,t){var r=t[0]-e[0],i=t[1]-e[1];return Math.hypot(r,i)};function Ke(){var e=new c.WT(4);return c.WT!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function He(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Ye(e,t,r){r*=.5;var i=Math.sin(r);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(r),e}function qe(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=i*l+s*o,e[1]=n*l+a*o,e[2]=a*l-n*o,e[3]=s*l-i*o,e}function Je(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=i*l-a*o,e[1]=n*l+s*o,e[2]=a*l+i*o,e[3]=s*l-n*o,e}je=new c.WT(2),c.WT!=Float32Array&&(je[0]=0,je[1]=0),function(){var e=new c.WT(4);c.WT!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0)}();var Qe=function(e,t,r,i){var n=new c.WT(4);return n[0]=e,n[1]=t,n[2]=r,n[3]=i,n},$e=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=r[0],l=r[1],u=r[2],c=r[3];return e[0]=i*c+s*o+n*u-a*l,e[1]=n*c+s*l+a*o-i*u,e[2]=a*c+s*u+i*l-n*o,e[3]=s*c-i*o-n*l-a*u,e},et=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=r*r+i*i+n*n+a*a;return s>0&&(s=1/Math.sqrt(s)),e[0]=r*s,e[1]=i*s,e[2]=n*s,e[3]=a*s,e},tt=(i.Ue(),i.al(1,0,0),i.al(0,1,0),Ke(),Ke(),h(),r(165));function rt(e){return(rt="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 it(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function nt(e,t){return(nt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function at(e,t){return!t||"object"!==rt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function st(e){return(st=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const ot=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&nt(e,t)}(o,e);var t,r,n,a,s=(n=o,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=st(n);if(a){var r=st(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return at(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e))._radius=75,t._culling=!1,t._twistData={normal:[0,0,0],center:[0,0]},t._twistDataSym={normal:[0,0,0],center:[0,0]},t._idAlpha=0,t}return t=o,(r=[{key:"startSculpt",value:function(){var e=this._main,t=e._mouseX,r=e._mouseY,i=e.getPicking();if(this.initTwistData(i,t,r,this._twistData),e.getSculptManager().getSymmetry()){var n=e.getPickingSymmetry();n.intersectionMouseMesh(),n.setLocalRadius2(i.getLocalRadius2()),n.getMesh()&&this.initTwistData(n,t,r,this._twistDataSym)}}},{key:"initTwistData",value:function(e,t,r,n){e.pickVerticesInSphere(e.getLocalRadius2()),i.tk(n.normal,e.getEyeDirection()),Ue(n.center,t,r)}},{key:"sculptStroke",value:function(){var e=this._main,t=e._mouseX,r=e._mouseY,i=e._lastMouseX,n=e._lastMouseY,a=e.getPicking(),s=a.getLocalRadius2();if(a.pickVerticesInSphere(s),this.stroke(a,t,r,i,n,this._twistData),e.getSculptManager().getSymmetry()){var o=e.getPickingSymmetry();o.getMesh()&&(o.pickVerticesInSphere(s),this.stroke(o,i,n,t,r,this._twistDataSym))}this.updateRender(),e.setCanvasCursor("default")}},{key:"stroke",value:function(e,t,r,i,n,a){var s=e.getPickedVertices();this._main.getStateManager().pushVertices(s),s=this.dynamicTopology(e),this._culling&&(s=this.getFrontVertices(s,e.getEyeDirection())),e.updateAlpha(!1),e.setIdAlpha(this._idAlpha),this.twist(s,e.getIntersectionPoint(),e.getLocalRadius2(),t,r,i,n,a,e);var o=this.getMesh();o.updateGeometry(o.getFacesFromVertices(s),s)}},{key:"twist",value:function(e,t,r,n,a,s,o,l,u){var c,h,d,f=this.getMesh(),_=l.center,p=[n-_[0],a-_[1]];if(h=(c=p)[0],d=c[1],!(Math.hypot(h,d)<30)){Ge(p,p);var g=l.normal,m=[0,0,0,0],v=[s-_[0],o-_[1]];Ge(v,v);for(var y=tt.Z.signedAngle2d(p,v),b=f.getVertices(),T=f.getMaterials(),M=1/Math.sqrt(r),S=t[0],k=t[1],E=t[2],A=[0,0,0],C=0,w=e.length;C<w;++C){var R=3*e[C],x=b[R],P=b[R+1],D=b[R+2],I=x-S,F=P-k,O=D-E,L=Math.sqrt(I*I+F*F+O*O)*M,V=L*L;V=3*V*V-4*V*L+1,Ye(m,g,V*=y*T[R+2]*u.getAlpha(x,P,D)),i.t8(A,x,P,D),i.lu(A,A,t),i.VC(A,A,m),i.IH(A,A,t),b[R]=A[0],b[R+1]=A[1],b[R+2]=A[2]}}}}])&&it(t.prototype,r),o}(Te);function lt(e){return(lt="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 ut(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function ct(e,t){return(ct=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ht(e,t){return!t||"object"!==lt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function dt(e){return(dt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const ft=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ct(e,t)}(l,e);var t,r,i,n,s=(i=l,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=dt(i);if(n){var r=dt(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return ht(this,e)});function l(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(t=s.call(this,e))._radius=50,t._intensity=.75,t._culling=!1,t._tangent=!1,t._idAlpha=0,t._lockPosition=!1,t}return t=l,(r=[{key:"stroke",value:function(e){var t=e.getPickedVertices(),r=this._intensity*a.Z.getPressureIntensity();this._main.getStateManager().pushVertices(t),this._culling&&(t=this.getFrontVertices(t,e.getEyeDirection())),e.updateAlpha(this._lockPosition),e.setIdAlpha(this._idAlpha),this._tangent?this.smoothTangent(t,r,e):this.smooth(t,r,e);var i=this.getMesh();i.updateGeometry(i.getFacesFromVertices(t),t)}},{key:"smooth",value:function(e,t,r){var i=this.getMesh(),n=i.getVertices(),a=i.getMaterials(),s=e.length,l=new Float32Array(o.Z.getMemory(4*s*3),0,3*s);this.laplacianSmooth(e,l);for(var u=0;u<s;++u){var c=3*e[u],h=n[c],d=n[c+1],f=n[c+2],_=3*u,p=t*a[c+2];r&&(p*=r.getAlpha(h,d,f));var g=1-p;n[c]=h*g+l[_]*p,n[c+1]=d*g+l[_+1]*p,n[c+2]=f*g+l[_+2]*p}}},{key:"smoothTangent",value:function(e,t,r){var i=this.getMesh(),n=i.getVertices(),a=i.getMaterials(),s=i.getNormals(),l=e.length,u=new Float32Array(o.Z.getMemory(4*l*3),0,3*l);this.laplacianSmooth(e,u);for(var c=0;c<l;++c){var h=3*e[c],d=n[h],f=n[h+1],_=n[h+2],p=s[h],g=s[h+1],m=s[h+2],v=p*p+g*g+m*m;if(0!==v){p*=v=1/Math.sqrt(v),g*=v,m*=v;var y=3*c,b=u[y],T=u[y+1],M=u[y+2],S=p*(b-d)+g*(T-f)+m*(M-_),k=t*a[h+2];r&&(k*=r.getAlpha(d,f,_)),n[h]=d+(b-p*S-d)*k,n[h+1]=f+(T-g*S-f)*k,n[h+2]=_+(M-m*S-_)*k}}}},{key:"smoothAlongNormals",value:function(e,t,r){var i=this.getMesh(),n=i.getVertices(),a=i.getMaterials(),s=i.getNormals(),l=e.length,u=new Float32Array(o.Z.getMemory(4*l*3),0,3*l);this.laplacianSmooth(e,u);for(var c=0;c<l;++c){var h=3*e[c],d=n[h],f=n[h+1],_=n[h+2],p=s[h],g=s[h+1],m=s[h+2],v=3*c,y=1/(p*p+g*g+m*m),b=p*(u[v]-d)+g*(u[v+1]-f)+m*(u[v+2]-_);b*=y*t*a[h+2],r&&(b*=r.getAlpha(d,f,_)),n[h]=d+p*b,n[h+1]=f+g*b,n[h+2]=_+m*b}}}])&&ut(t.prototype,r),l}(Te);function _t(e){return(_t="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 pt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function gt(e,t){return(gt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function mt(e,t){return!t||"object"!==_t(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function vt(e){return(vt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const yt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&gt(e,t)}(o,e);var t,r,i,n,s=(i=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=vt(i);if(n){var r=vt(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return mt(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e))._radius=50,t._intensity=.75,t._negative=!1,t._culling=!1,t._idAlpha=0,t._lockPosition=!1,t}return t=o,(r=[{key:"stroke",value:function(e){var t=e.getPickedVertices(),r=this._intensity*a.Z.getPressureIntensity();this._main.getStateManager().pushVertices(t),t=this.dynamicTopology(e),this._culling&&(t=this.getFrontVertices(t,e.getEyeDirection())),e.updateAlpha(this._lockPosition),e.setIdAlpha(this._idAlpha),this.pinch(t,e.getIntersectionPoint(),e.getLocalRadius2(),r,e);var i=this.getMesh();i.updateGeometry(i.getFacesFromVertices(t),t)}},{key:"pinch",value:function(e,t,r,i,n){var a=this.getMesh(),s=a.getVertices(),o=a.getMaterials(),l=Math.sqrt(r),u=t[0],c=t[1],h=t[2],d=.05*i;this._negative&&(d=-d);for(var f=0,_=e.length;f<_;++f){var p=3*e[f],g=s[p],m=s[p+1],v=s[p+2],y=u-g,b=c-m,T=h-v,M=Math.sqrt(y*y+b*b+T*T)/l,S=M*M;S=3*S*S-4*S*M+1,S*=d*o[p+2]*n.getAlpha(g,m,v),s[p]=g+y*S,s[p+1]=m+b*S,s[p+2]=v+T*S}}}])&&pt(t.prototype,r),o}(Te);function bt(e){return(bt="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 Tt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Mt(e,t){return(Mt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function St(e,t){return!t||"object"!==bt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function kt(e){return(kt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const Et=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Mt(e,t)}(o,e);var t,r,i,n,s=(i=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=kt(i);if(n){var r=kt(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return St(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e))._radius=25,t._intensity=.75,t._negative=!0,t._culling=!1,t._idAlpha=0,t._lockPosition=!1,t}return t=o,(r=[{key:"stroke",value:function(e){var t=e.getPickedVertices(),r=this._intensity*a.Z.getPressureIntensity();this.updateProxy(t),this._main.getStateManager().pushVertices(t),t=this.dynamicTopology(e),this._culling&&(t=this.getFrontVertices(t,e.getEyeDirection())),e.updateAlpha(this._lockPosition),e.setIdAlpha(this._idAlpha),this.crease(t,e.getPickedNormal(),e.getIntersectionPoint(),e.getLocalRadius2(),r,e);var i=this.getMesh();i.updateGeometry(i.getFacesFromVertices(t),t)}},{key:"crease",value:function(e,t,r,i,n,a){var s=this.getMesh(),o=s.getVertices(),l=s.getMaterials(),u=s.getVerticesProxy(),c=Math.sqrt(i),h=r[0],d=r[1],f=r[2],_=t[0],p=t[1],g=t[2],m=.07*n,v=m*c;this._negative&&(v=-v);for(var y=0,b=e.length;y<b;++y){var T=3*e[y],M=h-u[T],S=d-u[T+1],k=f-u[T+2],E=Math.sqrt(M*M+S*S+k*k)/c;if(!(E>=1)){var A=o[T],C=o[T+1],w=o[T+2],R=E*E;R=3*R*R-4*R*E+1,R*=l[T+2]*a.getAlpha(A,C,w);var x=Math.pow(R,5)*v;R*=m,o[T]=A+M*R+_*x,o[T+1]=C+S*R+p*x,o[T+2]=w+k*R+g*x}}}}])&&Tt(t.prototype,r),o}(Te);function At(e){return(At="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 Ct(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function wt(e,t){return(wt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Rt(e,t){return!t||"object"!==At(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function xt(e){return(xt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const Pt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&wt(e,t)}(o,e);var t,r,n,a,s=(n=o,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=xt(n);if(a){var r=xt(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return Rt(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e))._radius=150,t._dragDir=[0,0,0],t._dragDirSym=[0,0,0],t._idAlpha=0,t}return t=o,(r=[{key:"sculptStroke",value:function(){var e=this._main,t=this.getMesh(),r=e.getPicking(),n=e.getSculptManager().getSymmetry()?e.getPickingSymmetry():null,a=e._mouseX-this._lastMouseX,s=e._mouseY-this._lastMouseY,o=Math.sqrt(a*a+s*s),l=.15*this._radius,u=1/Math.floor(o/l);a*=u,s*=u;var c=this._lastMouseX,h=this._lastMouseY;if(r.getMesh()){r._mesh=t,n&&(n._mesh=t,i.JG(n.getIntersectionPoint(),r.getIntersectionPoint()),tt.Z.mirrorPoint(n.getIntersectionPoint(),t.getSymmetryOrigin(),t.getSymmetryNormal()));for(var d=0;d<1&&this.makeStroke(c,h,r,n);d+=u)c+=a,h+=s;this.updateRender(),this._lastMouseX=e._mouseX,this._lastMouseY=e._mouseY}}},{key:"makeStroke",value:function(e,t,r,i){var n=this.getMesh();return this.updateDragDir(r,e,t),r.pickVerticesInSphere(r.getLocalRadius2()),r.computePickedNormal(),n.isDynamic&&this.stroke(r,!1),i&&(this.updateDragDir(i,e,t,!0),i.setLocalRadius2(r.getLocalRadius2()),i.pickVerticesInSphere(i.getLocalRadius2())),n.isDynamic||this.stroke(r,!1),i&&this.stroke(i,!0),!0}},{key:"stroke",value:function(e,t){var r=e.getPickedVertices();this._main.getStateManager().pushVertices(r),r=this.dynamicTopology(e),e.updateAlpha(this._lockPosition),e.setIdAlpha(this._idAlpha),this.drag(r,e.getIntersectionPoint(),e.getLocalRadius2(),t,e);var i=this.getMesh();i.updateGeometry(i.getFacesFromVertices(r),r)}},{key:"drag",value:function(e,t,r,i,n){for(var a=this.getMesh(),s=a.getVertices(),o=a.getMaterials(),l=Math.sqrt(r),u=t[0],c=t[1],h=t[2],d=i?this._dragDirSym:this._dragDir,f=d[0],_=d[1],p=d[2],g=0,m=e.length;g<m;++g){var v=3*e[g],y=s[v],b=s[v+1],T=s[v+2],M=y-u,S=b-c,k=T-h,E=Math.sqrt(M*M+S*S+k*k)/l,A=E*E;A=3*A*A-4*A*E+1,A*=o[v+2]*n.getAlpha(y,b,T),s[v]=y+f*A,s[v+1]=b+_*A,s[v+2]=T+p*A}}},{key:"updateDragDir",value:function(e,t,r,n){var a=this.getMesh(),s=e.unproject(t,r,0),o=e.unproject(t,r,.1),u=l.Ue();l.U_(u,a.getMatrix()),i.fF(s,s,u),i.fF(o,o,u);var c=this._dragDir;if(n){c=this._dragDirSym;var h=a.getSymmetryOrigin(),d=a.getSymmetryNormal();tt.Z.mirrorPoint(s,h,d),tt.Z.mirrorPoint(o,h,d)}var f=e.getIntersectionPoint();e.setIntersectionPoint(tt.Z.vertexOnLine(f,s,o)),i.lu(c,e.getIntersectionPoint(),f),e._mesh=a,e.updateLocalAndWorldRadius2();var _=e.getEyeDirection();i.lu(_,o,s),i.Fv(_,_)}}])&&Ct(t.prototype,r),o}(Te);function Dt(e){return(Dt="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 It(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Ft(e,t,r){return(Ft="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Vt(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(r):n.value}})(e,t,r||e)}function Ot(e,t){return(Ot=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Lt(e,t){return!t||"object"!==Dt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Vt(e){return(Vt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const Nt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ot(e,t)}(l,e);var t,r,n,s,o=(n=l,s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Vt(n);if(s){var r=Vt(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return Lt(this,e)});function l(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(t=o.call(this,e))._radius=50,t._hardness=.75,t._intensity=.75,t._culling=!1,t._color=i.al(1,.766,.336),t._material=i.al(.3,.95,0),t._pickColor=!1,t._pickCallback=null,t._idAlpha=0,t._lockPosition=!1,t._writeAlbedo=!0,t._writeRoughness=!0,t._writeMetalness=!0,t}return t=l,(r=[{key:"end",value:function(){this._pickColor=!1,Ft(Vt(l.prototype),"end",this).call(this)}},{key:"pushState",value:function(e){this._pickColor&&!e||this._main.getStateManager().pushStateColorAndMaterial(this.getMesh())}},{key:"startSculpt",value:function(){if(this._pickColor)return this.pickColor(this._main.getPicking());Ft(Vt(l.prototype),"startSculpt",this).call(this)}},{key:"update",value:function(e){if(!0===this._pickColor)return this.updatePickColor();Ft(Vt(l.prototype),"update",this).call(this,e)}},{key:"updateContinuous",value:function(){if(!0===this._pickColor)return this.updatePickColor();Ft(Vt(l.prototype),"updateContinuous",this).call(this)}},{key:"updateMeshBuffers",value:function(){var e=this.getMesh();e.isDynamic?e.updateBuffers():(e.updateColorBuffer(),e.updateMaterialBuffer())}},{key:"updatePickColor",value:function(){var e=this._main.getPicking();e.intersectionMouseMesh()&&this.pickColor(e)}},{key:"setPickCallback",value:function(e){this._pickCallback=e}},{key:"pickColor",value:function(e){var t=this.getMesh(),r=this._color;e.polyLerp(t.getMaterials(),r);var i=r[0],n=r[1];e.polyLerp(t.getColors(),r),this._pickCallback(r,i,n)}},{key:"stroke",value:function(e){var t=e.getPickedVertices(),r=this._intensity*a.Z.getPressureIntensity();this._main.getStateManager().pushVertices(t),t=this.dynamicTopology(e),this._culling&&(t=this.getFrontVertices(t,e.getEyeDirection())),e.updateAlpha(this._lockPosition),e.setIdAlpha(this._idAlpha),this.paint(t,e.getIntersectionPoint(),e.getLocalRadius2(),r,this._hardness,e);var i=this.getMesh();i.updateDuplicateColorsAndMaterials(t),i.isUsingDrawArrays()&&i.updateDrawArrays(i.getFacesFromVertices(t))}},{key:"paint",value:function(e,t,r,i,n,a){for(var s=this.getMesh(),o=s.getVertices(),l=s.getColors(),u=s.getMaterials(),c=this._color,h=this._material[0],d=this._material[1],f=Math.sqrt(r),_=c[0],p=c[1],g=c[2],m=t[0],v=t[1],y=t[2],b=2*(1-n),T=0,M=e.length;T<M;++T){var S=3*e[T],k=o[S],E=o[S+1],A=o[S+2],C=k-m,w=E-v,R=A-y,x=Math.sqrt(C*C+w*w+R*R)/f;x>1&&(x=1);var P=Math.pow(1-x,b),D=1-(P*=i*u[S+2]*a.getAlpha(k,E,A));this._writeAlbedo&&(l[S]=l[S]*D+_*P,l[S+1]=l[S+1]*D+p*P,l[S+2]=l[S+2]*D+g*P),this._writeRoughness&&(u[S]=u[S]*D+h*P),this._writeMetalness&&(u[S+1]=u[S+1]*D+d*P)}}},{key:"paintAll",value:function(){var e=this.getMesh(),t=this.getUnmaskedVertices();if(0!==t.length){this.pushState(!0),this._main.getStateManager().pushVertices(t);for(var r=e.getColors(),i=e.getMaterials(),n=this._color,a=this._material[0],s=this._material[1],o=n[0],l=n[1],u=n[2],c=0,h=t.length;c<h;++c){var d=3*t[c],f=i[d+2],_=1-f;this._writeAlbedo&&(r[d]=r[d]*_+o*f,r[d+1]=r[d+1]*_+l*f,r[d+2]=r[d+2]*_+u*f),this._writeRoughness&&(i[d]=i[d]*_+a*f),this._writeMetalness&&(i[d+1]=i[d+1]*_+s*f)}e.updateDuplicateColorsAndMaterials(),e.updateDrawArrays(),this.updateRender()}}}])&&It(t.prototype,r),l}(Te);function Bt(e){return(Bt="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 Ut(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Zt(e,t){return(Zt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Gt(e,t){return!t||"object"!==Bt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Wt(e){return(Wt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const jt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Zt(e,t)}(o,e);var t,r,n,a,s=(n=o,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Wt(n);if(a){var r=Wt(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return Gt(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e))._radius=150,t._intensity=1,t._topoCheck=!0,t._negative=!1,t._moveData={center:[0,0,0],dir:[0,0],vProxy:null},t._moveDataSym={center:[0,0,0],dir:[0,0],vProxy:null},t._idAlpha=0,t}return t=o,(r=[{key:"startSculpt",value:function(){var e=this._main,t=e.getPicking();if(this.initMoveData(t,this._moveData),e.getSculptManager().getSymmetry()){var r=e.getPickingSymmetry();r.intersectionMouseMesh(),r.setLocalRadius2(t.getLocalRadius2()),r.getMesh()&&this.initMoveData(r,this._moveDataSym)}}},{key:"initMoveData",value:function(e,t){this._topoCheck?e.pickVerticesInSphereTopological(e.getLocalRadius2()):e.pickVerticesInSphere(e.getLocalRadius2()),i.JG(t.center,e.getIntersectionPoint());var r=e.getPickedVertices();this._main.getStateManager().pushVertices(r);for(var n=e.getMesh().getVertices(),a=r.length,s=t.vProxy=new Float32Array(3*a),o=0;o<a;++o){var l=3*r[o],u=3*o;s[u]=n[l],s[u+1]=n[l+1],s[u+2]=n[l+2]}}},{key:"copyVerticesProxy",value:function(e,t){for(var r=e.getPickedVertices(),i=this.getMesh().getVertices(),n=t.vProxy,a=0,s=r.length;a<s;++a){var o=3*r[a],l=3*a;i[o]=n[l],i[o+1]=n[l+1],i[o+2]=n[l+2]}}},{key:"sculptStroke",value:function(){var e=this._main,t=e.getPicking(),r=e.getPickingSymmetry(),i=e.getSculptManager().getSymmetry()&&r.getMesh();t.updateAlpha(this._lockPosition),t.setIdAlpha(this._idAlpha),i&&(r.updateAlpha(!1),r.setIdAlpha(this._idAlpha)),this.copyVerticesProxy(t,this._moveData),i&&this.copyVerticesProxy(r,this._moveDataSym);var n=e._mouseX,a=e._mouseY;this.updateMoveDir(t,n,a),this.move(t.getPickedVertices(),t.getIntersectionPoint(),t.getLocalRadius2(),this._moveData,t),i&&(this.updateMoveDir(r,n,a,!0),this.move(r.getPickedVertices(),r.getIntersectionPoint(),r.getLocalRadius2(),this._moveDataSym,r));var s=this.getMesh();s.updateGeometry(s.getFacesFromVertices(t.getPickedVertices()),t.getPickedVertices()),i&&s.updateGeometry(s.getFacesFromVertices(r.getPickedVertices()),r.getPickedVertices()),this.updateRender(),e.setCanvasCursor("default")}},{key:"move",value:function(e,t,r,i,n){for(var a=this.getMesh(),s=a.getVertices(),o=a.getMaterials(),l=Math.sqrt(r),u=i.vProxy,c=t[0],h=t[1],d=t[2],f=i.dir,_=f[0],p=f[1],g=f[2],m=0,v=e.length;m<v;++m){var y=3*e[m],b=3*m,T=u[b],M=u[b+1],S=u[b+2],k=T-c,E=M-h,A=S-d,C=Math.sqrt(k*k+E*E+A*A)/l,w=C*C;w=3*w*w-4*w*C+1,w*=o[y+2]*n.getAlpha(T,M,S),s[y]+=_*w,s[y+1]+=p*w,s[y+2]+=g*w}}},{key:"updateMoveDir",value:function(e,t,r,n){var a=this.getMesh(),s=e.unproject(t,r,0),o=e.unproject(t,r,.1),u=l.Ue();l.U_(u,a.getMatrix()),i.fF(s,s,u),i.fF(o,o,u);var c=n?this._moveDataSym:this._moveData;if(n){var h=a.getSymmetryOrigin(),d=a.getSymmetryNormal();tt.Z.mirrorPoint(s,h,d),tt.Z.mirrorPoint(o,h,d)}if(this._negative){var f=i.TK(tt.Z.vertexOnLine(c.center,s,o),c.center);i.Fv(c.dir,e.computePickedNormal()),i.bA(c.dir,c.dir,t<this._lastMouseX?-f:f)}else i.lu(c.dir,tt.Z.vertexOnLine(c.center,s,o),c.center);i.bA(c.dir,c.dir,this._intensity);var _=e.getEyeDirection();i.lu(_,o,s),i.Fv(_,_)}}])&&Ut(t.prototype,r),o}(Te);function zt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Xt=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._parent=t||null,this._depth=t?t._depth+1:0,this._children=[],this._aabbLoose=[1/0,1/0,1/0,-1/0,-1/0,-1/0],this._aabbSplit=[1/0,1/0,1/0,-1/0,-1/0,-1/0],this._iFaces=[],this._flag=0}var t,r;return t=e,(r=[{key:"resetNbFaces",value:function(e){var t=this._iFaces;t.length=e;for(var r=0;r<e;++r)t[r]=r}},{key:"build",value:function(t){var r=0,i=e.STACK;i[0]=this;for(var n=1,a=[];n>0;){var s=i[--n],o=s._iFaces.length;if(o>e.MAX_FACES&&s._depth<e.MAX_DEPTH){s.constructChildren(t);var l=s._children;for(r=0;r<8;++r)i[n+r]=l[r];n+=8}else o>0&&a.push(s)}var u=a.length;for(r=0;r<u;++r)a[r].constructLeaf(t)}},{key:"constructLeaf",value:function(e){for(var t=this._iFaces,r=t.length,i=1/0,n=1/0,a=1/0,s=-1/0,o=-1/0,l=-1/0,u=e.getFaceBoxes(),c=e.getFacePosInLeaf(),h=e.getFaceLeaf(),d=0;d<r;++d){var f=t[d];h[f]=this,c[f]=d;var _=u[f*=6],p=u[f+1],g=u[f+2],m=u[f+3],v=u[f+4],y=u[f+5];_<i&&(i=_),m>s&&(s=m),p<n&&(n=p),v>o&&(o=v),g<a&&(a=g),y>l&&(l=y)}this.expandsAabbLoose(i,n,a,s,o,l)}},{key:"constructChildren",value:function(t){for(var r=this._aabbSplit,i=r[0],n=r[1],a=r[2],s=r[3],o=r[4],l=r[5],u=.5*(s-i),c=.5*(o-n),h=.5*(l-a),d=.5*(s+i),f=.5*(o+n),_=.5*(l+a),p=new e(this),g=new e(this),m=new e(this),v=new e(this),y=new e(this),b=new e(this),T=new e(this),M=new e(this),S=p._iFaces,k=g._iFaces,E=m._iFaces,A=v._iFaces,C=y._iFaces,w=b._iFaces,R=T._iFaces,x=M._iFaces,P=t.getFaceCenters(),D=this._iFaces,I=D.length,F=0;F<I;++F){var O=D[F],L=3*O,V=P[L],N=P[L+1],B=P[L+2];V>d?N>f?B>_?R.push(O):w.push(O):B>_?E.push(O):k.push(O):N>f?B>_?x.push(O):C.push(O):B>_?A.push(O):S.push(O)}p.setAabbSplit(i,n,a,d,f,_),g.setAabbSplit(i+u,n,a,d+u,f,_),m.setAabbSplit(d,f-c,_,s,o-c,l),v.setAabbSplit(i,n,a+h,d,f,_+h),y.setAabbSplit(i,n+c,a,d,f+c,_),b.setAabbSplit(d,f,_-h,s,o,l-h),T.setAabbSplit(d,f,_,s,o,l),M.setAabbSplit(d-u,f,_,s-u,o,l),this._children.length=0,this._children.push(p,g,m,v,y,b,T,M),D.length=0}},{key:"setAabbSplit",value:function(e,t,r,i,n,a){var s=this._aabbSplit;s[0]=e,s[1]=t,s[2]=r,s[3]=i,s[4]=n,s[5]=a}},{key:"setAabbLoose",value:function(e,t,r,i,n,a){var s=this._aabbLoose;s[0]=e,s[1]=t,s[2]=r,s[3]=i,s[4]=n,s[5]=a}},{key:"collectIntersectRay",value:function(t,r,i,n){var a=t[0],s=t[1],o=t[2],l=1/r[0],u=1/r[1],c=1/r[2],h=0,d=e.STACK;d[0]=this;for(var f=1;f>0;){var _=d[--f],p=_._aabbLoose,g=(p[0]-a)*l,m=(p[3]-a)*l,v=(p[1]-s)*u,y=(p[4]-s)*u,b=(p[2]-o)*c,T=(p[5]-o)*c,M=Math.max(Math.min(g,m),Math.min(v,y),Math.min(b,T)),S=Math.min(Math.max(g,m),Math.max(v,y),Math.max(b,T));if(!(S<0||M>S)){var k=_._children;if(8===k.length){for(var E=0;E<8;++E)d[f+E]=k[E];f+=8}else{n&&n.push(_);var A=_._iFaces;i.set(A,h),h+=A.length}}}return new Uint32Array(i.subarray(0,h))}},{key:"collectIntersectSphere",value:function(t,r,i,n){var a=t[0],s=t[1],o=t[2],l=0,u=e.STACK;u[0]=this;for(var c=1;c>0;){var h,d,f,_=u[--c],p=_._aabbLoose;if(!((h=p[0]>a?p[0]-a:p[3]<a?p[3]-a:0)*h+(d=p[1]>s?p[1]-s:p[4]<s?p[4]-s:0)*d+(f=p[2]>o?p[2]-o:p[5]<o?p[5]-o:0)*f>r)){var g=_._children;if(8===g.length){for(var m=0;m<8;++m)u[c+m]=g[m];c+=8}else{n&&n.push(_);var v=_._iFaces;i.set(v,l),l+=v.length}}}return new Uint32Array(i.subarray(0,l))}},{key:"addFace",value:function(t,r,i,n,a,s,o,l,u,c){var h=e.STACK;h[0]=this;for(var d=1;d>0;){var f=h[--d],_=f._aabbSplit;if(!(l<=_[0]||u<=_[1]||c<=_[2]||l>_[3]||u>_[4]||c>_[5])){var p=f._aabbLoose;r<p[0]&&(p[0]=r),i<p[1]&&(p[1]=i),n<p[2]&&(p[2]=n),a>p[3]&&(p[3]=a),s>p[4]&&(p[4]=s),o>p[5]&&(p[5]=o);var g=f._children;if(8!==g.length)return f._iFaces.push(t),f;for(var m=0;m<8;++m)h[d+m]=g[m];d+=8}}}},{key:"pruneIfPossible",value:function(){for(var e=this;e._parent;){var t=e._parent,r=t._children;if(0===r.length)return;for(var i=0;i<8;++i){var n=r[i];if(n._iFaces.length>0||8===n._children.length)return}r.length=0,e=t}}},{key:"expandsAabbLoose",value:function(e,t,r,i,n,a){for(var s=this;s;){var o=s._aabbLoose,l=!1;e<o[0]&&(o[0]=e,l=!0),t<o[1]&&(o[1]=t,l=!0),r<o[2]&&(o[2]=r,l=!0),i>o[3]&&(o[3]=i,l=!0),n>o[4]&&(o[4]=n,l=!0),a>o[5]&&(o[5]=a,l=!0),s=l?s._parent:null}}}])&&zt(t.prototype,r),e}();Xt.FLAG=0,Xt.MAX_DEPTH=8,Xt.MAX_FACES=100,function(){for(var e=1+7*Xt.MAX_DEPTH,t=Xt.STACK=new Array(e),r=0;r<e;++r)t[r]=null}();const Kt=Xt;var Ht=function(e){var t=(0,u.Z)();return{_gl:e,_shaderType:t.shader,_flatShading:t.flatshading,_showWireframe:t.wireframe,_matcap:Math.min(t.matcap,B.matcaps.length-1),_curvature:Math.min(t.curvature,5),_texture0:null,_useDrawArrays:!1,_vertexBuffer:new g(e,e.ARRAY_BUFFER,e.DYNAMIC_DRAW),_normalBuffer:new g(e,e.ARRAY_BUFFER,e.DYNAMIC_DRAW),_colorBuffer:new g(e,e.ARRAY_BUFFER,e.DYNAMIC_DRAW),_materialBuffer:new g(e,e.ARRAY_BUFFER,e.DYNAMIC_DRAW),_texCoordBuffer:new g(e,e.ARRAY_BUFFER,e.STATIC_DRAW),_indexBuffer:new g(e,e.ELEMENT_ARRAY_BUFFER,e.STATIC_DRAW),_wireframeBuffer:new g(e,e.ELEMENT_ARRAY_BUFFER,e.STATIC_DRAW),_albedo:new Float32Array([-1,-1,-1]),_roughness:-.18,_metallic:-.78,_alpha:1,_flatColor:new Float32Array([1,0,0]),_mode:e.TRIANGLES,_clipDisabled:!1}};Ht.ONLY_DRAW_ARRAYS=!1;const Yt=Ht;function qt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Jt=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._id=e.ID++,this._meshData=null,this._transformData=null,this._renderData=null,this._isVisible=!0}var t,r,n;return t=e,n=[{key:"sortFunction",value:function(e,t){var r=e.isTransparent(),i=t.isTransparent();return r&&!i?1:!r&&i?-1:(t.getDepth()-e.getDepth())*(r&&i?1:-1)}}],(r=[{key:"setID",value:function(e){this._id=e}},{key:"isVisible",value:function(){return this._isVisible}},{key:"setVisible",value:function(e){this._isVisible=e}},{key:"setVertices",value:function(e){this._meshData._verticesXYZ=e,this._meshData._nbVertices=e.length/3}},{key:"setFaces",value:function(e){this._meshData._facesABCD=e,this._meshData._nbFaces=e.length/4}},{key:"setTexCoords",value:function(e){this._meshData._texCoordsST=e,this._meshData._nbTexCoords=e.length/2}},{key:"setColors",value:function(e){this._meshData._colorsRGB=e}},{key:"setMaterials",value:function(e){this._meshData._materialsPBR=e}},{key:"setVerticesDuplicateStartCount",value:function(e){this._meshData._duplicateStartCount=e}},{key:"setFacesTexCoord",value:function(e){this._meshData._UVfacesABCD=e}},{key:"setMeshData",value:function(e){this._meshData=e}},{key:"setRenderData",value:function(e){this._renderData=e}},{key:"setTransformData",value:function(e){this._transformData=e}},{key:"setNbVertices",value:function(e){this._meshData._nbVertices=e}},{key:"setNbFaces",value:function(e){this._meshData._nbFaces=e}},{key:"getID",value:function(){return this._id}},{key:"getRenderData",value:function(){return this._renderData}},{key:"getMeshData",value:function(){return this._meshData}},{key:"getTransformData",value:function(){return this._transformData}},{key:"getNbVertices",value:function(){return this._meshData._nbVertices}},{key:"getNbFaces",value:function(){return this._meshData._nbFaces}},{key:"getNbQuads",value:function(){return this.getNbTriangles()-this.getNbFaces()}},{key:"getNbTriangles",value:function(){return this._meshData._trianglesABC.length/3}},{key:"getNbTexCoords",value:function(){return this._meshData._nbTexCoords}},{key:"hasUV",value:function(){return null!==this._meshData._texCoordsST}},{key:"getVertices",value:function(){return this._meshData._verticesXYZ}},{key:"getColors",value:function(){return this._meshData._colorsRGB}},{key:"getNormals",value:function(){return this._meshData._normalsXYZ}},{key:"getMaterials",value:function(){return this._meshData._materialsPBR}},{key:"getVerticesTagFlags",value:function(){return this._meshData._vertTagFlags}},{key:"getVerticesSculptFlags",value:function(){return this._meshData._vertSculptFlags}},{key:"getVerticesStateFlags",value:function(){return this._meshData._vertStateFlags}},{key:"getVerticesRingVertStartCount",value:function(){return this._meshData._vrvStartCount}},{key:"getVerticesRingVert",value:function(){return this._meshData._vertRingVert}},{key:"getVerticesRingFaceStartCount",value:function(){return this._meshData._vrfStartCount}},{key:"getVerticesRingFace",value:function(){return this._meshData._vertRingFace}},{key:"getVerticesOnEdge",value:function(){return this._meshData._vertOnEdge}},{key:"getVerticesProxy",value:function(){return this._meshData._vertProxy}},{key:"getFaces",value:function(){return this._meshData._facesABCD}},{key:"hasOnlyTriangles",value:function(){return this.getNbTriangles()===this.getNbFaces()}},{key:"hasOnlyQuads",value:function(){return this.getNbTriangles()===2*this.getNbFaces()}},{key:"getFaceNormals",value:function(){return this._meshData._faceNormalsXYZ}},{key:"getFaceBoxes",value:function(){return this._meshData._faceBoxes}},{key:"getFaceCenters",value:function(){return this._meshData._faceCentersXYZ}},{key:"getFacesTagFlags",value:function(){return this._meshData._facesTagFlags}},{key:"getFaceEdges",value:function(){return this._meshData._faceEdges}},{key:"getFacesToTriangles",value:function(){return this._meshData._facesToTriangles}},{key:"getTrianglesTexCoord",value:function(){return this._meshData._UVtrianglesABC}},{key:"getTriangles",value:function(){return this._meshData._trianglesABC}},{key:"getEdges",value:function(){return this._meshData._edges}},{key:"getNbEdges",value:function(){return this._meshData._edges.length}},{key:"getTexCoords",value:function(){return this._meshData._texCoordsST}},{key:"getVerticesDuplicateStartCount",value:function(){return this._meshData._duplicateStartCount}},{key:"getFacesTexCoord",value:function(){return this._meshData._UVfacesABCD}},{key:"getVerticesDrawArrays",value:function(){return this._meshData._DAverticesXYZ||this.updateDrawArrays(),this._meshData._DAverticesXYZ}},{key:"getNormalsDrawArrays",value:function(){return this._meshData._DAnormalsXYZ}},{key:"getColorsDrawArrays",value:function(){return this._meshData._DAcolorsRGB}},{key:"getMaterialsDrawArrays",value:function(){return this._meshData._DAmaterialsPBR}},{key:"getTexCoordsDrawArrays",value:function(){return this._meshData._DAtexCoordsST}},{key:"getOctree",value:function(){return this._meshData._octree}},{key:"getCenter",value:function(){return this._transformData._center}},{key:"getMV",value:function(){return this._transformData._lastComputedMV}},{key:"getMVP",value:function(){return this._transformData._lastComputedMVP}},{key:"getN",value:function(){return this._transformData._lastComputedN}},{key:"getEN",value:function(){return this._transformData._lastComputedEN}},{key:"getDepth",value:function(){return this._transformData._lastComputedDepth}},{key:"getMatrix",value:function(){return this._transformData._matrix}},{key:"getEditMatrix",value:function(){return this._transformData._editMatrix}},{key:"getScale2",value:function(){var e=this._transformData._matrix;return e[0]*e[0]+e[4]*e[4]+e[8]*e[8]}},{key:"getScale",value:function(){return Math.sqrt(this.getScale2())}},{key:"getSymmetryOrigin",value:function(){var e=i.Ue(),t=this._transformData,r=t._symmetryOffset*this.computeLocalRadius();return i.od(e,t._center,t._symmetryNormal,r)}},{key:"getSymmetryOffset",value:function(){return this._transformData._symmetryOffset}},{key:"setSymmetryOffset",value:function(e){this._transformData._symmetryOffset=e}},{key:"getSymmetryNormal",value:function(){return this._transformData._symmetryNormal}},{key:"getFacePosInLeaf",value:function(){return this._meshData._facePosInLeaf}},{key:"getFaceLeaf",value:function(){return this._meshData._faceLeaf}},{key:"getLeavesToUpdate",value:function(){return this._meshData._leavesToUpdate}},{key:"getLocalBound",value:function(){return this._meshData._octree._aabbLoose}},{key:"getRenderNbEdges",value:function(){return this.getNbEdges()}},{key:"init",value:function(){this.initColorsAndMaterials(),this.allocateArrays(),this.initTopology(),this.updateGeometry(),this._renderData&&this.updateDuplicateColorsAndMaterials(),this.updateCenter()}},{key:"initTopology",value:function(){this.initFaceRings(),this.optimize(),this.initEdges(),this.initVertexRings(),this.initRenderTriangles()}},{key:"updateGeometry",value:function(e,t){this.updateFacesAabbAndNormal(e),this.updateVerticesNormal(t),this.updateOctree(e),this._renderData&&(this.updateDuplicateGeometry(t),this.updateDrawArrays(e))}},{key:"allocateArrays",value:function(){var e=this.getNbVertices();if(this.hasUV()){var t=this._meshData._texCoordsST.length/2,r=new Float32Array(3*t);r.set(this._meshData._verticesXYZ),this._meshData._verticesXYZ=r,this._meshData._normalsXYZ=new Float32Array(3*t),r=new Float32Array(3*t),this._meshData._colorsRGB&&r.set(this._meshData._colorsRGB),this._meshData._colorsRGB=r,r=new Float32Array(3*t),this._meshData._materialsPBR&&r.set(this._meshData._materialsPBR),this._meshData._materialsPBR=r}else this._meshData._normalsXYZ=this._meshData._normalsXYZ||new Float32Array(3*e),this._meshData._colorsRGB=this._meshData._colorsRGB||new Float32Array(3*e),this._meshData._materialsPBR=this._meshData._materialsPBR||new Float32Array(3*e);this._meshData._vertOnEdge=new Uint8Array(e),this._meshData._vrvStartCount=new Uint32Array(2*e),this._meshData._vrfStartCount=new Uint32Array(2*e),this._meshData._vertTagFlags=new Int32Array(e),this._meshData._vertSculptFlags=new Int32Array(e),this._meshData._vertStateFlags=new Int32Array(e),this._meshData._vertProxy=new Float32Array(3*e);var i=this.getNbFaces();this._meshData._faceEdges=new Uint32Array(4*i),this._meshData._facesToTriangles=new Uint32Array(i),this._meshData._faceBoxes=new Float32Array(6*i),this._meshData._faceNormalsXYZ=new Float32Array(3*i),this._meshData._faceCentersXYZ=new Float32Array(3*i),this._meshData._facesTagFlags=new Int32Array(i),this._meshData._facePosInLeaf=new Uint32Array(i);var n=this._meshData._faceLeaf;n.length=i;for(var a=0;a<i;++a)n[a]=null}},{key:"initColorsAndMaterials",value:function(){var e=this.getNbVertices(),t=0,r=3*e;if(!this._meshData._colorsRGB||this._meshData._colorsRGB.length!==r){var i=this._meshData._colorsRGB=new Float32Array(r);for(t=0;t<r;++t)i[t]=1}if(!this._meshData._materialsPBR||this._meshData._materialsPBR.length!==r){var n=this._meshData._materialsPBR=new Float32Array(r);for(t=0;t<e;++t){var a=3*t;n[a]=.18,n[a+1]=.08,n[a+2]=1}}}},{key:"initFaceRings",value:function(){var e=this.getFaces(),t=this.getNbVertices(),r=this.getNbFaces(),i=0,n=0,a=new Uint32Array(t);for(i=0;i<r;++i){a[e[n=4*i]]++,a[e[n+1]]++,a[e[n+2]]++;var s=e[n+3];s!==o.Z.TRI_INDEX&&a[s]++}var l=this.getVerticesRingFaceStartCount(),u=0;for(i=0;i<t;++i){var c=a[i];l[2*i]=u,l[2*i+1]=c,u+=c}var h=new Uint32Array(o.Z.getMemory(4*r*6),0,6*r);for(u=0,i=0;i<r;++i){var d=e[n=4*i],f=e[n+1],_=e[n+2],p=e[n+3];h[l[2*d]+--a[d]]=i,h[l[2*f]+--a[f]]=i,h[l[2*_]+--a[_]]=i,p!==o.Z.TRI_INDEX&&(h[l[2*p]+--a[p]]=i,++u)}this._meshData._vertRingFace=new Uint32Array(h.subarray(0,3*r+u))}},{key:"updateVerticesNormal",value:function(e){for(var t=this.getVerticesRingFaceStartCount(),r=this.getVerticesRingFace(),i=r instanceof Array?r:null,n=this.getNormals(),a=this.getFaceNormals(),s=void 0===e,o=s?this.getNbVertices():e.length,l=0;l<o;++l){var u,c,h=s?l:e[l];i?(u=0,c=(r=i[h]).length):c=(u=t[2*h])+t[2*h+1];for(var d=0,f=0,_=0,p=u;p<c;++p){var g=3*r[p];d+=a[g],f+=a[g+1],_+=a[g+2]}var m=c-u;0!==m&&(m=1/m),n[h*=3]=d*m,n[h+1]=f*m,n[h+2]=_*m}}},{key:"initVertexRings",value:function(){for(var e=this.getVerticesRingVertStartCount(),t=this._meshData._vertRingVert=new Uint32Array(2*this.getNbEdges()),r=this.getVerticesRingFaceStartCount(),i=this.getVerticesRingFace(),n=this.getVerticesTagFlags(),a=this.getVerticesOnEdge(),s=this.getFaces(),l=0,u=0,c=this.getNbVertices();u<c;++u){for(var h=++o.Z.TAG_FLAG,d=r[2*u],f=d+r[2*u+1],_=0,p=d;p<f;++p){var g=4*i[p],m=s[g],v=s[g+1],y=s[g+2],b=s[g+3];m===u?m=b!==o.Z.TRI_INDEX?b:y:v===u||b===u?v=y:y===u&&b!==o.Z.TRI_INDEX&&(m=b),n[m]!==h&&(t[l+_++]=m,n[m]=h),n[v]!==h&&(t[l+_++]=v,n[v]=h)}e[2*u]=l,e[2*u+1]=_,l+=_,f-d!==_&&(a[u]=1)}}},{key:"expandsVertices",value:function(e,t){var r=++o.Z.TAG_FLAG,i=e.length,n=this.getVerticesRingVertStartCount(),a=this.getVerticesRingVert(),s=a instanceof Array?a:null,l=this.getVerticesTagFlags(),u=i,c=this.getNbVertices(),h=new Uint32Array(o.Z.getMemory(4*c),0,c);h.set(e);var d=0;for(d=0;d<i;++d)l[h[d]]=r;for(var f=0;t;){for(--t,d=f;d<i;++d){var _,p,g=h[d];s?(_=0,p=(a=s[g]).length):p=(_=n[2*g])+n[2*g+1];for(var m=_;m<p;++m){var v=a[m];l[v]!==r&&(l[v]=r,h[u++]=v)}}f=i,i=u}return new Uint32Array(h.subarray(0,u))}},{key:"getVerticesFromFaces",value:function(e){for(var t=++o.Z.TAG_FLAG,r=e.length,i=this.getVerticesTagFlags(),n=this.getFaces(),a=0,s=new Uint32Array(o.Z.getMemory(4*e.length*4),0,4*e.length),l=0;l<r;++l){var u=4*e[l],c=n[u],h=n[u+1],d=n[u+2],f=n[u+3];i[c]!==t&&(i[c]=t,s[a++]=c),i[h]!==t&&(i[h]=t,s[a++]=h),i[d]!==t&&(i[d]=t,s[a++]=d),f!==o.Z.TRI_INDEX&&i[f]!==t&&(i[f]=t,s[a++]=f)}return new Uint32Array(s.subarray(0,a))}},{key:"updateFacesAabbAndNormal",value:function(e){for(var t=this.getFaceNormals(),r=this.getFaceBoxes(),i=this.getFaceCenters(),n=this.getVertices(),a=this.getFaces(),s=void 0===e,l=s?this.getNbFaces():e.length,u=0;u<l;++u){var c=s?u:e[u],h=3*c,d=4*c,f=6*c,_=3*a[d],p=3*a[d+1],g=3*a[d+2],m=a[d+3],v=m!==o.Z.TRI_INDEX;v&&(m*=3);var y=n[_],b=n[_+1],T=n[_+2],M=n[p],S=n[p+1],k=n[p+2],E=n[g],A=n[g+1],C=n[g+2],w=M-y,R=S-b,x=k-T,P=E-y,D=A-b,I=C-T,F=R*I-x*D,O=x*P-w*I,L=w*D-R*P,V=y<M?y<E?y:E:M<E?M:E,N=y>M?y>E?y:E:M>E?M:E,B=b<S?b<A?b:A:S<A?S:A,U=b>S?b>A?b:A:S>A?S:A,Z=T<k?T<C?T:C:k<C?k:C,G=T>k?T>C?T:C:k>C?k:C;if(v){var W=n[m],j=n[m+1],z=n[m+2];W<V&&(V=W),W>N&&(N=W),j<B&&(B=j),j>U&&(U=j),z<Z&&(Z=z),z>G&&(G=z),F+=(R=A-j)*I-(x=C-z)*D,O+=x*P-(w=E-W)*I,L+=w*D-R*P}t[h]=F,t[h+1]=O,t[h+2]=L,r[f]=V,r[f+1]=B,r[f+2]=Z,r[f+3]=N,r[f+4]=U,r[f+5]=G,i[h]=.5*(V+N),i[h+1]=.5*(B+U),i[h+2]=.5*(Z+G)}}},{key:"expandsFaces",value:function(e,t){var r=++o.Z.TAG_FLAG,i=e.length,n=this.getVerticesRingFaceStartCount(),a=this.getVerticesRingFace(),s=a instanceof Array?a:null,l=this.getFacesTagFlags(),u=this.getFaces(),c=i,h=new Uint32Array(o.Z.getMemory(4*this.getNbFaces()),0,this.getNbFaces());h.set(e);var d=0;for(d=0;d<i;++d)l[h[d]]=r;for(var f=0;t;){for(--t,d=f;d<i;++d)for(var _=4*h[d],p=0;p<4;++p){var g=u[_+p];if(g!==o.Z.TRI_INDEX){var m,v;s?(m=0,v=(a=s[g]).length):v=(m=n[2*g])+n[2*g+1];for(var y=m;y<v;++y){var b=a[y];l[b]!==r&&(l[b]=r,h[c++]=b)}}}f=i,i=c}return new Uint32Array(h.subarray(0,c))}},{key:"getFacesFromVertices",value:function(e){for(var t=++o.Z.TAG_FLAG,r=e.length,i=this.getVerticesRingFaceStartCount(),n=this.getVerticesRingFace(),a=n instanceof Array?n:null,s=this.getFacesTagFlags(),l=0,u=new Uint32Array(o.Z.getMemory(4*this.getNbFaces()),0,this.getNbFaces()),c=0;c<r;++c){var h,d,f=e[c];a?(h=0,d=(n=a[f]).length):d=(h=i[2*f])+i[2*f+1];for(var _=h;_<d;++_){var p=n[_];s[p]!==t&&(s[p]=t,u[l++]=p)}}return new Uint32Array(u.subarray(0,l))}},{key:"initRenderTriangles",value:function(){this.hasUV()&&(this._meshData._UVtrianglesABC=this.computeTrianglesFromFaces(this.getFacesTexCoord())),this._meshData._trianglesABC=this.computeTrianglesFromFaces(this.getFaces())}},{key:"computeTrianglesFromFaces",value:function(e){for(var t=this.getNbFaces(),r=this.getFacesToTriangles(),i=new Uint32Array(o.Z.getMemory(4*t*6),0,6*t),n=0,a=0;a<t;++a){r[a]=n;var s=4*a,l=e[s],u=e[s+1],c=e[s+2],h=e[s+3],d=3*n;i[d]=l,i[d+1]=u,i[d+2]=c,++n,h!==o.Z.TRI_INDEX&&(i[d=3*n]=l,i[d+1]=c,i[d+2]=h,++n)}return new Uint32Array(i.subarray(0,3*n))}},{key:"initEdges",value:function(){for(var e=this.getFaces(),t=this.getFaceEdges(),r=0,i=new Uint32Array(this.getNbVertices()),n=this.getVerticesRingFaceStartCount(),a=this.getVerticesRingFace(),s=0,l=this.getNbVertices();s<l;++s)for(var u=n[2*s],c=u+n[2*s+1],h=r,d=u;d<c;++d){var f=4*a[d],_=e[f],p=e[f+1],g=e[f+2],m=e[f+3],v=0,y=0;m===o.Z.TRI_INDEX?(s>_&&(y=f+(s===p?0:2),(v=i[_])<=h?(t[y]=r,i[_]=++r):t[y]=v-1),s>p&&(y=f+(s===_?0:1),(v=i[p])<=h?(t[y]=r,i[p]=++r):t[y]=v-1),s>g&&(y=f+(s===_?2:1),(v=i[g])<=h?(t[y]=r,i[g]=++r):t[y]=v-1),t[f+3]=o.Z.TRI_INDEX):(s>_&&s!==g&&(y=f+(s===p?0:3),(v=i[_])<=h?(t[y]=r,i[_]=++r):t[y]=v-1),s>p&&s!==m&&(y=f+(s===_?0:1),(v=i[p])<=h?(t[y]=r,i[p]=++r):t[y]=v-1),s>g&&s!==_&&(y=f+(s===p?1:2),(v=i[g])<=h?(t[y]=r,i[g]=++r):t[y]=v-1),s>m&&s!==p&&(y=f+(s===_?3:2),(v=i[m])<=h?(t[y]=r,i[m]=++r):t[y]=v-1))}for(var b=this._meshData._edges=new Uint8ClampedArray(r),T=0,M=this.getNbFaces();T<M;++T){var S=4*T;b[t[S]]++,b[t[S+1]]++,b[t[S+2]]++;var k=t[S+3];k!==o.Z.TRI_INDEX&&b[k]++}}},{key:"getWireframe",value:function(){var e,t=this.getNbEdges(),r=this.isUsingDrawArrays();if(r){if(this._meshData._drawArraysWireframe&&this._meshData._drawArraysWireframe.length===2*t)return this._meshData._drawArraysWireframe;e=this._meshData._drawArraysWireframe=new Uint32Array(2*t)}else{if(this._meshData._drawElementsWireframe&&this._meshData._drawElementsWireframe.length===2*t)return this._meshData._drawElementsWireframe;e=this._meshData._drawElementsWireframe=new Uint32Array(2*t)}for(var i=this.getFaces(),n=this.getFaceEdges(),a=this.getNbFaces(),s=this.getFacesToTriangles(),l=0,u=new Uint8Array(t),c=0;c<a;++c){var h,d,f,_=4*c,p=i[_+3],g=p!==o.Z.TRI_INDEX;if(r){var m=3*s[c];h=m,d=m+1,f=m+2,g&&(p=m+5)}else h=i[_],d=i[_+1],f=i[_+2];var v=n[_],y=n[_+1],b=n[_+2],T=n[_+3];0===u[v]&&(u[v]=1,e[2*l]=h,e[2*l+1]=d,l++),0===u[y]&&(u[y]=1,e[2*l]=d,e[2*l+1]=f,l++),0===u[b]&&(u[b]=1,e[2*l]=f,e[2*l+1]=g?p:h,l++),g&&0===u[T]&&(u[T]=1,e[2*l]=p,e[2*l+1]=h,l++)}return r?this._meshData._drawArraysWireframe:this._meshData._drawElementsWireframe}},{key:"updateDuplicateGeometry",value:function(e){if(this.isUsingTexCoords()&&this.hasUV())for(var t=this.getVertices(),r=this.getColors(),i=this.getMaterials(),n=this.getNormals(),a=this.getVerticesDuplicateStartCount(),s=void 0===e,o=s?this.getNbVertices():e.length,l=0;l<o;++l){var u=s?l:e[l],c=a[2*u];if(0!==c)for(var h=c+a[2*u+1],d=3*u,f=t[d],_=t[d+1],p=t[d+2],g=n[d],m=n[d+1],v=n[d+2],y=r[d],b=r[d+1],T=r[d+2],M=i[d],S=i[d+1],k=i[d+2],E=c;E<h;++E){var A=3*E;t[A]=f,t[A+1]=_,t[A+2]=p,n[A]=g,n[A+1]=m,n[A+2]=v,r[A]=y,r[A+1]=b,r[A+2]=T,i[A]=M,i[A+1]=S,i[A+2]=k}}}},{key:"updateDuplicateColorsAndMaterials",value:function(e){if(this.isUsingTexCoords()&&this.hasUV())for(var t=this.getColors(),r=this.getMaterials(),i=this.getVerticesDuplicateStartCount(),n=void 0===e,a=n?this.getNbVertices():e.length,s=0;s<a;++s){var o=n?s:e[s],l=i[2*o];if(0!==l)for(var u=l+i[2*o+1],c=3*o,h=t[c],d=t[c+1],f=t[c+2],_=r[c],p=r[c+1],g=r[c+2],m=l;m<u;++m){var v=3*m;t[v]=h,t[v+1]=d,t[v+2]=f,r[v]=_,r[v+1]=p,r[v+2]=g}}}},{key:"initTexCoordsDataFromOBJData",value:function(e,t){var r=this.getFaces(),i=r.length;if(i==t.length){var n=e.length/2;for(s=0;s<i;++s)t[s]>=n&&(t[s]=r[s]);var a=this.getNbVertices(),s=0,l=0,u=0,c=0,h=new Int32Array(a),d=new Float32Array(o.Z.getMemory(4*a*2),0,2*a),f=[],_=0,p=0;for(s=0;s<i;++s)if((u=r[s])!==o.Z.TRI_INDEX){var g=t[s];if((c=h[u])!==g+1)if(0!==c)if(c>0)h[u]=--_,f.push([g]),++p;else{var m=f[-c-1],v=m.length;for(l=0;l<v&&m[l]!==g;++l);l===v&&(++p,m.push(g))}else h[u]=g+1,d[2*u]=e[2*g],d[2*u+1]=e[2*g+1]}var y=new Float32Array(2*(a+p));y.set(d);var b=this._meshData._duplicateStartCount=new Uint32Array(2*a);for(_=0,s=0;s<a;++s)if(!((c=h[s])>=0)){var T=f[-c-1],M=T.length,S=a+_;for(b[2*s]=S,b[2*s+1]=M,_+=M,l=0;l<M;++l){var k=2*T[l],E=2*(S+l);y[E]=e[k],y[E+1]=e[k+1]}}var A=new Uint32Array(r);for(i=r.length,s=0;s<i;++s)if((u=A[s])!==o.Z.TRI_INDEX&&!((c=h[u])>0)){var C=t[s],w=f[-c-1],R=w.length;for(l=0;l<R;++l)if(C===w[l]){A[s]=b[2*u]+l;break}}this.setTexCoords(y),this.setFacesTexCoord(A)}}},{key:"setAlreadyDrawArrays",value:function(){this._meshData._DAverticesXYZ=this.getVertices(),this._meshData._DAnormalsXYZ=this.getNormals(),this._meshData._DAcolorsRGB=this.getColors(),this._meshData._DAmaterialsPBR=this.getMaterials()}},{key:"updateDrawArrays",value:function(e){if(this.isUsingDrawArrays()){var t=this.getVertices(),r=this.getNormals(),i=this.getColors(),n=this.getMaterials(),a=this.getFaces(),s=this.getNbTriangles(),l=this.hasOnlyTriangles()?null:this.getFacesToTriangles(),u=void 0===e,c=this._meshData._DAverticesXYZ,h=this._meshData._DAnormalsXYZ,d=this._meshData._DAcolorsRGB,f=this._meshData._DAmaterialsPBR;(!c||c.length<9*s)&&(c=this._meshData._DAverticesXYZ=new Float32Array(9*s),h=this._meshData._DAnormalsXYZ=new Float32Array(9*s),d=this._meshData._DAcolorsRGB=new Float32Array(9*s),f=this._meshData._DAmaterialsPBR=new Float32Array(9*s));for(var _=u?this.getNbFaces():e.length,p=0;p<_;++p){var g=u?p:e[p],m=9*(l?l[g]:g),v=3*a[g*=4],y=3*a[g+1],b=3*a[g+2];c[m]=t[v],c[m+1]=t[v+1],c[m+2]=t[v+2],c[m+3]=t[y],c[m+4]=t[y+1],c[m+5]=t[y+2],c[m+6]=t[b],c[m+7]=t[b+1],c[m+8]=t[b+2],d[m]=i[v],d[m+1]=i[v+1],d[m+2]=i[v+2],d[m+3]=i[y],d[m+4]=i[y+1],d[m+5]=i[y+2],d[m+6]=i[b],d[m+7]=i[b+1],d[m+8]=i[b+2],f[m]=n[v],f[m+1]=n[v+1],f[m+2]=n[v+2],f[m+3]=n[y],f[m+4]=n[y+1],f[m+5]=n[y+2],f[m+6]=n[b],f[m+7]=n[b+1],f[m+8]=n[b+2],h[m]=r[v],h[m+1]=r[v+1],h[m+2]=r[v+2],h[m+3]=r[y],h[m+4]=r[y+1],h[m+5]=r[y+2],h[m+6]=r[b],h[m+7]=r[b+1],h[m+8]=r[b+2];var T=a[g+3];T!==o.Z.TRI_INDEX&&(T*=3,c[m+=9]=t[v],c[m+1]=t[v+1],c[m+2]=t[v+2],c[m+3]=t[b],c[m+4]=t[b+1],c[m+5]=t[b+2],c[m+6]=t[T],c[m+7]=t[T+1],c[m+8]=t[T+2],d[m]=i[v],d[m+1]=i[v+1],d[m+2]=i[v+2],d[m+3]=i[b],d[m+4]=i[b+1],d[m+5]=i[b+2],d[m+6]=i[T],d[m+7]=i[T+1],d[m+8]=i[T+2],f[m]=n[v],f[m+1]=n[v+1],f[m+2]=n[v+2],f[m+3]=n[b],f[m+4]=n[b+1],f[m+5]=n[b+2],f[m+6]=n[T],f[m+7]=n[T+1],f[m+8]=n[T+2],h[m]=r[v],h[m+1]=r[v+1],h[m+2]=r[v+2],h[m+3]=r[b],h[m+4]=r[b+1],h[m+5]=r[b+2],h[m+6]=r[T],h[m+7]=r[T+1],h[m+8]=r[T+2])}this.isUsingTexCoords()&&this.updateDrawArraysTexCoord(e)}}},{key:"updateDrawArraysTexCoord",value:function(e){var t=this.getNbTriangles(),r=this.getFacesToTriangles(),i=void 0===e,n=this._meshData._DAtexCoordsST;n&&n.length===6*t||(n=this._meshData._DAtexCoordsST=new Float32Array(6*t));for(var a=this.getTexCoords(),s=this.getFacesTexCoord(),l=i?this.getNbFaces():e.length,u=0;u<l;++u){var c=i?u:e[u],h=6*r[c],d=2*s[c*=4],f=2*s[c+1],_=2*s[c+2];n[h]=a[d],n[h+1]=a[d+1],n[h+2]=a[f],n[h+3]=a[f+1],n[h+4]=a[_],n[h+5]=a[_+1];var p=s[c+3];p!==o.Z.TRI_INDEX&&(p*=3,n[h+=6]=a[d],n[h+1]=a[d+1],n[h+2]=a[_],n[h+3]=a[_+1],n[h+4]=a[p],n[h+5]=a[p+1])}}},{key:"updateCenter",value:function(){var e=this.getLocalBound();i.t8(this._transformData._center,.5*(e[0]+e[3]),.5*(e[1]+e[4]),.5*(e[2]+e[5]))}},{key:"updateMatrices",value:function(e){_(this._transformData._lastComputedEN,this._transformData._editMatrix),l.dC(this._transformData._lastComputedMV,e.getView(),this._transformData._matrix),_(this._transformData._lastComputedN,this._transformData._lastComputedMV),l.dC(this._transformData._lastComputedMVP,e.getProjection(),this._transformData._lastComputedMV);var t=this._transformData._center,r=this._transformData._lastComputedMVP;this._transformData._lastComputedDepth=r[2]*t[0]+r[6]*t[1]+r[10]*t[2]+r[14]}},{key:"computeLocalRadius",value:function(){var e=this.getLocalBound();return.5*i.TK([e[0],e[1],e[2]],[e[3],e[4],e[5]])}},{key:"normalizeSize",value:function(){var e=o.Z.SCALE/(2*this.computeLocalRadius());l.bA(this._transformData._matrix,this._transformData._matrix,[e,e,e])}},{key:"computeWorldBound",value:function(){var e=this._meshData._worldBound,t=this.getLocalBound(),r=this.getMatrix();e[0]=e[3]=r[12],e[1]=e[4]=r[13],e[2]=e[5]=r[14];for(var i=0;i<3;++i)for(var n=4*i,a=t[i],s=t[i+3],o=0;o<3;++o){var l=r[n+o],u=l*s,c=l*a;u<c?(e[o]+=u,e[o+3]+=c):(e[o]+=c,e[o+3]+=u)}return e}},{key:"intersectRay",value:function(e,t,r){var i=this.getNbFaces(),n=new Uint32Array(o.Z.getMemory(4*i),0,i);return this._meshData._octree.collectIntersectRay(e,t,n,r?this._meshData._leavesToUpdate:void 0)}},{key:"intersectSphere",value:function(e,t,r){var i=this.getNbFaces(),n=new Uint32Array(o.Z.getMemory(4*i),0,i);return this._meshData._octree.collectIntersectSphere(e,t,n,r?this._meshData._leavesToUpdate:void 0)}},{key:"updateOctree",value:function(e){e?this.updateOctreeAdd(this.updateOctreeRemove(e)):this.computeOctree()}},{key:"computeAabb",value:function(){for(var e=this.getNbVertices(),t=this.getVertices(),r=1/0,i=1/0,n=1/0,a=-1/0,s=-1/0,o=-1/0,l=0;l<e;++l){var u=3*l,c=t[u],h=t[u+1],d=t[u+2];c<r&&(r=c),c>a&&(a=c),h<i&&(i=h),h>s&&(s=h),d<n&&(n=d),d>o&&(o=d)}return[r,i,n,a,s,o]}},{key:"computeOctree",value:function(){var e=this.computeAabb(),t=e[0],r=e[1],i=e[2],n=e[3],a=e[4],s=e[5],o=n-t,l=a-r,u=s-i,c=.2*Math.sqrt(o*o+l*l+u*u),h=1e-16;n-t<h&&(t-=c,n+=c),a-r<h&&(r-=c,a+=c),s-i<h&&(i-=c,s+=c);var d=.3*o,f=.3*l,_=.3*u,p=t-d,g=n+d,m=r-f,v=a+f,y=i-_,b=s+_,T=this._meshData._octree=new Kt;T.resetNbFaces(this.getNbFaces()),T.setAabbLoose(t,r,i,n,a,s),T.setAabbSplit(p,m,y,g,v,b),T.build(this)}},{key:"updateOctreeRemove",value:function(e){for(var t=this.getFaceCenters(),r=this.getFaceBoxes(),i=this._meshData._facePosInLeaf,n=this._meshData._faceLeaf,a=e.length,s=0,l=new Uint32Array(o.Z.getMemory(4*a),0,a),u=0;u<a;++u){var c=e[u],h=6*c,d=3*c,f=n[c],_=f._aabbSplit,p=t[d],g=t[d+1],m=t[d+2];if(p<=_[0]||g<=_[1]||m<=_[2]||p>_[3]||g>_[4]||m>_[5]){l[s++]=e[u];var v=f._iFaces;if(v.length>0){var y=v[v.length-1],b=i[c];v[b]=y,i[y]=b,v.pop()}}else f.expandsAabbLoose(r[h],r[h+1],r[h+2],r[h+3],r[h+4],r[h+5])}return new Uint32Array(l.subarray(0,s))}},{key:"updateOctreeAdd",value:function(e){for(var t=this.getFaceCenters(),r=this.getFaceBoxes(),i=this._meshData._facePosInLeaf,n=this._meshData._faceLeaf,a=e.length,s=this._meshData._octree,o=s._aabbSplit,l=o[0],u=o[1],c=o[2],h=o[3],d=o[4],f=o[5],_=0;_<a;++_){var p=e[_],g=6*p,m=r[g],v=r[g+1],y=r[g+2],b=r[g+3],T=r[g+4],M=r[g+5];if(m>h||b<l||v>d||T<u||y>f||M<c){this.computeOctree(),this._meshData._leavesToUpdate.length=0;break}var S=3*p,k=s.addFace(p,m,v,y,b,T,M,t[S],t[S+1],t[S+2]);if(k)i[p]=k._iFaces.length-1,n[p]=k;else{var E=n[p]._iFaces;i[p]=E.length,E.push(e[_])}}}},{key:"balanceOctree",value:function(){++Kt.FLAG;for(var e=this._meshData._leavesToUpdate,t=e.length,r=0;r<t;++r){var i=e[r];i._flag!==Kt.FLAG&&(0===i._iFaces.length?i.pruneIfPossible():i._iFaces.length>Kt.MAX_FACES&&i._depth<Kt.MAX_DEPTH&&i.build(this),i._flag=Kt.FLAG)}e.length=0}},{key:"setFlatColor",value:function(e){this.getFlatColor().set(e)}},{key:"setAlbedo",value:function(e){this.getAlbedo().set(e)}},{key:"setMode",value:function(e){this._renderData._mode=e}},{key:"setRoughness",value:function(e){this._renderData._roughness=e}},{key:"setMetallic",value:function(e){this._renderData._metallic=e}},{key:"setOpacity",value:function(e){this._renderData._alpha=e}},{key:"setTexture0",value:function(e){this._renderData._texture0=e}},{key:"setMatcap",value:function(e){this._renderData._matcap=e}},{key:"setCurvature",value:function(e){this._renderData._curvature=e}},{key:"setFlatShading",value:function(e){this._renderData._flatShading=e}},{key:"setShowWireframe",value:function(e){this._renderData._showWireframe=!Yt.ONLY_DRAW_ARRAYS&&e,this.updateWireframeBuffer()}},{key:"setClipDisabled",value:function(e){this._renderData._clipDisabled=e}},{key:"setUseDrawArrays",value:function(e){this._renderData._useDrawArrays=e}},{key:"getGL",value:function(){return this._renderData._gl}},{key:"getCount",value:function(){var e=this.getGL();return this.getMode()===e.TRIANGLES?3*this.getNbTriangles():this.getMode()===e.LINES?this.getNbVertices():0}},{key:"getVertexBuffer",value:function(){return this._renderData._vertexBuffer}},{key:"getNormalBuffer",value:function(){return this._renderData._normalBuffer}},{key:"getColorBuffer",value:function(){return this._renderData._colorBuffer}},{key:"getMaterialBuffer",value:function(){return this._renderData._materialBuffer}},{key:"getTexCoordBuffer",value:function(){return this._renderData._texCoordBuffer}},{key:"getIndexBuffer",value:function(){return this._renderData._indexBuffer}},{key:"getWireframeBuffer",value:function(){return this._renderData._wireframeBuffer}},{key:"getRoughness",value:function(){return this._renderData._roughness}},{key:"getMetallic",value:function(){return this._renderData._metallic}},{key:"getOpacity",value:function(){return this._renderData._alpha}},{key:"getFlatColor",value:function(){return this._renderData._flatColor}},{key:"getMode",value:function(){return this._renderData._mode}},{key:"getAlbedo",value:function(){return this._renderData._albedo}},{key:"getTexture0",value:function(){return this._renderData._texture0}},{key:"getMatcap",value:function(){return this._renderData._matcap}},{key:"getCurvature",value:function(){return this._renderData._curvature}},{key:"getFlatShading",value:function(){return this._renderData._flatShading}},{key:"getShowWireframe",value:function(){return this._renderData._showWireframe}},{key:"getClipDisabled",value:function(){return!!this._renderData._clipDisabled}},{key:"isUsingDrawArrays",value:function(){return this._renderData._useDrawArrays||Yt.ONLY_DRAW_ARRAYS}},{key:"isUsingTexCoords",value:function(){var e=this._renderData._shaderType;return e===s.Z.Shader.UV||e===s.Z.Shader.PAINTUV}},{key:"isTransparent",value:function(){return this._renderData._alpha<.99}},{key:"getShaderType",value:function(){return this._renderData._shaderType}},{key:"setShaderType",value:function(e){var t=this.hasUV();if(e===s.Z.Shader.UV&&!t){if(this._renderData._shaderType!==s.Z.Shader.UV)return;e=s.Z.Shader.MATCAP}this._renderData._shaderType=e,t&&(this.updateDuplicateGeometry(),this.updateDrawArrays()),this.updateBuffers()}},{key:"initRender",value:function(){this.setShaderType(this._renderData._shaderType),this.setShowWireframe(this.getShowWireframe())}},{key:"render",value:function(e){this.isVisible()&&de[this.getShaderType()].getOrCreate(this.getGL()).draw(this,e)}},{key:"renderWireframe",value:function(e){this.isVisible()&&de[s.Z.Shader.WIREFRAME].getOrCreate(this.getGL()).draw(this,e)}},{key:"renderFlatColor",value:function(e){this.isVisible()&&de[s.Z.Shader.FLAT].getOrCreate(this.getGL()).draw(this,e)}},{key:"getRenderNbVertices",value:function(){return this.isUsingDrawArrays()?this.getCount():this.isUsingTexCoords()?this.getNbTexCoords():this.getNbVertices()}},{key:"updateVertexBuffer",value:function(){var e=this.isUsingDrawArrays()?this.getVerticesDrawArrays():this.getVertices();this.getVertexBuffer().update(e,3*this.getRenderNbVertices())}},{key:"updateNormalBuffer",value:function(){var e=this.isUsingDrawArrays()?this.getNormalsDrawArrays():this.getNormals();this.getNormalBuffer().update(e,3*this.getRenderNbVertices())}},{key:"updateColorBuffer",value:function(){var e=this.isUsingDrawArrays()?this.getColorsDrawArrays():this.getColors();this.getColorBuffer().update(e,3*this.getRenderNbVertices())}},{key:"updateMaterialBuffer",value:function(){var e=this.isUsingDrawArrays()?this.getMaterialsDrawArrays():this.getMaterials();this.getMaterialBuffer().update(e,3*this.getRenderNbVertices())}},{key:"updateTexCoordBuffer",value:function(){if(this.isUsingTexCoords()){var e=this.isUsingDrawArrays()?this.getTexCoordsDrawArrays():this.getTexCoords();this.getTexCoordBuffer().update(e,2*this.getRenderNbVertices())}}},{key:"updateIndexBuffer",value:function(){if(!this.isUsingDrawArrays()){var e=this.isUsingTexCoords()?this.getTrianglesTexCoord():this.getTriangles();this.getIndexBuffer().update(e,3*this.getNbTriangles())}}},{key:"updateWireframeBuffer",value:function(){this.getShowWireframe()&&this.getWireframeBuffer().update(this.getWireframe(),2*this.getNbEdges())}},{key:"updateGeometryBuffers",value:function(){this.updateVertexBuffer(),this.updateNormalBuffer()}},{key:"updateBuffers",value:function(){this.updateGeometryBuffers(),this.updateColorBuffer(),this.updateMaterialBuffer(),this.updateTexCoordBuffer(),this.updateIndexBuffer(),this.updateWireframeBuffer()}},{key:"release",value:function(){this.getTexture0()&&this.getGL().deleteTexture(this.getTexture0()),this.getVertexBuffer().release(),this.getNormalBuffer().release(),this.getColorBuffer().release(),this.getMaterialBuffer().release(),this.getIndexBuffer().release(),this.getWireframeBuffer().release()}},{key:"copyRenderConfig",value:function(e){this.setFlatShading(e.getFlatShading()),this.setShowWireframe(e.getShowWireframe()),this.setShaderType(e.getShaderType()),this.setMatcap(e.getMatcap()),this.setTexture0(e.getTexture0()),this.setCurvature(e.getCurvature()),this.setOpacity(e.getOpacity())}},{key:"copyTransformData",value:function(e){i.JG(this.getCenter(),e.getCenter()),l.JG(this.getMatrix(),e.getMatrix()),l.JG(this.getEditMatrix(),e.getEditMatrix()),i.JG(this.getSymmetryNormal(),e.getSymmetryNormal())}},{key:"copyData",value:function(e){this.setVertices(e.getVertices().slice()),this.setFaces(e.getFaces().slice()),this.setColors(e.getColors().slice()),this.setMaterials(e.getMaterials().slice()),e.hasUV()&&this.initTexCoordsDataFromOBJData(e.getTexCoords(),e.getFacesTexCoord()),this.init(),this.initRender(),this.copyTransformData(e),this.copyRenderConfig(e)}},{key:"optimize",value:function(){0!==this.getNbFaces()&&e.OPTIMIZE&&(this.optimizePostTransform(),this.optimizePreTransform(),this.initFaceRings())}},{key:"computeCacheScore",value:function(){var e=this.getFaces(),t=this.getNbFaces(),r=[];r.length=32;for(var i=0,n=0,a=0;a<t;++a)for(var s=3*a,l=e[s+3]!==o.Z.TRI_INDEX?4:3,u=0;u<l;++u){var c=e[s+u];for(n=0;n<32;++n){if(void 0===r[n]){r[n]=c,i++;break}if(r[n]===c)break}32===n&&(i++,r.shift(),r.push(c))}return{ACMR:i/t,ACTVR:i/this.getNbVertices()}}},{key:"optimizePostTransform",value:function(){var e=0,t=this.hasUV(),r=this.getFaces(),i=t?this.getFacesTexCoord():r,n=this.getNbFaces(),a=this.getNbVertices(),s=t?this.getNbTexCoords():a,l=this.getVerticesDuplicateStartCount(),u=new Uint32Array(s-a);if(t)for(e=0;e<s;++e)for(var c=l[2*e],h=c+l[2*e+1],d=c;d<h;++d)u[d-a]=e;var f=this.getVerticesRingFaceStartCount(),_=this.getVerticesRingFace(),p=new Int32Array(s);for(e=0;e<a;++e)p[e]=f[2*e+1];for(e=a;e<s;++e)p[e]=f[2*u[e-a]+1];for(var g=new Uint32Array(s),m=33,v=0,y=new Uint32Array(o.Z.getMemory(4*n*4),0,4*n),b=0,T=new Uint8Array(n),M=new Uint32Array(4*n),S=t?new Uint32Array(4*n):M,k=0,E=0;E>=0;){var A=[],C=E>=a?u[E-a]:E,w=f[2*C],R=w+f[2*C+1];for(e=w;e<R;++e){var x=_[e];if(!T[x]){T[x]=1;var P=4*x,D=y[b++]=M[k++]=i[P],I=y[b++]=M[k++]=i[P+1],F=y[b++]=M[k++]=i[P+2],O=M[k++]=i[P+3],L=O!==o.Z.TRI_INDEX;t&&(S[k-4]=r[P],S[k-3]=r[P+1],S[k-2]=r[P+2],S[k-1]=r[P+3]),A.push(D,I,F),--p[D],--p[I],--p[F],m-g[D]>32&&(g[D]=m++),m-g[I]>32&&(g[I]=m++),m-g[F]>32&&(g[F]=m++),L&&(y[b++]=O,A.push(O),--p[O],m-g[O]>32&&(g[O]=m++))}}E=-1;var V=-1,N=A.length;for(e=0;e<N;++e){var B=A[e],U=p[B];if(!(U<=0)){var Z=0,G=m-g[B];G+2*U<=32&&(Z=G),Z>V&&(V=Z,E=B)}}if(-1===E){for(;b>0;){var W=y[--b];if(p[W]>0){E=W;break}}if(-1===E)for(;v<s;)if(p[v++]>0){E=v-1;break}}}i.set(M.subarray(0,4*n)),t&&r.set(S.subarray(0,4*n))}},{key:"optimizePreTransform",value:function(){var e=this.getVertices(),t=this.getColors(),r=this.getMaterials(),i=this.getNbVertices(),n=this.getFaces(),a=4*this.getNbFaces(),s=new Float32Array(3*i),l=new Float32Array(3*i),u=new Float32Array(3*i),c=new Uint32Array(i),h=0,d=0;for(d=0;d<a;++d){var f=n[d];if(f!==o.Z.TRI_INDEX){var _=c[f]-1;if(-1===_){var p=3*h,g=3*f;s[p]=e[g],s[p+1]=e[g+1],s[p+2]=e[g+2],l[p]=t[g],l[p+1]=t[g+1],l[p+2]=t[g+2],u[p]=r[g],u[p+1]=r[g+1],u[p+2]=r[g+2],_=h++,c[f]=_+1}n[d]=_}}var m=i-h;if(m>0&&this.setNbVertices(h),this.hasUV()){var v=this.getFacesTexCoord();for(d=0;d<a;++d){var y=v[d];y<i?v[d]=c[y]-1:y!==o.Z.TRI_INDEX&&(v[d]-=m)}var b=this.getNbTexCoords(),T=this.getNbTexCoords()-m,M=this.getTexCoords(),S=new Float32Array(2*T),k=new Uint32Array(2*h),E=this.getVerticesDuplicateStartCount();for(d=0;d<i;++d){var A=2*d,C=E[A],w=2*(c[d]-1);w<0||(C>0&&(k[w]=C-m,k[w+1]=E[A+1]),S[w]=M[A],S[w+1]=M[A+1])}for(d=i;d<b;++d){var R=2*d,x=2*(d-m);S[x]=M[R],S[x+1]=M[R+1]}this.setVerticesDuplicateStartCount(k),this.setTexCoords(S)}e.set(s),t.set(l),r.set(u)}}])&&qt(t.prototype,r),n&&qt(t,n),e}();Jt.OPTIMIZE=!0,Jt.ID=0;const Qt=Jt,$t=function(){return{_center:i.Ue(),_matrix:l.Ue(),_editMatrix:l.Ue(),_symmetryNormal:[1,0,0],_symmetryOffset:0,_lastComputedMV:l.Ue(),_lastComputedMVP:l.Ue(),_lastComputedN:h(),_lastComputedEN:h(),_lastComputedDepth:0,_lastWorldBound:[1/0,1/0,1/0,-1/0,-1/0,-1/0]}},er=function(){return{_nbVertices:0,_nbFaces:0,_nbTexCoords:0,_verticesXYZ:null,_normalsXYZ:null,_colorsRGB:null,_materialsPBR:null,_vertOnEdge:null,_vertRingFace:null,_vrfStartCount:null,_vrvStartCount:null,_vertRingVert:null,_vertTagFlags:null,_vertSculptFlags:null,_vertStateFlags:null,_vertProxy:null,_facesABCD:null,_faceEdges:null,_faceNormalsXYZ:null,_facesToTriangles:null,_trianglesABC:null,_facesTagFlags:null,_edges:null,_drawArraysWireframe:null,_drawElementsWireframe:null,_texCoordsST:null,_duplicateStartCount:null,_UVfacesABCD:null,_UVtrianglesABC:null,_DAverticesXYZ:null,_DAnormalsXYZ:null,_DAcolorsRGB:null,_DAmaterialsPBR:null,_DAtexCoordsST:null,_octree:null,_faceBoxes:null,_faceCentersXYZ:null,_facePosInLeaf:null,_faceLeaf:[],_leavesToUpdate:[],_worldBound:[1/0,1/0,1/0,-1/0,-1/0,-1/0]}};function tr(e){return(tr="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 rr(e,t){return(rr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ir(e,t){return!t||"object"!==tr(t)&&"function"!=typeof t?nr(e):t}function nr(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ar(e){return(ar=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const sr=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&rr(e,t)}(n,e);var t,r,i=(t=n,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,i=ar(t);if(r){var n=ar(this).constructor;e=Reflect.construct(i,arguments,n)}else e=i.apply(this,arguments);return ir(this,e)});function n(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(t=i.call(this))._id=Qt.ID++,e&&(t._renderData=new Yt(e,nr(t))),t._meshData=new er,t._transformData=new $t,t}return n}(Qt);function or(e){return(or="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 lr(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function ur(e,t){return(ur=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function cr(e,t){return!t||"object"!==or(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function hr(e){return(hr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const dr=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ur(e,t)}(l,e);var t,r,n,a,s=(n=l,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=hr(n);if(a){var r=hr(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return cr(this,e)});function l(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(t=s.call(this,e))._radius=50,t._hardness=.25,t._intensity=1,t._negative=!0,t._culling=!1,t._idAlpha=0,t._lockPosition=!1,t._thickness=1,t}return t=l,(r=[{key:"pushState",value:function(){this._main.getStateManager().pushStateColorAndMaterial(this.getMesh())}},{key:"updateMeshBuffers",value:function(){var e=this.getMesh();e.isDynamic?e.updateBuffers():e.updateMaterialBuffer()}},{key:"stroke",value:function(e){Nt.prototype.stroke.call(this,e)}},{key:"dynamicTopology",value:function(e){return e.getPickedVertices()}},{key:"paint",value:function(e,t,r,i,n,a){for(var s=this.getMesh(),o=s.getVertices(),l=s.getMaterials(),u=Math.sqrt(r),c=t[0],h=t[1],d=t[2],f=2*(1-n),_=this._negative?-i:i,p=0,g=e.length;p<g;++p){var m=3*e[p],v=o[m],y=o[m+1],b=o[m+2],T=v-c,M=y-h,S=b-d,k=Math.sqrt(T*T+M*M+S*S)/u;k>1&&(k=1);var E=Math.pow(1-k,f);E*=_*a.getAlpha(v,y,b),l[m+2]=Math.min(Math.max(l[m+2]+E,0),1)}}},{key:"updateAndRenderMask",value:function(){var e=this.getMesh();e.updateDuplicateColorsAndMaterials(),e.updateDrawArrays(),this.updateRender()}},{key:"blur",value:function(){var e=this.getMesh(),t=this.getMaskedVertices();if(0!==t.length){t=e.expandsVertices(t,1),this.pushState(),this._main.getStateManager().pushVertices(t);var r=e.getMaterials(),i=t.length,n=new Float32Array(3*i);this.laplacianSmooth(t,n,r);for(var a=0;a<i;++a)r[3*t[a]+2]=n[3*a+2];this.updateAndRenderMask()}}},{key:"sharpen",value:function(){var e=this.getMesh(),t=this.getMaskedVertices();if(0!==t.length){this.pushState(),this._main.getStateManager().pushVertices(t);for(var r=e.getMaterials(),i=t.length,n=0;n<i;++n){var a=3*t[n]+2,s=r[a];r[a]=s>.5?Math.min(s+.1,1):Math.max(s-1,0)}this.updateAndRenderMask()}}},{key:"clear",value:function(){var e=this.getMesh(),t=this.getMaskedVertices();if(0!==t.length){this.pushState(),this._main.getStateManager().pushVertices(t);for(var r=e.getMaterials(),i=0,n=t.length;i<n;++i)r[3*t[i]+2]=1;this.updateAndRenderMask()}}},{key:"invert",value:function(e,t){var r=t;r||(r=this.getMesh()),e||this._main.getStateManager().pushStateCustom(this.invert.bind(this,!0,r));for(var i=r.getMaterials(),n=0,a=r.getNbVertices();n<a;++n)i[3*n+2]=1-i[3*n+2];this.updateAndRenderMask()}},{key:"remapAndMirrorIndices",value:function(e,t,r){var i=this.getMesh().getNbVertices(),n=new Uint32Array(o.Z.getMemory(4*i),0,i),a=0,s=0,l=r.length;for(a=0;a<l;++a)n[r[a]]=a;var u=2*t;for(a=0;a<u;++a){var c=a<t?0:l;e[s=4*a]=n[e[s]]+c,e[s+1]=n[e[s+1]]+c,e[s+2]=n[e[s+2]]+c;var h=e[s+3];h!==o.Z.TRI_INDEX&&(e[s+3]=n[h]+c)}var d=e.length/4;for(a=u;a<d;++a)e[s=4*a]=n[e[s]],e[s+1]=n[e[s+1]],e[s+2]=n[e[s+2]]+l,e[s+3]=n[e[s+3]]+l}},{key:"invertFaces",value:function(e){for(var t=0,r=e.length/4;t<r;++t){var i=4*t,n=e[i];e[i]=e[i+2],e[i+2]=n}}},{key:"extractFaces",value:function(e,t,r){for(var i=this.getMesh(),n=i.getFaces(),a=i.getMaterials(),s=i.getVerticesOnEdge(),l=0===this._thickness,u=e.length,c=new Uint32Array(o.Z.getMemory(4*u*4*3),0,4*u*3),h=l?u:2*u,d=0;d<u;++d){var f=4*d,_=4*e[d],p=c[f]=n[_],g=c[f+1]=n[_+1],m=c[f+2]=n[_+2],v=c[f+3]=n[_+3];if(!l){var y=v!==o.Z.TRI_INDEX,b=a[3*p+2]>=r||s[p]>=1,T=a[3*g+2]>=r||s[g]>=1,M=a[3*m+2]>=r||s[m]>=1,S=!!y&&(a[3*v+2]>=r||s[v]>=1);c[f+=4*u]=m,c[f+1]=g,c[f+2]=p,c[f+3]=v,T&&(b&&(c[f=4*h++]=c[f+3]=g,c[f+1]=c[f+2]=p),M&&(c[f=4*h++]=c[f+3]=m,c[f+1]=c[f+2]=g)),y?S&&(b&&(c[f=4*h++]=c[f+3]=p,c[f+1]=c[f+2]=v),M&&(c[f=4*h++]=c[f+3]=v,c[f+1]=c[f+2]=m)):b&&M&&(c[f=4*h++]=c[f+3]=p,c[f+1]=c[f+2]=m)}}var k=new Uint32Array(c.subarray(0,4*h));return this.remapAndMirrorIndices(k,u,t),this._thickness>0&&this.invertFaces(k),k}},{key:"extractVertices",value:function(e){var t=this.getMesh(),r=t.getVertices(),n=t.getNormals(),a=t.getMatrix(),s=_(h(),a),o=e.length,l=new Float32Array(2*o*3),u=[0,0,0],c=[0,0,0],d=3*o,f=this._thickness,p=.01;f<0&&(p=-p);for(var g=0;g<o;++g){var m=3*g,v=3*e[g];u[0]=r[v],u[1]=r[v+1],u[2]=r[v+2],c[0]=n[v],c[1]=n[v+1],c[2]=n[v+2],i.kK(c,c,s),i.Fv(c,c),i.fF(u,u,a),i.od(u,u,c,p),l[m]=u[0],l[m+1]=u[1],l[m+2]=u[2],i.od(u,u,c,f),l[m+=d]=u[0],l[m+1]=u[1],l[m+2]=u[2]}return l}},{key:"smoothBorder",value:function(e,t){for(var r=2*t.length,i=new Uint32Array(e.getNbFaces()-r),n=0,a=i.length;n<a;++n)i[n]=r+n;var s=e.expandsVertices(e.getVerticesFromFaces(i),1),o=new ft;o.setToolMesh(e),o.smooth(s,1),o.smooth(s,1),o.smooth(s,1)}},{key:"extract",value:function(){var e=this.getMesh(),t=this.filterMaskedVertices(-1/0,.5);if(0!==t.length){var r=e.getFacesFromVertices(t);t=e.getVerticesFromFaces(r);var i=this.extractFaces(r,t,.5),n=this.extractVertices(t),a=new sr(e.getGL());a.setVertices(n),a.setFaces(i),a.initColorsAndMaterials(),a.allocateArrays(),a.initTopology(),0!==this._thickness&&this.smoothBorder(a,r),a.updateGeometry(),a.updateDuplicateColorsAndMaterials(),a.copyRenderConfig(e),a.initRender();var s=this._main;s.addNewMesh(a),s.setMesh(e)}}}])&&lr(t.prototype,r),l}(Te);function fr(e){return(fr="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 _r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function pr(e,t){return(pr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function gr(e,t){return!t||"object"!==fr(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function mr(e){return(mr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const vr=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&pr(e,t)}(s,e);var t,r,i,n,a=(i=s,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=mr(i);if(n){var r=mr(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return gr(this,e)});function s(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),(t=a.call(this,e))._radius=50,t._culling=!1,t._idAlpha=0,t}return t=s,(r=[{key:"startSculpt",value:function(){var e=this._main;if(e.getSculptManager().getSymmetry()){var t=e.getPickingSymmetry();t.intersectionMouseMesh(),t.setLocalRadius2(e.getPicking().getLocalRadius2())}}},{key:"sculptStroke",value:function(){var e=this._main,t=e._mouseX-e._lastMouseX,r=e.getPicking(),i=r.getLocalRadius2();if(r.pickVerticesInSphere(i),this.stroke(r,t),e.getSculptManager().getSymmetry()){var n=e.getPickingSymmetry();n.getMesh()&&(n.pickVerticesInSphere(i),this.stroke(n,t))}this.updateRender()}},{key:"stroke",value:function(e,t){var r=e.getPickedVertices();this._main.getStateManager().pushVertices(r),r=this.dynamicTopology(e),this._culling&&(r=this.getFrontVertices(r,e.getEyeDirection())),e.updateAlpha(!1),e.setIdAlpha(this._idAlpha),this.scale(r,e.getIntersectionPoint(),e.getLocalRadius2(),t,e);var i=this.getMesh();i.updateGeometry(i.getFacesFromVertices(r),r)}},{key:"scale",value:function(e,t,r,i,n){for(var a=this.getMesh(),s=a.getVertices(),o=a.getMaterials(),l=.01*i,u=Math.sqrt(r),c=t[0],h=t[1],d=t[2],f=0,_=e.length;f<_;++f){var p=3*e[f],g=s[p],m=s[p+1],v=s[p+2],y=g-c,b=m-h,T=v-d,M=Math.sqrt(y*y+b*b+T*T)/u,S=M*M;S=3*S*S-4*S*M+1,S*=l*o[p+2]*n.getAlpha(g,m,v),s[p]=g+y*S,s[p+1]=m+b*S,s[p+2]=v+T*S}}}])&&_r(t.prototype,r),s}(Te);var yr=function(e,t){this.previous=null,this.next=null,this.v1=e,this.v2=t},br=function(e){if(!(e.length<=2)){var t=e.length,r=e[0].v1,i=e[0].v2,n=e[0],a=n;e[0]=e[--t];for(var s=0;s<t;){var o=e[s];if(o.v1===i){if(o.previous=a,a.next=o,a=o,i=e[s].v2,e[s]=e[--t],i===r)break;s=0}else s++}if(e.length=t,i===r)return n.previous=a,a.next=n,n}},Tr=function(e,t,r,i,n,a){var s=e.getVertices(),l=e.getColors(),u=e.getMaterials(),c=e.getNbVertices()+i.length/3,h=t,d=0,f=0,_=0,p=0,g=0,m=0,v=0,y=0,b=0,T=0;do{var M=h.next,S=h.v1,k=h.v2,E=M.v2;r.push(S,k,c,o.Z.TRI_INDEX),k*=3,E*=3,T++,d+=s[S*=3],f+=s[S+1],_+=s[S+2],p+=l[S],g+=l[S+1],m+=l[S+2],v+=u[S],y+=u[S+1],b+=u[S+2];var A=s[k],C=s[k+1],w=s[k+2],R=s[S]-A,x=s[S+1]-C,P=s[S+2]-w,D=s[E]-A,I=s[E+1]-C,F=s[E+2]-w,O=R*R+x*x+P*P,L=D*D+I*I+F*F;h.angle=Math.acos((R*D+x*I+P*F)/Math.sqrt(O*L)),h=M}while(h!==t);i.push(d/T,f/T,_/T),n.push(p/T,g/T,m/T),a.push(v/T,y/T,b/T)},Mr=function(e,t,r,i,n){var a=new sr;return a.setID(e.getID()),a.setVertices(t),i&&a.setColors(i),n&&a.setMaterials(n),a.setFaces(r),a.setTransformData(e.getTransformData()),a.setRenderData(e.getRenderData()),Qt.OPTIMIZE=!1,a.init(),Qt.OPTIMIZE=!0,a};const Sr={createClosedMesh:function(e){var t=function(e){var t=function(e){for(var t=e.getEdges(),r=e.getFaces(),i=e.getFaceEdges(),n=[],a=0,s=e.getNbFaces();a<s;++a){var l=4*a,u=i[l+3],c=u!==o.Z.TRI_INDEX;1===t[i[l]]&&n.push(new yr(r[l],r[l+1])),1===t[i[l+1]]&&n.push(new yr(r[l+1],r[l+2])),1===t[i[l+2]]&&n.push(new yr(r[l+2],r[c?l+3:l])),c&&1===t[u]&&n.push(new yr(r[l+3],r[l]))}for(var h=[];;){var d=br(n);if(!d)break;h.push(d)}return h}(e);if(0===t.length)return e;for(var r=[],i=[],n=[],a=[],s=0,l=t.length;s<l;++s)Tr(e,t[s],r,i,n,a);var u=3*e.getNbVertices(),c=u+i.length,h=new Float32Array(c);h.set(e.getVertices().subarray(0,u));var d=new Float32Array(c);d.set(e.getColors().subarray(0,u));var f=new Float32Array(c);f.set(e.getMaterials().subarray(0,u)),c>u&&(h.set(i,u),d.set(n,u),f.set(a,u));var _=new Uint32Array(4*e.getNbFaces()+r.length);return _.set(e.getFaces()),r.length>0&&_.set(r,4*e.getNbFaces()),Mr(e,h,_,d,f)}(e);if(t===e){var r=3*e.getNbVertices(),i=4*e.getNbFaces(),n=new Uint32Array(e.getFaces().subarray(0,i)),a=new Float32Array(e.getVertices().subarray(0,r)),s=new Float32Array(e.getColors().subarray(0,r)),l=new Float32Array(e.getMaterials().subarray(0,r));t=Mr(e,a,n,s,l)}return t}};var kr={BLOCK:!1},Er=function(){for(var e=new Uint32Array(24),t=0,r=0;r<8;++r)for(var i=1;i<=4;i<<=1){var n=r^i;r<=n&&(e[t++]=r,e[t++]=n)}return e}(),Ar=function(e){for(var t=new Uint32Array(256),r=0;r<256;++r){for(var i=0,n=0;n<24;n+=2)i|=!!(r&1<<e[n])!=!!(r&1<<e[n+1])?1<<(n>>1):0;t[r]=i}return t}(Er),Cr=function(e,t,r,i,n,a){for(var s=e.colorField,o=e.materialField,l=e.distanceField,u=0,c=0,h=0,d=0,f=0,_=0,p=0,g=0,m=0,v=r[0],y=r[0]*r[1],b=0;b<2;++b)for(var T=0;T<2;++T)for(var M=0;M<2;++M){var S=i+M+T*v+b*y,k=3*S,E=l[S];t[m]=E,g|=E<0?1<<m:0,m++,E!==1/0&&(p+=E=Math.min(1/Math.abs(E),1e15),u+=s[k]*E,c+=s[k+1]*E,h+=s[k+2]*E,d+=o[k]*E,f+=o[k+1]*E,_+=o[k+2]*E)}return 0!==g&&255!==g&&(p>0&&(p=1/p),n.push(u*p,c*p,h*p),a.push(d*p,f*p,_*p)),g},wr=[0,0,0],Rr=function(e,t,r,i,n){wr[0]=wr[1]=wr[2]=0;for(var a=0,s=0;s<12;++s)if(e&1<<s&&(++a,!kr.BLOCK)){var o=t[s<<1],l=t[1+(s<<1)],u=r[o],c=u-r[l];if(!(Math.abs(c)<1e-7)){c=u/c;for(var h=0,d=1;h<3;++h,d<<=1){var f=o&d;wr[h]+=f!==(l&d)?f?1-c:c:f?1:0}}}for(var _=1/a,p=0;p<3;++p)wr[p]=i[p]+_*wr[p];n.push(wr[0],wr[1],wr[2])},xr=function(e,t,r,i,n,a,s){for(var o=0;o<3;++o)if(e&1<<o){var l=(o+1)%3,u=(o+2)%3;if(0!==a[l]&&0!==a[u]){var c=i[l],h=i[u];1&t?s.push(r[n],r[n-c],r[n-c-h],r[n-h]):s.push(r[n],r[n-h],r[n-c-h],r[n-c])}}};kr.computeSurface=function(e){var t=e.dims,r=[],i=[],n=[],a=[],s=0,o=new Int32Array(3),l=new Int32Array([1,t[0]+1,(t[0]+1)*(t[1]+1)]),u=new Float32Array(8),c=1,h=new Int32Array(2*l[2]);for(o[2]=0;o[2]<t[2]-1;++o[2],s+=t[0],c^=1,l[2]=-l[2]){var d=1+(t[0]+1)*(1+c*(t[1]+1));for(o[1]=0;o[1]<t[1]-1;++o[1],++s,d+=2)for(o[0]=0;o[0]<t[0]-1;++o[0],++s,++d){var f=Cr(e,u,t,s,i,n);if(0!==f&&255!==f){var _=Ar[f];h[d]=r.length/3,Rr(_,Er,u,o,r),xr(_,f,h,l,d,o,a)}}}return{colors:new Float32Array(i),materials:new Float32Array(n),vertices:new Float32Array(r),faces:new Uint32Array(a)}};const Pr=kr;var Dr={BLOCK:!1},Ir=new Uint32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]),Fr=[[],[0,8,3],[0,1,9],[1,8,3,9,8,1],[1,2,10],[0,8,3,1,2,10],[9,2,10,0,2,9],[2,8,3,2,10,8,10,9,8],[3,11,2],[0,11,2,8,11,0],[1,9,0,2,3,11],[1,11,2,1,9,11,9,8,11],[3,10,1,11,10,3],[0,10,1,0,8,10,8,11,10],[3,9,0,3,11,9,11,10,9],[9,8,10,10,8,11],[4,7,8],[4,3,0,7,3,4],[0,1,9,8,4,7],[4,1,9,4,7,1,7,3,1],[1,2,10,8,4,7],[3,4,7,3,0,4,1,2,10],[9,2,10,9,0,2,8,4,7],[2,10,9,2,9,7,2,7,3,7,9,4],[8,4,7,3,11,2],[11,4,7,11,2,4,2,0,4],[9,0,1,8,4,7,2,3,11],[4,7,11,9,4,11,9,11,2,9,2,1],[3,10,1,3,11,10,7,8,4],[1,11,10,1,4,11,1,0,4,7,11,4],[4,7,8,9,0,11,9,11,10,11,0,3],[4,7,11,4,11,9,9,11,10],[9,5,4],[9,5,4,0,8,3],[0,5,4,1,5,0],[8,5,4,8,3,5,3,1,5],[1,2,10,9,5,4],[3,0,8,1,2,10,4,9,5],[5,2,10,5,4,2,4,0,2],[2,10,5,3,2,5,3,5,4,3,4,8],[9,5,4,2,3,11],[0,11,2,0,8,11,4,9,5],[0,5,4,0,1,5,2,3,11],[2,1,5,2,5,8,2,8,11,4,8,5],[10,3,11,10,1,3,9,5,4],[4,9,5,0,8,1,8,10,1,8,11,10],[5,4,0,5,0,11,5,11,10,11,0,3],[5,4,8,5,8,10,10,8,11],[9,7,8,5,7,9],[9,3,0,9,5,3,5,7,3],[0,7,8,0,1,7,1,5,7],[1,5,3,3,5,7],[9,7,8,9,5,7,10,1,2],[10,1,2,9,5,0,5,3,0,5,7,3],[8,0,2,8,2,5,8,5,7,10,5,2],[2,10,5,2,5,3,3,5,7],[7,9,5,7,8,9,3,11,2],[9,5,7,9,7,2,9,2,0,2,7,11],[2,3,11,0,1,8,1,7,8,1,5,7],[11,2,1,11,1,7,7,1,5],[9,5,8,8,5,7,10,1,3,10,3,11],[5,7,0,5,0,9,7,11,0,1,0,10,11,10,0],[11,10,0,11,0,3,10,5,0,8,0,7,5,7,0],[11,10,5,7,11,5],[10,6,5],[0,8,3,5,10,6],[9,0,1,5,10,6],[1,8,3,1,9,8,5,10,6],[1,6,5,2,6,1],[1,6,5,1,2,6,3,0,8],[9,6,5,9,0,6,0,2,6],[5,9,8,5,8,2,5,2,6,3,2,8],[2,3,11,10,6,5],[11,0,8,11,2,0,10,6,5],[0,1,9,2,3,11,5,10,6],[5,10,6,1,9,2,9,11,2,9,8,11],[6,3,11,6,5,3,5,1,3],[0,8,11,0,11,5,0,5,1,5,11,6],[3,11,6,0,3,6,0,6,5,0,5,9],[6,5,9,6,9,11,11,9,8],[5,10,6,4,7,8],[4,3,0,4,7,3,6,5,10],[1,9,0,5,10,6,8,4,7],[10,6,5,1,9,7,1,7,3,7,9,4],[6,1,2,6,5,1,4,7,8],[1,2,5,5,2,6,3,0,4,3,4,7],[8,4,7,9,0,5,0,6,5,0,2,6],[7,3,9,7,9,4,3,2,9,5,9,6,2,6,9],[3,11,2,7,8,4,10,6,5],[5,10,6,4,7,2,4,2,0,2,7,11],[0,1,9,4,7,8,2,3,11,5,10,6],[9,2,1,9,11,2,9,4,11,7,11,4,5,10,6],[8,4,7,3,11,5,3,5,1,5,11,6],[5,1,11,5,11,6,1,0,11,7,11,4,0,4,11],[0,5,9,0,6,5,0,3,6,11,6,3,8,4,7],[6,5,9,6,9,11,4,7,9,7,11,9],[10,4,9,6,4,10],[4,10,6,4,9,10,0,8,3],[10,0,1,10,6,0,6,4,0],[8,3,1,8,1,6,8,6,4,6,1,10],[1,4,9,1,2,4,2,6,4],[3,0,8,1,2,9,2,4,9,2,6,4],[0,2,4,4,2,6],[8,3,2,8,2,4,4,2,6],[10,4,9,10,6,4,11,2,3],[0,8,2,2,8,11,4,9,10,4,10,6],[3,11,2,0,1,6,0,6,4,6,1,10],[6,4,1,6,1,10,4,8,1,2,1,11,8,11,1],[9,6,4,9,3,6,9,1,3,11,6,3],[8,11,1,8,1,0,11,6,1,9,1,4,6,4,1],[3,11,6,3,6,0,0,6,4],[6,4,8,11,6,8],[7,10,6,7,8,10,8,9,10],[0,7,3,0,10,7,0,9,10,6,7,10],[10,6,7,1,10,7,1,7,8,1,8,0],[10,6,7,10,7,1,1,7,3],[1,2,6,1,6,8,1,8,9,8,6,7],[2,6,9,2,9,1,6,7,9,0,9,3,7,3,9],[7,8,0,7,0,6,6,0,2],[7,3,2,6,7,2],[2,3,11,10,6,8,10,8,9,8,6,7],[2,0,7,2,7,11,0,9,7,6,7,10,9,10,7],[1,8,0,1,7,8,1,10,7,6,7,10,2,3,11],[11,2,1,11,1,7,10,6,1,6,7,1],[8,9,6,8,6,7,9,1,6,11,6,3,1,3,6],[0,9,1,11,6,7],[7,8,0,7,0,6,3,11,0,11,6,0],[7,11,6],[7,6,11],[3,0,8,11,7,6],[0,1,9,11,7,6],[8,1,9,8,3,1,11,7,6],[10,1,2,6,11,7],[1,2,10,3,0,8,6,11,7],[2,9,0,2,10,9,6,11,7],[6,11,7,2,10,3,10,8,3,10,9,8],[7,2,3,6,2,7],[7,0,8,7,6,0,6,2,0],[2,7,6,2,3,7,0,1,9],[1,6,2,1,8,6,1,9,8,8,7,6],[10,7,6,10,1,7,1,3,7],[10,7,6,1,7,10,1,8,7,1,0,8],[0,3,7,0,7,10,0,10,9,6,10,7],[7,6,10,7,10,8,8,10,9],[6,8,4,11,8,6],[3,6,11,3,0,6,0,4,6],[8,6,11,8,4,6,9,0,1],[9,4,6,9,6,3,9,3,1,11,3,6],[6,8,4,6,11,8,2,10,1],[1,2,10,3,0,11,0,6,11,0,4,6],[4,11,8,4,6,11,0,2,9,2,10,9],[10,9,3,10,3,2,9,4,3,11,3,6,4,6,3],[8,2,3,8,4,2,4,6,2],[0,4,2,4,6,2],[1,9,0,2,3,4,2,4,6,4,3,8],[1,9,4,1,4,2,2,4,6],[8,1,3,8,6,1,8,4,6,6,10,1],[10,1,0,10,0,6,6,0,4],[4,6,3,4,3,8,6,10,3,0,3,9,10,9,3],[10,9,4,6,10,4],[4,9,5,7,6,11],[0,8,3,4,9,5,11,7,6],[5,0,1,5,4,0,7,6,11],[11,7,6,8,3,4,3,5,4,3,1,5],[9,5,4,10,1,2,7,6,11],[6,11,7,1,2,10,0,8,3,4,9,5],[7,6,11,5,4,10,4,2,10,4,0,2],[3,4,8,3,5,4,3,2,5,10,5,2,11,7,6],[7,2,3,7,6,2,5,4,9],[9,5,4,0,8,6,0,6,2,6,8,7],[3,6,2,3,7,6,1,5,0,5,4,0],[6,2,8,6,8,7,2,1,8,4,8,5,1,5,8],[9,5,4,10,1,6,1,7,6,1,3,7],[1,6,10,1,7,6,1,0,7,8,7,0,9,5,4],[4,0,10,4,10,5,0,3,10,6,10,7,3,7,10],[7,6,10,7,10,8,5,4,10,4,8,10],[6,9,5,6,11,9,11,8,9],[3,6,11,0,6,3,0,5,6,0,9,5],[0,11,8,0,5,11,0,1,5,5,6,11],[6,11,3,6,3,5,5,3,1],[1,2,10,9,5,11,9,11,8,11,5,6],[0,11,3,0,6,11,0,9,6,5,6,9,1,2,10],[11,8,5,11,5,6,8,0,5,10,5,2,0,2,5],[6,11,3,6,3,5,2,10,3,10,5,3],[5,8,9,5,2,8,5,6,2,3,8,2],[9,5,6,9,6,0,0,6,2],[1,5,8,1,8,0,5,6,8,3,8,2,6,2,8],[1,5,6,2,1,6],[1,3,6,1,6,10,3,8,6,5,6,9,8,9,6],[10,1,0,10,0,6,9,5,0,5,6,0],[0,3,8,5,6,10],[10,5,6],[11,5,10,7,5,11],[11,5,10,11,7,5,8,3,0],[5,11,7,5,10,11,1,9,0],[10,7,5,10,11,7,9,8,1,8,3,1],[11,1,2,11,7,1,7,5,1],[0,8,3,1,2,7,1,7,5,7,2,11],[9,7,5,9,2,7,9,0,2,2,11,7],[7,5,2,7,2,11,5,9,2,3,2,8,9,8,2],[2,5,10,2,3,5,3,7,5],[8,2,0,8,5,2,8,7,5,10,2,5],[9,0,1,5,10,3,5,3,7,3,10,2],[9,8,2,9,2,1,8,7,2,10,2,5,7,5,2],[1,3,5,3,7,5],[0,8,7,0,7,1,1,7,5],[9,0,3,9,3,5,5,3,7],[9,8,7,5,9,7],[5,8,4,5,10,8,10,11,8],[5,0,4,5,11,0,5,10,11,11,3,0],[0,1,9,8,4,10,8,10,11,10,4,5],[10,11,4,10,4,5,11,3,4,9,4,1,3,1,4],[2,5,1,2,8,5,2,11,8,4,5,8],[0,4,11,0,11,3,4,5,11,2,11,1,5,1,11],[0,2,5,0,5,9,2,11,5,4,5,8,11,8,5],[9,4,5,2,11,3],[2,5,10,3,5,2,3,4,5,3,8,4],[5,10,2,5,2,4,4,2,0],[3,10,2,3,5,10,3,8,5,4,5,8,0,1,9],[5,10,2,5,2,4,1,9,2,9,4,2],[8,4,5,8,5,3,3,5,1],[0,4,5,1,0,5],[8,4,5,8,5,3,9,0,5,0,3,5],[9,4,5],[4,11,7,4,9,11,9,10,11],[0,8,3,4,9,7,9,11,7,9,10,11],[1,10,11,1,11,4,1,4,0,7,4,11],[3,1,4,3,4,8,1,10,4,7,4,11,10,11,4],[4,11,7,9,11,4,9,2,11,9,1,2],[9,7,4,9,11,7,9,1,11,2,11,1,0,8,3],[11,7,4,11,4,2,2,4,0],[11,7,4,11,4,2,8,3,4,3,2,4],[2,9,10,2,7,9,2,3,7,7,4,9],[9,10,7,9,7,4,10,2,7,8,7,0,2,0,7],[3,7,10,3,10,2,7,4,10,1,10,0,4,0,10],[1,10,2,8,7,4],[4,9,1,4,1,7,7,1,3],[4,9,1,4,1,7,0,8,1,8,7,1],[4,0,3,7,4,3],[4,8,7],[9,10,8,10,11,8],[3,0,9,3,9,11,11,9,10],[0,1,10,0,10,8,8,10,11],[3,1,10,11,3,10],[1,2,11,1,11,9,9,11,8],[3,0,9,3,9,11,1,2,9,2,11,9],[0,2,11,8,0,11],[3,2,11],[2,3,8,2,8,10,10,8,9],[9,10,2,0,9,2],[2,3,8,2,8,10,0,1,8,1,10,8],[1,10,2],[1,3,8,9,1,8],[0,9,1],[0,3,8],[]],Or=[[0,0,0],[1,0,0],[1,1,0],[0,1,0],[0,0,1],[1,0,1],[1,1,1],[0,1,1]],Lr=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],Vr=function(e,t,r,i,n,a){for(var s=e.colorField,o=e.materialField,l=e.distanceField,u=0,c=0,h=0,d=0,f=0,_=0,p=0,g=0,m=r[0],v=r[0]*r[1],y=0;y<8;++y){var b=Or[y],T=i+b[0]+b[1]*m+b[2]*v,M=3*T,S=l[T];t[y]=S,g|=S>0?1<<y:0,S!==1/0&&(p+=S=Math.min(1/Math.abs(S),1e15),u+=s[M]*S,c+=s[M+1]*S,h+=s[M+2]*S,d+=o[M]*S,f+=o[M+1]*S,_+=o[M+2]*S)}return 0!==Ir[g]&&(p>0&&(p=1/p),n[0]=u*p,n[1]=c*p,n[2]=h*p,a[0]=d*p,a[1]=f*p,a[2]=_*p),g};Dr.computeSurface=function(e){var t=e.dims,r=new Map,i=[],n=[],a=[],s=[],l=0,u=new Int32Array(3),c=new Float32Array(8),h=new Array(12),d=new Float32Array(3),f=new Float32Array(3),_=new Float32Array(3);for(u[2]=0;u[2]<t[2]-1;++u[2],l+=t[0])for(u[1]=0;u[1]<t[1]-1;++u[1],++l)for(u[0]=0;u[0]<t[0]-1;++u[0],++l){var p=Vr(e,c,t,l,f,_),g=Ir[p];if(0!==g){for(var m=0;m<12;++m)if(g&1<<m){var v=Lr[m],y=Or[v[0]],b=Or[v[1]],T=c[v[0]],M=T-c[v[1]],S=0;Math.abs(M)>1e-6&&(S=T/M);for(var k=0;k<3;++k)d[k]=u[k]+y[k]+S*(b[k]-y[k]);var E=d[0]+"+"+d[1]+"+"+d[2],A=r.get(E);A>=0?h[m]=A:(h[m]=i.length/3,r.set(E,h[m]),i.push(d[0],d[1],d[2]),n.push(f[0],f[1],f[2]),a.push(_[0],_[1],_[2]))}for(var C=Fr[p],w=0;w<C.length;w+=3)s.push(h[C[w]],h[C[w+1]],h[C[w+2]],o.Z.TRI_INDEX)}}return{colors:new Float32Array(n),materials:new Float32Array(a),vertices:new Float32Array(i),faces:new Uint32Array(s)}};const Nr=Dr;var Br={RESOLUTION:150,BLOCK:!1,SMOOTHING:!0},Ur=function(e,t){for(var r=t.min,i=t.step,n=t.dims,a=1/i,s=r[0],o=r[1],l=r[2],u=n[0],c=u*n[1],h=t.distanceField,d=t.crossedEdges,f=t.colorField,_=t.materialField,p=e.getTriangles(),g=e.getVertices(),m=e.getColors(),v=e.getMaterials(),y=e.getNbTriangles(),b=[0,0,0],T=[0,0,0],M=[0,0,0],S=[0,0,0],k=[0,0,0],E=[0,0,0],A=[0,0,0,0],C=[[1,0,0],[0,1,0],[0,0,1]],w=1/3,R=0;R<y;++R)for(var x=3*R,P=3*p[x],D=3*p[x+1],I=3*p[x+2],F=b[0]=g[P],O=b[1]=g[P+1],L=b[2]=g[P+2],V=T[0]=g[D],N=T[1]=g[D+1],B=T[2]=g[D+2],U=M[0]=g[I],Z=M[1]=g[I+1],G=M[2]=g[I+2],W=(m[P]+m[D]+m[I])*w,j=(m[P+1]+m[D+1]+m[I+1])*w,z=(m[P+2]+m[D+2]+m[I+2])*w,X=(v[P]+v[D]+v[I])*w,K=(v[P+1]+v[D+1]+v[I+1])*w,H=(v[P+2]+v[D+2]+v[I+2])*w,Y=F<V?F<U?F:U:V<U?V:U,q=F>V?F>U?F:U:V>U?V:U,J=O<N?O<Z?O:Z:N<Z?N:Z,Q=O>N?O>Z?O:Z:N>Z?N:Z,$=L<B?L<G?L:G:B<G?B:G,ee=L>B?L>G?L:G:B>G?B:G,te=S[0]=V-F,re=S[1]=N-O,ie=S[2]=B-L,ne=k[0]=U-F,ae=k[1]=Z-O,se=k[2]=G-L,oe=te*te+re*re+ie*ie,le=te*ne+re*ae+ie*se,ue=ne*ne+ae*ae+se*se,ce=Math.floor((Y-s)*a),he=Math.floor((J-o)*a),de=Math.floor(($-l)*a),fe=Math.ceil((q-s)*a),_e=Math.ceil((Q-o)*a),pe=Math.ceil((ee-l)*a),ge=de;ge<=pe;++ge)for(var me=he;me<=_e;++me)for(var ve=ce;ve<=fe;++ve){var ye=s+ve*i,be=o+me*i,Te=l+ge*i,Me=ve+me*u+ge*c;E[0]=ye,E[1]=be,E[2]=Te;var Se=tt.Z.distance2PointTriangleEdges(E,S,k,b,oe,le,ue,A);if((Se=Math.sqrt(Se))<h[Me]){h[Me]=Se;var ke=3*Me;f[ke]=W,f[ke+1]=j,f[ke+2]=z,_[ke]=X,_[ke+1]=K,_[ke+2]=H}if(!(Se>i))for(var Ee=0;Ee<3;++Ee){var Ae=A[Ee]-E[Ee];if(!(Ae<0||Ae>i)){var Ce=3*Me+Ee;if(1!==d[Ce]){var we=tt.Z.intersectionRayTriangleEdges(E,C[Ee],S,k,b);we<0||we>i||(d[Ce]=1)}}}}},Zr=function(e,t,r,i,n){var a=new sr(e.getGL());return a.setID(e.getID()),a.setFaces(t),a.setVertices(r),i&&a.setColors(i),n&&a.setMaterials(n),a.setRenderData(e.getRenderData()),a.init(),a.initRender(),a};Br.remesh=function(e,t,r){console.time("remesh total"),console.time("1. prepareMeshes");var n=function(e){for(var t=[1/0,1/0,1/0,-1/0,-1/0,-1/0],r=[0,0,0],n=0,a=e.length;n<a;++n){var o=e[n];o.isUsingTexCoords()&&o.setShaderType(s.Z.Shader.MATCAP);for(var l=o.getMatrix(),u=(o=e[n]=Sr.createClosedMesh(o)).getVertices(),c=0,h=o.getNbVertices();c<h;++c){var d=3*c;r[0]=u[d],r[1]=u[d+1],r[2]=u[d+2],i.fF(r,r,l);var f=u[d]=r[0],_=u[d+1]=r[1],p=u[d+2]=r[2];f<t[0]&&(t[0]=f),_<t[1]&&(t[1]=_),p<t[2]&&(t[2]=p),f>t[3]&&(t[3]=f),_>t[4]&&(t[4]=_),p>t[5]&&(t[5]=p)}}return t}(e=e.slice());console.timeEnd("1. prepareMeshes"),console.time("2. voxelization");for(var a,u=function(e){for(var t=Math.max(e[3]-e[0],e[4]-e[1],e[5]-e[2])/Br.RESOLUTION,r=1.51*t,i=1.51*t,n=[e[0]-r,e[1]-r,e[2]-r],a=[e[3]+i,e[4]+i,e[5]+i],s=Math.ceil((a[0]-n[0])/t),l=Math.ceil((a[1]-n[1])/t),u=Math.ceil((a[2]-n[2])/t),c=s*l*u,h=o.Z.getMemory(31*c),d=new Float32Array(h,0,c),f=new Float32Array(h,4*c,3*c),_=new Float32Array(h,16*c,3*c),p=new Uint8Array(h,28*c,3*c),g=0;g<c;++g)d[g]=1/0;for(var m=0,v=3*c;m<v;++m)p[m]=0;for(var y=0,b=3*c;y<b;++y)f[y]=_[y]=-1;var T={};return T.dims=[s,l,u],T.step=t,T.min=n,T.max=a,T.crossedEdges=p,T.distanceField=d,T.colorField=f,T.materialField=_,T}(n),c=0,h=e.length;c<h;++c)Ur(e[c],u);console.timeEnd("2. voxelization"),console.time("3. flood"),function(e){var t=e.step,r=e.dims,i=r[0],n=i*r[1],a=e.crossedEdges,s=e.distanceField,o=s.length,l=new Uint8Array(o),u=new Int32Array(o);u[0]=0;for(var c=1,h=[-1,1,-i,i,-n,n],d=[0,0,1,1,2,2],f=h.length,_=0,p=0;c>0;){var g=u[--c];if(s[g]<t)for(_=0;_<f;++_){var m=h[_];(p=g+m)>=o||p<0||1!==l[p]&&s[p]!==1/0&&0===a[3*(m>=0?g:p)+d[_]]&&(l[p]=1,u[c++]=p)}else for(_=0;_<f;++_)(p=g+h[_])>=o||p<0||1!==l[p]&&(l[p]=1,u[c++]=p)}for(var v=0;v<o;++v)0===s[v]&&console.log("hit"),0===l[v]&&(s[v]=-s[v])}(u),console.timeEnd("3. flood"),r?(console.time("4. marchingCubes"),Nr.BLOCK=Br.BLOCK,a=Nr.computeSurface(u),console.timeEnd("4. marchingCubes")):(console.time("4. surfaceNets"),Pr.BLOCK=Br.BLOCK,a=Pr.computeSurface(u),console.timeEnd("4. surfaceNets")),console.time("5. createMesh");var d=Zr(t,a.faces,a.vertices,a.colors,a.materials);return console.timeEnd("5. createMesh"),function(e,t){var r=[t[0],t[1],t[2]],n=[t[3],t[4],t[5]],a=i.TK(r,n),s=i.IH([],r,n);i.bA(s,s,.5);var o=e.getLocalBound(),u=[o[0],o[1],o[2]],c=[o[3],o[4],o[5]],h=i.TK(u,c),d=i.IH([],u,c);i.bA(d,d,.5);var f=a/h,_=i.bA([],s,1/f);i.lu(_,_,d);var p=e.getMatrix();l.yR(p),l.bA(p,p,[f,f,f]),l.Iu(p,p,_)}(d,n),r&&Br.SMOOTHING&&(console.time("6. tangential smoothing"),function(e){for(var t=e.getNbVertices(),r=new Uint32Array(t),i=0;i<t;++i)r[i]=i;var n=new ft;n.setToolMesh(e),n.smoothTangent(r,1),e.updateGeometry(),e.updateGeometryBuffers()}(d),console.timeEnd("6. tangential smoothing")),console.timeEnd("remesh total"),console.log("\n"),d},Br.mergeArrays=function(e,t){var r,n,a=0,s=0,l=0,u=0,c=e.length,h=0;for(r=0;r<c;++r)a+=e[r].getNbVertices(),s+=e[r].getNbFaces(),l+=e[r].getNbQuads(),u+=e[r].getNbTriangles();t.nbVertices=a,t.nbFaces=s,t.nbQuads=l,t.nbTriangles=u;var d=t.vertices=void 0!==t.vertices?new Float32Array(3*a):null,f=t.colors=void 0!==t.colors?new Float32Array(3*a):null,_=t.materials=void 0!==t.materials?new Float32Array(3*a):null,p=t.faces=void 0!==t.faces?new Uint32Array(4*s):null,g=t.triangles=void 0!==t.triangles?new Uint32Array(3*u):null,m=[0,0,0],v=0,y=0,b=0,T=0;for(r=0;r<c;++r){var M=e[r],S=M.getVertices(),k=M.getColors(),E=M.getMaterials(),A=M.getFaces(),C=M.getTriangles(),w=M.getNbVertices(),R=M.getNbFaces(),x=M.getNbTriangles(),P=M.getMatrix();for(n=0;n<w;++n)h=3*n,m[0]=S[h],m[1]=S[h+1],m[2]=S[h+2],i.fF(m,m,P),d[v+h]=m[0],d[v+h+1]=m[1],d[v+h+2]=m[2],f&&(f[v+h]=k[h],f[v+h+1]=k[h+1],f[v+h+2]=k[h+2]),_&&(_[v+h]=E[h],_[v+h+1]=E[h+1],_[v+h+2]=E[h+2]);if(v+=3*w,p)for(n=0;n<R;++n)p[y+(h=4*n)]=A[h]+T,p[y+h+1]=A[h+1]+T,p[y+h+2]=A[h+2]+T,p[y+h+3]=A[h+3]===o.Z.TRI_INDEX?o.Z.TRI_INDEX:A[h+3]+T;if(g)for(n=0;n<x;++n)g[b+(h=3*n)]=C[h]+T,g[b+h+1]=C[h+1]+T,g[b+h+2]=C[h+2]+T;T+=w,y+=4*R,b+=3*x}return t},Br.mergeMeshes=function(e,t){var r={vertices:null,colors:null,materials:null,faces:null};return Br.mergeArrays(e,r),Zr(t,r.faces,r.vertices,r.colors,r.materials)};const Gr=Br;var Wr={},jr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-.5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-.5,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,o=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0,l=arguments.length>8&&void 0!==arguments[8]?arguments[8]:1,u=new Float32Array(4);u[0]=0,u[1]=1,u[2]=2,u[3]=3;var c=new Float32Array(12);return c[0]=e,c[1]=t,c[2]=r,c[3]=e+i,c[4]=t+n,c[5]=r+a,c[6]=e+i+s,c[7]=t+n+o,c[8]=r+a+l,c[9]=e+s,c[10]=t+o,c[11]=r+l,{faces:u,vertices:c}},zr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=new Float32Array(24);t[1]=t[2]=t[4]=t[6]=t[7]=t[9]=t[10]=t[11]=t[14]=t[18]=t[21]=t[23]=.5*-e,t[0]=t[3]=t[5]=t[8]=t[12]=t[13]=t[15]=t[16]=t[17]=t[19]=t[20]=t[22]=.5*e;var r=new Float32Array(28);r[0]=r[6]=r[8]=r[10]=r[11]=r[13]=r[16]=r[23]=r[25]=.5,r[1]=r[3]=1,r[2]=r[4]=r[9]=r[12]=r[14]=r[15]=r[18]=.25,r[5]=r[7]=r[21]=r[24]=r[26]=r[27]=.75,r[17]=r[19]=r[20]=r[22]=0;var i=new Uint32Array(24),n=new Uint32Array(24);return i[0]=i[8]=i[21]=n[0]=0,i[1]=i[11]=i[12]=n[1]=1,i[2]=i[15]=i[16]=n[2]=n[15]=n[16]=2,i[3]=i[19]=i[22]=n[3]=n[19]=n[22]=3,i[4]=i[9]=i[20]=n[4]=n[9]=4,i[7]=i[10]=i[13]=n[5]=n[18]=n[23]=5,i[6]=i[14]=i[17]=n[6]=n[14]=n[17]=6,i[5]=i[18]=i[23]=n[7]=n[10]=7,n[8]=8,n[11]=9,n[12]=10,n[13]=11,n[20]=12,n[21]=13,{vertices:t,uv:r,faces:i,facesUV:n}},Xr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:64,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:64,a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],s=!(arguments.length>6&&void 0!==arguments[6])||arguments[6],l=a&&0===e,u=s&&0===t,c=.5*r,h=(n+1)*i,d=n*i;a&&(h+=1,d+=i),s&&(h+=1,d+=i),(l||u)&&(h-=i,d-=i);var f,_=new Float32Array(3*h),p=new Uint32Array(4*d),g=0,m=0,v=0,y=0,b=l?1:0,T=u?n-1:n;for(v=b;v<=T;v++){var M=v/n,S=M*(t-e)+e;for(y=0;y<i;y++){var k=2*Math.PI*y/i;_[m=3*g++]=S*Math.sin(k),_[m+1]=-M*r+c,_[m+2]=S*Math.cos(k)}}for(g=0,y=0;y<i;y++){var E=y===i-1?0:y+1;for(v=b;v<T;v++)p[m=4*g++]=i*v+y,p[m+1]=i*(v+1)+y,p[m+2]=i*(v+1)+E,p[m+3]=i*v+E}if(a)for(_[3*(f=(s?_.length-6:_.length-3)/3)+1]=c,y=0;y<i;y++)p[m=4*g++]=y,p[m+1]=y===i-1?0:y+1,p[m+2]=f,p[m+3]=o.Z.TRI_INDEX;if(s){_[3*(f=(_.length-3)/3)+1]=-c,l&&--v;var A=i*v;for(y=0;y<i;y++)p[m=4*g++]=y===i-1?A:A+y+1,p[m+1]=A+y,p[m+2]=f,p[m+3]=o.Z.TRI_INDEX}return{vertices:_,faces:p}},Kr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2*Math.PI,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:128,a=2*Math.PI-r<.01,s=i*n,l=s;a||(s+=2,l+=i);var u=a?n:n-1,c=new Float32Array(3*s),h=new Uint32Array(4*l),d=0,f=0,_=0,p=0;for(_=0;_<n;++_)for(p=0;p<i;++p){var g=_/u*r,m=p/i*Math.PI*2;c[f=3*d++]=(e+t*Math.cos(m))*Math.cos(g),c[f+1]=t*Math.sin(m),c[f+2]=(e+t*Math.cos(m))*Math.sin(g)}for(d=0,_=0;_<u;++_){var v=_===n-1?0:_+1;for(p=0;p<i;++p){h[f=4*d++]=i*_+p;var y=p===i-1?0:p+1;h[f+1]=i*_+y,h[f+2]=i*v+y,h[f+3]=i*v+p}}if(!a){var b=(c.length-6)/3;for(c[3*b]=e,p=0;p<i;p++)h[f=4*d++]=b,h[f+1]=p===i-1?0:p+1,h[f+2]=p,h[f+3]=o.Z.TRI_INDEX;c[3*++b]=e*Math.cos(r),c[3*b+2]=e*Math.sin(r);var T=i*_;for(p=0;p<i;p++)h[f=4*d++]=b,h[f+1]=T+p,h[f+2]=p===i-1?T:T+p+1,h[f+3]=o.Z.TRI_INDEX}return{vertices:c,faces:h}},Hr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-.5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-.5,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,o=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0,l=arguments.length>8&&void 0!==arguments[8]?arguments[8]:1,u=arguments.length>9&&void 0!==arguments[9]?arguments[9]:20,c=arguments.length>10&&void 0!==arguments[10]?arguments[10]:u;u+=2,c+=2;var h=new Float32Array(2*(u+c)*3),d=0,f=0,_=i/(u-1),p=n/(u-1),g=a/(u-1),m=e+i+s,v=t+n+o,y=r+a+l;for(d=0;d<u;++d)h[f=6*d]=e+_*d,h[f+1]=t+p*d,h[f+2]=r+g*d,h[f+3]=m-_*(u-d-1),h[f+4]=v-p*(u-d-1),h[f+5]=y-g*(u-d-1);for(_=s/(c-1),p=o/(c-1),g=l/(c-1),d=0;d<c;++d)h[f=6*(u+d)]=e+_*d,h[f+1]=t+p*d,h[f+2]=r+g*d,h[f+3]=m-_*(c-d-1),h[f+4]=v-p*(c-d-1),h[f+5]=y-g*(c-d-1);return{vertices:h}},Yr=function(e,t){var r=new sr(e);return r.setVertices(t.vertices),t.faces&&r.setFaces(t.faces),t.uv&&t.facesUV&&r.initTexCoordsDataFromOBJData(t.uv,t.facesUV),r.init(),e&&r.initRender(),r},qr=Array.prototype.slice;Wr.createGrid=function(e){var t=Yr(e,Hr.apply(this,qr.call(arguments,1)));return e&&(t.setMode(e.LINES),t.setUseDrawArrays(!0),t.setAlreadyDrawArrays()),t},Wr.createCube=function(e){return Yr(e,zr.apply(this,qr.call(arguments,1)))},Wr.createCylinder=function(e){return Yr(e,Xr.apply(this,qr.call(arguments,1)))},Wr.createTorus=function(e){return Yr(e,Kr.apply(this,qr.call(arguments,1)))},Wr.createPlane=function(e){return Yr(e,jr.apply(this,qr.call(arguments,1)))},Wr.createArrow=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.2,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:4,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1,o=Yr(null,Xr(t,t,r,a,s)),l=Yr(null,Xr(0,t*i,r*n,a,s));l.getMatrix()[13]=.5*r;var u={vertices:null,faces:null};return Gr.mergeArrays([o,l],u),Yr(e,u)},Wr.createLine2D=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=Yr(e,{vertices:new Float32Array([t,r,0,i,n,0])});return e&&(a.setMode(e.LINES),a.setUseDrawArrays(!0),a.setAlreadyDrawArrays()),a};const Jr=Wr;function Qr(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var $r=i.al(.7,.2,.2),ei=i.al(.2,.7,.2),ti=i.al(.2,.2,.7),ri=i.al(.4,.4,.4),ii=i.al(.8,.4,.2),ni=.02,ai=Ke(),si=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return{_finalMatrix:l.Ue(),_baseMatrix:l.Ue(),_color:i.Ue(),_colorSelect:i.al(1,1,0),_drawGeo:null,_pickGeo:null,_isSelected:!1,_type:e,_nbAxis:t,_lastInter:[0,0,0],updateMatrix:function(){l.JG(this._drawGeo.getMatrix(),this._finalMatrix),l.JG(this._pickGeo.getMatrix(),this._finalMatrix)},updateFinalMatrix:function(e){l.dC(this._finalMatrix,e,this._baseMatrix)}}},oi=1024,li=2048,ui=4096,ci=8192,hi=15360;const di=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=t,this._gl=t._gl,this._activatedType=e.TRANS_XYZ|e.ROT_XYZ|e.PLANE_XYZ|e.SCALE_XYZW|e.ROT_W,this._transX=si(e.TRANS_X,0),this._transY=si(e.TRANS_Y,1),this._transZ=si(e.TRANS_Z,2),this._planeX=si(e.PLANE_X,0),this._planeY=si(e.PLANE_Y,1),this._planeZ=si(e.PLANE_Z,2),this._scaleX=si(e.SCALE_X,0),this._scaleY=si(e.SCALE_Y,1),this._scaleZ=si(e.SCALE_Z,2),this._scaleW=si(e.SCALE_W),this._rotX=si(e.ROT_X,0),this._rotY=si(e.ROT_Y,1),this._rotZ=si(e.ROT_Z,2),this._rotW=si(e.ROT_W),this._lineHelper=Jr.createLine2D(this._gl),this._lineHelper.setShaderType(s.Z.Shader.FLAT),this._lastDistToEye=0,this._isEditing=!1,this._selected=null,this._pickables=[],this._editLineOrigin=[0,0,0],this._editLineDirection=[0,0,0],this._editOffset=[0,0,0],this._editLocal=[],this._editTrans=l.Ue(),this._editScaleRot=[],this._editLocalInv=[],this._editTransInv=l.Ue(),this._editScaleRotInv=[],this._initTranslate(),this._initRotate(),this._initScale(),this._initPickables()}var t,r,n;return t=e,n=[{key:"TRANS_X",get:function(){return 1}},{key:"TRANS_Y",get:function(){return 2}},{key:"TRANS_Z",get:function(){return 4}},{key:"ROT_X",get:function(){return 8}},{key:"ROT_Y",get:function(){return 16}},{key:"ROT_Z",get:function(){return 32}},{key:"ROT_W",get:function(){return 64}},{key:"PLANE_X",get:function(){return 128}},{key:"PLANE_Y",get:function(){return 256}},{key:"PLANE_Z",get:function(){return 512}},{key:"SCALE_X",get:function(){return oi}},{key:"SCALE_Y",get:function(){return li}},{key:"SCALE_Z",get:function(){return ui}},{key:"SCALE_W",get:function(){return ci}},{key:"TRANS_XYZ",get:function(){return 7}},{key:"ROT_XYZ",get:function(){return 56}},{key:"PLANE_XYZ",get:function(){return 896}},{key:"SCALE_XYZW",get:function(){return hi}}],(r=[{key:"setActivatedType",value:function(e){this._activatedType=e,this._initPickables()}},{key:"_initPickables",value:function(){var e=this._pickables;e.length=0;var t=this._activatedType;1&t&&e.push(this._transX._pickGeo),2&t&&e.push(this._transY._pickGeo),4&t&&e.push(this._transZ._pickGeo),128&t&&e.push(this._planeX._pickGeo),256&t&&e.push(this._planeY._pickGeo),512&t&&e.push(this._planeZ._pickGeo),8&t&&e.push(this._rotX._pickGeo),16&t&&e.push(this._rotY._pickGeo),32&t&&e.push(this._rotZ._pickGeo),t&oi&&e.push(this._scaleX._pickGeo),t&li&&e.push(this._scaleY._pickGeo),t&ui&&e.push(this._scaleZ._pickGeo),t&ci&&e.push(this._scaleW._pickGeo)}},{key:"_createArrow",value:function(e,t,r){var n=e._baseMatrix;l.U1(n,n,.5*Math.PI,t),l.Iu(n,n,[0,1.25,0]),i.JG(e._color,r),e._pickGeo=Jr.createArrow(this._gl,.1,2.5,6*.4),e._pickGeo._gizmo=e,e._drawGeo=Jr.createArrow(this._gl,ni,2.5,6,.25),e._drawGeo.setShaderType(s.Z.Shader.FLAT)}},{key:"_createPlane",value:function(e,t,r,n,a,o,l,u){i.JG(e._color,t),e._pickGeo=Jr.createPlane(this._gl,0,0,0,r,n,a,o,l,u),e._pickGeo._gizmo=e,e._drawGeo=Jr.createPlane(this._gl,0,0,0,r,n,a,o,l,u),e._drawGeo.setShaderType(s.Z.Shader.FLAT)}},{key:"_initTranslate",value:function(){var e=[0,0,0];this._createArrow(this._transX,i.t8(e,0,0,-1),$r),this._createArrow(this._transY,i.t8(e,0,1,0),ei),this._createArrow(this._transZ,i.t8(e,1,0,0),ti);var t=.5;this._createPlane(this._planeX,$r,0,t,0,0,0,t),this._createPlane(this._planeY,ei,t,0,0,0,0,t),this._createPlane(this._planeZ,ti,t,0,0,0,t,0)}},{key:"_createCircle",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1.5,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;i.JG(e._color,r),e._pickGeo=Jr.createTorus(this._gl,n,.1*a,t,6,64),e._pickGeo._gizmo=e,e._drawGeo=Jr.createTorus(this._gl,n,ni*a,t,6,64),e._drawGeo.setShaderType(s.Z.Shader.FLAT)}},{key:"_initRotate",value:function(){this._createCircle(this._rotX,Math.PI,$r),this._createCircle(this._rotY,Math.PI,ei),this._createCircle(this._rotZ,Math.PI,ti),this._createCircle(this._rotW,2*Math.PI,ri)}},{key:"_createCube",value:function(e,t,r){var n=e._baseMatrix;l.U1(n,n,.5*Math.PI,t),l.Iu(n,n,[0,1.5,0]),i.JG(e._color,r),e._pickGeo=Jr.createCube(this._gl,.42),e._pickGeo._gizmo=e,e._drawGeo=Jr.createCube(this._gl,.35),e._drawGeo.setShaderType(s.Z.Shader.FLAT)}},{key:"_initScale",value:function(){var e=[0,0,0];this._createCube(this._scaleX,i.t8(e,0,0,-1),$r),this._createCube(this._scaleY,i.t8(e,0,1,0),ei),this._createCube(this._scaleZ,i.t8(e,1,0,0),ti),this._createCircle(this._scaleW,2*Math.PI,ii,1.9500000000000002,2)}},{key:"_updateArcRotation",value:function(e){ai[0]=e[2],ai[1]=0,ai[2]=-e[0],ai[3]=1+e[1],et(ai,ai),l.en(this._rotW._baseMatrix,ai),l.en(this._scaleW._baseMatrix,ai),function(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);e[0]=i*l+n*o,e[1]=n*l-i*o,e[2]=a*l+s*o,e[3]=s*l-a*o}(ai,He(ai),.5*Math.PI),Je(ai,ai,Math.atan2(-e[1],-e[2])),l.en(this._rotX._baseMatrix,ai),Je(ai,He(ai),Math.atan2(-e[0],-e[2])),l.en(this._rotY._baseMatrix,ai),qe(ai,He(ai),.5*Math.PI),Je(ai,ai,Math.atan2(-e[0],e[1])),l.en(this._rotZ._baseMatrix,ai)}},{key:"_computeCenterGizmo",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0],t=this._main.getSelectedMeshes(),r=[0,0,0],n=[0,0,0],a=0;a<t.length;++a){var s=t[a];i.fF(n,s.getCenter(),s.getEditMatrix()),i.fF(n,n,s.getMatrix()),i.IH(r,r,n)}return i.bA(e,r,1/t.length),e}},{key:"_updateMatrices",value:function(){var e=this._main.getCamera(),t=this._computeCenterGizmo(),r=e.computePosition();this._lastDistToEye=this._isEditing?this._lastDistToEye:i.TK(r,t);var n=80*this._lastDistToEye/e.getConstantScreen(),a=l.Ue();l.Iu(a,a,t),l.bA(a,a,[n,n,n]),this._updateArcRotation(i.Fv(r,i.lu(r,t,r))),this._transX.updateFinalMatrix(a),this._transY.updateFinalMatrix(a),this._transZ.updateFinalMatrix(a),this._planeX.updateFinalMatrix(a),this._planeY.updateFinalMatrix(a),this._planeZ.updateFinalMatrix(a),this._rotX.updateFinalMatrix(a),this._rotY.updateFinalMatrix(a),this._rotZ.updateFinalMatrix(a),this._rotW.updateFinalMatrix(a),this._scaleX.updateFinalMatrix(a),this._scaleY.updateFinalMatrix(a),this._scaleZ.updateFinalMatrix(a),this._scaleW.updateFinalMatrix(a)}},{key:"_drawGizmo",value:function(e){e.updateMatrix();var t=e._drawGeo;t.setFlatColor(e._isSelected?e._colorSelect:e._color),t.updateMatrices(this._main.getCamera()),t.render(this._main)}},{key:"_updateLineHelper",value:function(e,t,r,i){var n=this._lineHelper.getVertices(),a=this._main,s=a.getCanvasWidth(),o=a.getCanvasHeight();n[0]=e/s*2-1,n[1]=(o-t)/o*2-1,n[3]=r/s*2-1,n[4]=(o-i)/o*2-1,this._lineHelper.updateVertexBuffer()}},{key:"_saveEditMatrices",value:function(){var e=this._main.getSelectedMeshes(),t=this._computeCenterGizmo();l.Iu(this._editTrans,l.yR(this._editTrans),t),l.U_(this._editTransInv,this._editTrans);for(var r=0;r<e.length;++r)this._editLocal[r]=l.Ue(),this._editScaleRot[r]=l.Ue(),this._editLocalInv[r]=l.Ue(),this._editScaleRotInv[r]=l.Ue(),l.JG(this._editLocal[r],e[r].getMatrix()),l.JG(this._editScaleRot[r],this._editLocal[r]),this._editScaleRot[r][12]=this._editScaleRot[r][13]=this._editScaleRot[r][14]=0,l.U_(this._editLocalInv[r],this._editLocal[r]),l.U_(this._editScaleRotInv[r],this._editScaleRot[r])}},{key:"_startRotateEdit",value:function(){var e=this._main,t=e.getCamera(),r=[0,0,0];this._computeCenterGizmo(r),i.JG(r,t.project(r));var n=this._editLineDirection,a=0===this._selected._nbAxis?-1:1,s=this._selected._lastInter;i.t8(n,-a*s[2],-a*s[1],a*s[0]),i.fF(n,n,this._selected._finalMatrix),i.JG(n,t.project(n)),Ge(n,ze(n,n,r)),Ue(this._editLineOrigin,e._mouseX,e._mouseY)}},{key:"_startTranslateEdit",value:function(){var e=this._main,t=e.getCamera(),r=this._editLineOrigin,n=this._editLineDirection;this._computeCenterGizmo(r);var a=this._selected._nbAxis;-1!==a&&(i.t8(n,0,0,0)[a]=1),i.IH(n,r,n),i.JG(r,t.project(r)),i.JG(n,t.project(n)),Ge(n,ze(n,n,r));var s=this._editOffset;s[0]=e._mouseX-r[0],s[1]=e._mouseY-r[1]}},{key:"_startPlaneEdit",value:function(){var e=this._main,t=e.getCamera(),r=this._editLineOrigin;this._computeCenterGizmo(r),i.JG(r,t.project(r));var n=this._editOffset;n[0]=e._mouseX-r[0],n[1]=e._mouseY-r[1],Ue(this._editLineOrigin,e._mouseX,e._mouseY)}},{key:"_startScaleEdit",value:function(){this._startTranslateEdit()}},{key:"_updateRotateEdit",value:function(){var e=this._main,t=this._editLineOrigin,r=this._editLineDirection,i=[e._mouseX,e._mouseY,0];ze(i,i,t);var n=We(i,r);this._updateLineHelper(t[0],t[1],t[0]+r[0]*n,t[1]+r[1]*n);var a=7*n/Math.min(e.getCanvasWidth(),e.getCanvasHeight());a%=2*Math.PI;for(var s=this._selected._nbAxis,o=this._main.getSelectedMeshes(),u=0;u<o.length;++u){var c=o[u].getEditMatrix();l.yR(c),0===s?l.lM(c,c,-a):1===s?l.uD(c,c,-a):2===s&&l.jI(c,c,-a),this._scaleRotateEditMatrix(c,u)}e.render()}},{key:"_updateTranslateEdit",value:function(){var e=this._main,t=e.getCamera(),r=this._editLineOrigin,n=this._editLineDirection,a=[e._mouseX,e._mouseY,0];ze(a,a,r),ze(a,a,this._editOffset),Ze(a,r,n,We(a,n)),this._updateLineHelper(r[0],r[1],a[0],a[1]);var s=t.unproject(a[0],a[1],0),o=t.unproject(a[0],a[1],.1);i.fF(s,s,this._editTransInv),i.fF(o,o,this._editTransInv),i.Fv(a,i.lu(a,o,s));var l=[0,0,0];l[this._selected._nbAxis]=1;var u=-i.AK(a,l),c=i.AK(s,a),h=Math.abs(1-u*u),d=-i.AK(s,l);l[this._selected._nbAxis]=(u*c-d)/h,this._updateMatrixTranslate(l),e.render()}},{key:"_updatePlaneEdit",value:function(){var e=this._main,t=e.getCamera(),r=[e._mouseX,e._mouseY,0];ze(r,r,this._editOffset),this._updateLineHelper(this._editLineOrigin[0],this._editLineOrigin[1],e._mouseX,e._mouseY);var n=t.unproject(r[0],r[1],0),a=t.unproject(r[0],r[1],.1);i.fF(n,n,this._editTransInv),i.fF(a,a,this._editTransInv);var s=[0,0,0];s[this._selected._nbAxis]=1;var o=i.AK(n,s),l=i.AK(a,s);if(o===l)return!1;var u=-o/(l-o);s[0]=n[0]+(a[0]-n[0])*u,s[1]=n[1]+(a[1]-n[1])*u,s[2]=n[2]+(a[2]-n[2])*u,this._updateMatrixTranslate(s),e.render()}},{key:"_updateMatrixTranslate",value:function(e){for(var t=[0,0,0],r=this._main.getSelectedMeshes(),n=0;n<r.length;++n){i.fF(t,e,this._editScaleRotInv[n]);var a=r[n].getEditMatrix();l.yR(a),l.Iu(a,a,t)}}},{key:"_updateScaleEdit",value:function(){var e=this._main,t=(e.getMesh(),this._editLineOrigin),r=this._editLineDirection,n=this._selected._nbAxis,a=[e._mouseX,e._mouseY,0];-1!==n&&(ze(a,a,t),Ze(a,t,r,We(a,r))),this._updateLineHelper(t[0],t[1],a[0],a[1]);var s=i.Zh(this._editOffset),o=[1,1,1],u=Math.max(-.99,(Xe(t,a)-s)/s);-1===n?(o[0]+=u,o[1]+=u,o[2]+=u):o[n]+=u;for(var c=this._main.getSelectedMeshes(),h=0;h<c.length;++h){var d=c[h].getEditMatrix();l.yR(d),l.bA(d,d,o),this._scaleRotateEditMatrix(d,h)}e.render()}},{key:"_scaleRotateEditMatrix",value:function(e,t){l.dC(e,this._editTrans,e),l.dC(e,e,this._editTransInv),l.dC(e,this._editLocalInv[t],e),l.dC(e,e,this._editLocal[t])}},{key:"addGizmoToScene",value:function(e){return e.push(this._transX._drawGeo),e.push(this._transY._drawGeo),e.push(this._transZ._drawGeo),e.push(this._planeX._drawGeo),e.push(this._planeY._drawGeo),e.push(this._planeZ._drawGeo),e.push(this._rotX._drawGeo),e.push(this._rotY._drawGeo),e.push(this._rotZ._drawGeo),e.push(this._rotW._drawGeo),e.push(this._scaleX._drawGeo),e.push(this._scaleY._drawGeo),e.push(this._scaleZ._drawGeo),e.push(this._scaleW._drawGeo),e}},{key:"render",value:function(){this._updateMatrices();var e=this._isEditing&&this._selected?this._selected._type:this._activatedType;64&e&&this._drawGizmo(this._rotW),1&e&&this._drawGizmo(this._transX),2&e&&this._drawGizmo(this._transY),4&e&&this._drawGizmo(this._transZ),128&e&&this._drawGizmo(this._planeX),256&e&&this._drawGizmo(this._planeY),512&e&&this._drawGizmo(this._planeZ),8&e&&this._drawGizmo(this._rotX),16&e&&this._drawGizmo(this._rotY),32&e&&this._drawGizmo(this._rotZ),e&oi&&this._drawGizmo(this._scaleX),e&li&&this._drawGizmo(this._scaleY),e&ui&&this._drawGizmo(this._scaleZ),e&ci&&this._drawGizmo(this._scaleW),this._isEditing&&this._lineHelper.render(this._main)}},{key:"onMouseOver",value:function(){if(this._isEditing){var e=this._selected._type;return 56&e?this._updateRotateEdit():7&e?this._updateTranslateEdit():896&e?this._updatePlaneEdit():e&hi&&this._updateScaleEdit(),!0}var t=this._main,r=t.getPicking(),n=t._mouseX,a=t._mouseY,s=this._pickables;r.intersectionMouseMeshes(s,n,a),this._selected&&(this._selected._isSelected=!1);var o=r.getMesh();return o?(this._selected=o._gizmo,this._selected._isSelected=!0,i.JG(this._selected._lastInter,r.getIntersectionPoint()),!0):(this._selected=null,!1)}},{key:"onMouseDown",value:function(){var e=this._selected;if(!e)return!1;this._isEditing=!0;var t=e._type;return this._saveEditMatrices(),56&t?this._startRotateEdit():7&t?this._startTranslateEdit():896&t?this._startPlaneEdit():t&hi&&this._startScaleEdit(),!0}},{key:"onMouseUp",value:function(){this._isEditing=!1}}])&&Qr(t.prototype,r),n&&Qr(t,n),e}();function fi(e){return(fi="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 _i(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function pi(e,t){return(pi=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function gi(e,t){return!t||"object"!==fi(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function mi(e){return(mi=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const vi=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&pi(e,t)}(o,e);var t,r,n,a,s=(n=o,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=mi(n);if(a){var r=mi(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return gi(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e))._gizmo=new di(e),t}return t=o,(r=[{key:"isIdentity",value:function(e){return 1===e[0]&&1===e[5]&&1===e[10]&&1===e[15]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]}},{key:"preUpdate",value:function(){var e=this._main.getPicking(),t=e.getMesh();this._gizmo.onMouseOver(),e._mesh=t,this._main.setCanvasCursor("default")}},{key:"start",value:function(e){var t=this._main,r=this.getMesh(),i=t.getPicking();return r&&this._gizmo.onMouseDown()?(i._mesh=r,!0):!!i.intersectionMouseMeshes(t.getMeshes(),t._mouseX,t._mouseY)&&!!t.setOrUnsetMesh(i.getMesh(),e)&&(this._lastMouseX=t._mouseX,this._lastMouseY=t._mouseY,!1)}},{key:"end",value:function(){if(this._gizmo.onMouseUp(),this.getMesh()&&!this.isIdentity(this.getMesh().getEditMatrix())){for(var e=this._main.getSelectedMeshes(),t=0;t<e.length;++t){this._forceToolMesh=e[t],this.pushState(),t>0&&(this._main.getStateManager().getCurrentState().squash=!0);var r=this.getUnmaskedVertices();this._main.getStateManager().pushVertices(r),this.applyEditMatrix(r),0!==r.length&&this.updateMeshBuffers()}this._forceToolMesh=null}}},{key:"applyEditMatrix",value:function(e){for(var t=this.getMesh(),r=t.getEditMatrix(),n=t.getMaterials(),a=t.getVertices(),s=[0,0,0],o=0,u=e.length;o<u;++o){var c=3*e[o],h=n[c+2],d=s[0]=a[c],f=s[1]=a[c+1],_=s[2]=a[c+2];i.fF(s,s,r);var p=1-h;a[c]=d*p+s[0]*h,a[c+1]=f*p+s[1]*h,a[c+2]=_*p+s[2]*h}i.fF(t.getCenter(),t.getCenter(),r),l.yR(r),e.length===t.getNbVertices()?t.updateGeometry():t.updateGeometry(t.getFacesFromVertices(e),e)}},{key:"update",value:function(){}},{key:"postRender",value:function(){this.getMesh()&&this._gizmo.render()}},{key:"addSculptToScene",value:function(e){this.getMesh()&&this._gizmo.addGizmoToScene(e)}}])&&_i(t.prototype,r),o}(Te);var yi=x.getCopy();yi.vertexName=yi.fragmentName="PenStroke",yi.uniforms={},yi.attributes={},yi.activeAttributes={vertex:!0},yi.uniformNames=["uMVP","uColor","uPointSize"],yi.vertex=["attribute vec3 aVertex;","uniform mat4 uMVP;","uniform float uPointSize;","void main() {"," gl_Position = uMVP * vec4(aVertex, 1.0);"," gl_PointSize = uPointSize;","}"].join("\n"),yi.fragment=["uniform vec3 uColor;","void main() {"," gl_FragColor = vec4(uColor, 1.0);","}"].join("\n");const bi=yi;function Ti(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Mi=l.Ue();const Si=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._gl=t,this._buffer=new g(t,t.ARRAY_BUFFER,t.DYNAMIC_DRAW),this._color=new Float32Array([.2,.8,.2]),this._pointSize=6,this._count=0,this._closeLoop=!1}var t,r;return t=e,(r=[{key:"setPoints",value:function(e,t){this._closeLoop=!!t;for(var r=e.length,i=new Float32Array(3*r),n=0;n<r;++n){var a=3*n,s=e[n];i[a]=s[0],i[a+1]=s[1],i[a+2]=s[2]}this._count=r,this._buffer.update(i)}},{key:"setClosedLoop",value:function(e){this._closeLoop=!!e}},{key:"setColor",value:function(e){e&&(this._color[0]=e[0],this._color[1]=e[1],this._color[2]=e[2])}},{key:"setPointSize",value:function(e){this._pointSize=e}},{key:"clear",value:function(){this._count=0,this._buffer.update(new Float32Array(0))}},{key:"render",value:function(e,t){if(e&&0!==this._count){var r=this._gl,i=bi.getOrCreate(r);l.dC(Mi,t.getProjection(),t.getView()),l.dC(Mi,Mi,e.getMatrix()),r.useProgram(i.program),r.uniformMatrix4fv(i.uniforms.uMVP,!1,Mi),r.uniform3fv(i.uniforms.uColor,this._color),r.uniform1f(i.uniforms.uPointSize,this._pointSize),i.attributes.aVertex.bindToBuffer(this._buffer);var n=this._closeLoop?r.LINE_LOOP:r.LINE_STRIP;r.drawArrays(n,0,this._count),r.drawArrays(r.POINTS,0,this._count)}}}])&&Ti(t.prototype,r),e}();function ki(e){return(ki="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 Ei(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Ai(e,t){return(Ai=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ci(e,t){return!t||"object"!==ki(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function wi(e){return(wi=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ri=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ai(e,t)}(s,e);var t,r,i,n,a=(i=s,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=wi(i);if(n){var r=wi(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return Ci(this,e)});function s(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),(t=a.call(this,e))._mode=s.MODE_POINTS,t._closeLoop=!1,t._spacing=.01,t._stroke=new Si(e._gl),t._isDrawing=!1,t._features=[],t._featureId=0,t._activeFeatureId=null,t._selectedFeatureIds=new Set,t._onFeaturesChanged=[],t._solidFeatures=[],t._solidFeatureId=0,t._volumeRadiusFactor=.035,t._tmpPos=[0,0,0],t}return t=s,(r=[{key:"setCloseLoop",value:function(e){this._closeLoop=e;var t=this.getActiveFeature();t&&(t.closed=e,this._notifyFeaturesChanged()),this._main.render()}},{key:"clearStroke",value:function(){var e=this.getActiveFeature();e&&(e.points.length=0,this._notifyFeaturesChanged()),this._main.render()}},{key:"setOnFeaturesChanged",value:function(e){"function"==typeof e&&this._onFeaturesChanged.push(e),this._debugLog("setOnFeaturesChanged",{listeners:this._onFeaturesChanged.length})}},{key:"getFeatures",value:function(){return this._features}},{key:"getSolidFeatures",value:function(){return this._solidFeatures}},{key:"getSelectedFeatureIds",value:function(){return Array.from(this._selectedFeatureIds)}},{key:"getActiveFeature",value:function(){return this._getFeatureById(this._activeFeatureId)}},{key:"startNewFeature",value:function(){var e=this._main.getMesh();if(!e)return null;var t=this._createFeature(e);return this._features.push(t),this._activeFeatureId=t.id,this._selectedFeatureIds.clear(),this._selectedFeatureIds.add(t.id),this._notifyFeaturesChanged(),t}},{key:"finishActiveFeature",value:function(){this._isDrawing=!1,this._activeFeatureId=null,this._notifyFeaturesChanged()}},{key:"selectFeature",value:function(e,t){if(t||this._selectedFeatureIds.clear(),this._selectedFeatureIds.has(e)&&t)this._selectedFeatureIds.delete(e);else{this._selectedFeatureIds.add(e),this._activeFeatureId=e;var r=this._getFeatureById(e);r&&(this._closeLoop=r.closed)}this._notifyFeaturesChanged(),this._main.render()}},{key:"createSolidFeature",value:function(e,t,r){var i=++this._solidFeatureId,n=r||{},a={id:i,name:"Volume "+(i<10?"0"+i:i),type:e,sourceIds:t.slice(),params:{height:n.height||0,depth:n.depth||0,direction:void 0===n.direction?1:n.direction}};return this._solidFeatures.push(a),this._debugLog("createSolidFeature",{type:e,sourceIds:t,params:a.params}),this._applySolidFeature(a),this._notifyFeaturesChanged(),a}},{key:"start",value:function(e){var t=this._main,r=t.getPicking();if(!r.intersectionMouseMeshes())return!1;var i=t.setOrUnsetMesh(r.getMesh(),e);if(!i)return!1;var n=this.getActiveFeature();return!!(n&&n.meshId===i.getID()||(n=this.startNewFeature()))&&(this._mode===s.MODE_POINTS?(this._addPointFromPicking(r,i,n,!0)&&t.render(),this._isDrawing=!1):(this._isDrawing=!0,this._lastMouseX=t._mouseX,this._lastMouseY=t._mouseY,this._addPointFromPicking(r,i,n,!0)&&t.render()),!0)}},{key:"update",value:function(){var e=this.getActiveFeature();if(this._isDrawing&&e){var t=this._main,r=t.getPicking(),i=this._getMeshById(e.meshId);i&&r.intersectionMouseMesh(i)&&this._addPointFromPicking(r,i,e,!1)&&t.render()}}},{key:"end",value:function(){this._isDrawing=!1}},{key:"postRender",value:function(e){e.render(this._main),this.renderOverlay()}},{key:"renderOverlay",value:function(){for(var e=this._main.getCamera(),t=this._features,r=0,i=t.length;r<i;++r){var n=t[r];if(n.visible&&0!==n.points.length){var a=this._getMeshById(n.meshId);if(a){var s=this._reconstructFeaturePoints(n,a);0!==s.length&&(this._stroke.setPoints(s,n.closed),this._stroke.setColor(this._getFeatureColor(n)),this._stroke.setPointSize(this._getFeaturePointSize(n)),this._stroke.render(a,e))}}}}},{key:"_addPointFromPicking",value:function(e,t,r,i){var n=e.getIntersectionPoint(),a=e.getPickedFace();if(!n||a<0)return!1;if(!i&&r.points.length){var s=this._getSpacing(t),o=r.points[r.points.length-1],l=this._reconstructPoint(o,t);if(l){var u=n[0]-l[0],c=n[1]-l[1],h=n[2]-l[2];if(u*u+c*c+h*h<s*s)return!1}}var d=this._computeBarycentric(n,a,t);return!!d&&(r.points.push({faceId:a,bary:d}),this._notifyFeaturesChanged(),!0)}},{key:"_computeBarycentric",value:function(e,t,r){var i=r.getVertices(),n=r.getFaces(),a=4*t,s=3*n[a],o=3*n[a+1],l=3*n[a+2],u=n[a+3],c=4294967295!==u;c&&(u*=3);var h=i[s],d=i[s+1],f=i[s+2],_=i[o]-h,p=i[o+1]-d,g=i[o+2]-f,m=i[l]-h,v=i[l+1]-d,y=i[l+2]-f,b=e[0]-h,T=e[1]-d,M=e[2]-f,S=_*_+p*p+g*g,k=_*m+p*v+g*y,E=m*m+v*v+y*y,A=b*_+T*p+M*g,C=b*m+T*v+M*y,w=S*E-k*k;if(Math.abs(w)<1e-12)return null;var R=1/w,x=(E*A-k*C)*R,P=(S*C-k*A)*R;return{u:x,v:P,w:1-x-P,isQuad:c}}},{key:"_reconstructPoint",value:function(e,t){if(!e||void 0===e.faceId)return null;var r=t.getVertices(),i=t.getFaces(),n=4*e.faceId,a=3*i[n],s=3*i[n+1],o=3*i[n+2],l=e.bary,u=l.w,c=l.u,h=l.v;return this._tmpPos[0]=u*r[a]+c*r[s]+h*r[o],this._tmpPos[1]=u*r[a+1]+c*r[s+1]+h*r[o+1],this._tmpPos[2]=u*r[a+2]+c*r[s+2]+h*r[o+2],this._tmpPos}},{key:"_reconstructFeaturePoints",value:function(e,t){for(var r=e.points,i=[],n=0;n<r.length;++n){var a=this._reconstructPoint(r[n],t);a&&i.push([a[0],a[1],a[2]])}return i}},{key:"_getSpacing",value:function(e){var t=e.computeLocalRadius?e.computeLocalRadius():1;return Math.max(1e-6,t*this._spacing)}},{key:"_createFeature",value:function(e){var t=++this._featureId;return{id:t,name:"Point Set "+(t<10?"0"+t:t),points:[],closed:this._closeLoop,visible:!0,locked:!1,meshId:e.getID()}}},{key:"_getFeatureById",value:function(e){if(null==e)return null;for(var t=this._features,r=0,i=t.length;r<i;++r)if(t[r].id===e)return t[r];return null}},{key:"_getMeshById",value:function(e){for(var t=this._main.getMeshes(),r=0,i=t.length;r<i;++r)if(t[r].getID()===e)return t[r];return null}},{key:"_getFeatureColor",value:function(e){return this._selectedFeatureIds.has(e.id)?s.COLOR_SELECTED:s.COLOR_DEFAULT}},{key:"_getFeaturePointSize",value:function(e){return e.id===this._activeFeatureId?s.POINT_SIZE_ACTIVE:s.POINT_SIZE}},{key:"_notifyFeaturesChanged",value:function(){for(var e=0;e<this._onFeaturesChanged.length;++e)this._onFeaturesChanged[e]();this._debugLog("featuresChanged",{count:this._features.length,ids:this._features.map((function(e){return e.id})),lengths:this._features.map((function(e){return e.points.length})),samples:this._features.map((function(e){return{id:e.id,pts:e.points.slice(0,3)}}))})}},{key:"_applySolidFeature",value:function(e){var t=this._getFeaturesByIds(e.sourceIds);if(t.length){var r=this._getMeshById(t[0].meshId);if(r){var i=r.getVertices(),n=r.getNormals();if(i&&n){for(var a=r.getNbVertices?r.getNbVertices():i.length/3,s=this._estimateMeshRadius(r),o=Math.max(1e-4,s*this._volumeRadiusFactor),l="Pad"===e.type?e.params.height:e.params.depth,u=l&&0!==l?l:o,c="Pad"===e.type?u:-u,h=[],d=0;d<t.length;++d)h.push(this._computeFeatureBounds(t[d],r));for(var f=[],_=0;_<a;++_){for(var p=3*_,g=i[p],m=i[p+1],v=i[p+2],y=1/0,b=0;b<t.length;++b){var T=h[b],M=g-T.center[0],S=m-T.center[1],k=v-T.center[2];if(!(Math.sqrt(M*M+S*S+k*k)>T.radius+o)){var E=this._distanceToFeature(g,m,v,t[b],T.positions);E<y&&(y=E)}}if(!(y===1/0||y>o)){var A=c*(1-y/o);i[p]+=n[p]*A,i[p+1]+=n[p+1]*A,i[p+2]+=n[p+2]*A,f.push(_)}}if(f.length){var C=new Uint32Array(f),w=r.getFacesFromVertices?r.getFacesFromVertices(C):null,R=this._main.getStateManager&&this._main.getStateManager();R&&R.pushVertices&&R.pushVertices(C),R&&R.pushFaces&&w&&R.pushFaces(w),r.updateGeometry(w||void 0,C),r.updateGeometryBuffers&&r.updateGeometryBuffers(),this._debugLog("applySolidFeature:done",{featureId:e.id,type:e.type,affected:f.length,influence:o,amount:c}),this._main.render()}else this._debugLog("applySolidFeature:noAffected",{feature:e,influence:o})}else this._debugLog("applySolidFeature:noGeometry",{})}else this._debugLog("applySolidFeature:noMesh",{meshId:t[0].meshId})}else this._debugLog("applySolidFeature:missingSources",{feature:e})}},{key:"_getFeaturesByIds",value:function(e){for(var t=[],r=this._features,i=0,n=r.length;i<n;++i)-1!==e.indexOf(r[i].id)&&t.push(r[i]);return t}},{key:"_computeFeatureBounds",value:function(e,t){var r=this._reconstructFeaturePoints(e,t);if(!r||!r.length)return{center:[0,0,0],radius:0};for(var i=0,n=0,a=0,s=0;s<r.length;++s)i+=r[s][0],n+=r[s][1],a+=r[s][2];i/=r.length,n/=r.length,a/=r.length;for(var o=0,l=0;l<r.length;++l){var u=r[l][0]-i,c=r[l][1]-n,h=r[l][2]-a,d=Math.sqrt(u*u+c*c+h*h);d>o&&(o=d)}return{center:[i,n,a],radius:o,positions:r}}},{key:"_distanceToFeature",value:function(e,t,r,i,n){if(!n||0===n.length)return 1/0;if(1===n.length){var a=e-n[0][0],s=t-n[0][1],o=r-n[0][2];return Math.sqrt(a*a+s*s+o*o)}for(var l=1/0,u=n.length,c=i.closed?u:u-1,h=0;h<c;++h){var d=n[h],f=n[(h+1)%u],_=this._distancePointSegment(e,t,r,d,f);_<l&&(l=_)}return l}},{key:"_distancePointSegment",value:function(e,t,r,i,n){var a=n[0]-i[0],s=n[1]-i[1],o=n[2]-i[2],l=e-i[0],u=t-i[1],c=r-i[2],h=a*a+s*s+o*o,d=h>0?(l*a+u*s+c*o)/h:0;d=Math.max(0,Math.min(1,d));var f=e-(i[0]+a*d),_=t-(i[1]+s*d),p=r-(i[2]+o*d);return Math.sqrt(f*f+_*_+p*p)}},{key:"_estimateMeshRadius",value:function(e){var t=e.getVertices(),r=e.getNbVertices?e.getNbVertices():t.length/3;if(!t||0===r)return 1;for(var i=1/0,n=1/0,a=1/0,s=-1/0,o=-1/0,l=-1/0,u=0;u<r;++u){var c=3*u,h=t[c],d=t[c+1],f=t[c+2];h<i&&(i=h),d<n&&(n=d),f<a&&(a=f),h>s&&(s=h),d>o&&(o=d),f>l&&(l=f)}var _=s-i,p=o-n,g=l-a;return.5*Math.sqrt(_*_+p*p+g*g)}},{key:"_debugLog",value:function(e,t){"undefined"!=typeof window&&void 0===window.DEBUG_PADS_TRIMS&&(window.DEBUG_PADS_TRIMS=!0),"undefined"!=typeof console&&console.log("[Pen]",e,t)}}])&&Ei(t.prototype,r),s}(Te);Ri.MODE_POINTS=0,Ri.MODE_STROKE=1,Ri.COLOR_DEFAULT=[.2,.8,.2],Ri.COLOR_SELECTED=[1,.8,.2],Ri.POINT_SIZE=6,Ri.POINT_SIZE_ACTIVE=8;const xi=Ri;var Pi=[];Pi[s.Z.Tools.BRUSH]=Ie,Pi[s.Z.Tools.INFLATE]=Be,Pi[s.Z.Tools.TWIST]=ot,Pi[s.Z.Tools.SMOOTH]=ft,Pi[s.Z.Tools.FLATTEN]=Ce,Pi[s.Z.Tools.PINCH]=yt,Pi[s.Z.Tools.CREASE]=Et,Pi[s.Z.Tools.DRAG]=Pt,Pi[s.Z.Tools.PAINT]=Nt,Pi[s.Z.Tools.MOVE]=jt,Pi[s.Z.Tools.MASKING]=dr,Pi[s.Z.Tools.LOCALSCALE]=vr,Pi[s.Z.Tools.TRANSFORM]=vi,Pi[s.Z.Tools.PEN]=xi,Pi[s.Z.Tools.BRUSH].uiName="sculptBrush",Pi[s.Z.Tools.INFLATE].uiName="sculptInflate",Pi[s.Z.Tools.TWIST].uiName="sculptTwist",Pi[s.Z.Tools.SMOOTH].uiName="sculptSmooth",Pi[s.Z.Tools.FLATTEN].uiName="sculptFlatten",Pi[s.Z.Tools.PINCH].uiName="sculptPinch",Pi[s.Z.Tools.CREASE].uiName="sculptCrease",Pi[s.Z.Tools.DRAG].uiName="sculptDrag",Pi[s.Z.Tools.PAINT].uiName="sculptPaint",Pi[s.Z.Tools.MOVE].uiName="sculptMove",Pi[s.Z.Tools.MASKING].uiName="sculptMasking",Pi[s.Z.Tools.LOCALSCALE].uiName="sculptLocalScale",Pi[s.Z.Tools.TRANSFORM].uiName="sculptTransform",Pi[s.Z.Tools.PEN].uiName="sculptPen";const Di=Pi;function Ii(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Fi=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=t,this._toolIndex=s.Z.Tools.BRUSH,this._tools=[],this._symmetry=!0,this._continuous=!1,this._sculptTimer=-1,this._selection=new ye(t._gl),this.init()}var t,r;return t=e,(r=[{key:"setToolIndex",value:function(e){this._toolIndex=e}},{key:"getToolIndex",value:function(){return this._toolIndex}},{key:"getCurrentTool",value:function(){return this._tools[this._toolIndex]}},{key:"getSymmetry",value:function(){return this._symmetry}},{key:"getTool",value:function(e){return this._tools[e]}},{key:"getSelection",value:function(){return this._selection}},{key:"init",value:function(){for(var e=this._main,t=this._tools,r=0,i=Di.length;r<i;++r)Di[r]&&(t[r]=new Di[r](e))}},{key:"canBeContinuous",value:function(){switch(this._toolIndex){case s.Z.Tools.TWIST:case s.Z.Tools.MOVE:case s.Z.Tools.DRAG:case s.Z.Tools.LOCALSCALE:case s.Z.Tools.TRANSFORM:return!1;default:return!0}}},{key:"isUsingContinuous",value:function(){return this._continuous&&this.canBeContinuous()}},{key:"start",value:function(e){var t=this.getCurrentTool(),r=t.start(e);return this._main.getPicking().getMesh()&&this.isUsingContinuous()&&(this._sculptTimer=window.setInterval(t._cbContinuous,16.6)),r}},{key:"end",value:function(){this.getCurrentTool().end(),-1!==this._sculptTimer&&(clearInterval(this._sculptTimer),this._sculptTimer=-1)}},{key:"preUpdate",value:function(){this.getCurrentTool().preUpdate(this.canBeContinuous())}},{key:"update",value:function(){this.isUsingContinuous()||this.getCurrentTool().update()}},{key:"postRender",value:function(){if(this.getCurrentTool().postRender(this._selection),this._toolIndex!==s.Z.Tools.PEN){var e=this._tools[s.Z.Tools.PEN];e&&e.renderOverlay&&e.renderOverlay()}}},{key:"addSculptToScene",value:function(e){return this.getCurrentTool().addSculptToScene(e)}}])&&Ii(t.prototype,r),e}();function Oi(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Li={LINEAR:!1},Vi=function(){function e(t,r,i,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._vArOut=r,this._cArOut=i,this._mArOut=n,this._vAr=t.getVertices(),this._cAr=t.getColors(),this._mAr=t.getMaterials(),this._eAr=t.getEdges(),this._nbVertices=t.getNbVertices(),this._tagEdges=new Int32Array(t.getNbEdges())}var t,r;return t=e,(r=[{key:"computeTriangleEdgeVertex",value:function(e,t,r,i){var n=this._vAr,a=this._cAr,s=this._mAr,o=this._eAr,l=this._vArOut,u=this._cArOut,c=this._mArOut,h=this._tagEdges,d=3*e,f=3*t,_=3*r,p=h[i]-1,g=-1===p?this._nbVertices++:p,m=3*g,v=o[i];if(1===v||v>=3||Li.LINEAR){if(-1!==p)return g;h[i]=g+1,l[m]=.5*(n[d]+n[f]),l[m+1]=.5*(n[d+1]+n[f+1]),l[m+2]=.5*(n[d+2]+n[f+2]),u[m]=.5*(a[d]+a[f]),u[m+1]=.5*(a[d+1]+a[f+1]),u[m+2]=.5*(a[d+2]+a[f+2]),c[m]=.5*(s[d]+s[f]),c[m+1]=.5*(s[d+1]+s[f+1]),c[m+2]=.5*(s[d+2]+s[f+2])}else-1===p?(h[i]=g+1,l[m]=.125*n[_]+.375*(n[d]+n[f]),l[m+1]=.125*n[_+1]+.375*(n[d+1]+n[f+1]),l[m+2]=.125*n[_+2]+.375*(n[d+2]+n[f+2]),u[m]=.125*a[_]+.375*(a[d]+a[f]),u[m+1]=.125*a[_+1]+.375*(a[d+1]+a[f+1]),u[m+2]=.125*a[_+2]+.375*(a[d+2]+a[f+2]),c[m]=.125*s[_]+.375*(s[d]+s[f]),c[m+1]=.125*s[_+1]+.375*(s[d+1]+s[f+1]),c[m+2]=.125*s[_+2]+.375*(s[d+2]+s[f+2])):(l[m]+=.125*n[_],l[m+1]+=.125*n[_+1],l[m+2]+=.125*n[_+2],u[m]+=.125*a[_],u[m+1]+=.125*a[_+1],u[m+2]+=.125*a[_+2],c[m]+=.125*s[_],c[m+1]+=.125*s[_+1],c[m+2]+=.125*s[_+2]);return g}},{key:"computeQuadEdgeVertex",value:function(e,t,r,i,n){var a=this._vAr,s=this._cAr,o=this._mAr,l=this._eAr,u=this._vArOut,c=this._cArOut,h=this._mArOut,d=this._tagEdges,f=3*e,_=3*t,p=3*r,g=3*i,m=d[n]-1,v=-1===m?this._nbVertices++:m,y=3*v,b=l[n];if(1===b||b>=3||Li.LINEAR){if(-1!==m)return v;d[n]=v+1,u[y]=.5*(a[f]+a[_]),u[y+1]=.5*(a[f+1]+a[_+1]),u[y+2]=.5*(a[f+2]+a[_+2]),c[y]=.5*(s[f]+s[_]),c[y+1]=.5*(s[f+1]+s[_+1]),c[y+2]=.5*(s[f+2]+s[_+2]),h[y]=.5*(o[f]+o[_]),h[y+1]=.5*(o[f+1]+o[_+1]),h[y+2]=.5*(o[f+2]+o[_+2])}else-1===m?(d[n]=v+1,u[y]=.0625*(a[p]+a[g])+.375*(a[f]+a[_]),u[y+1]=.0625*(a[p+1]+a[g+1])+.375*(a[f+1]+a[_+1]),u[y+2]=.0625*(a[p+2]+a[g+2])+.375*(a[f+2]+a[_+2]),c[y]=.0625*(s[p]+s[g])+.375*(s[f]+s[_]),c[y+1]=.0625*(s[p+1]+s[g+1])+.375*(s[f+1]+s[_+1]),c[y+2]=.0625*(s[p+2]+s[g+2])+.375*(s[f+2]+s[_+2]),h[y]=.0625*(o[p]+o[g])+.375*(o[f]+o[_]),h[y+1]=.0625*(o[p+1]+o[g+1])+.375*(o[f+1]+o[_+1]),h[y+2]=.0625*(o[p+2]+o[g+2])+.375*(o[f+2]+o[_+2])):(u[y]+=.0625*(a[p]+a[g]),u[y+1]+=.0625*(a[p+1]+a[g+1]),u[y+2]+=.0625*(a[p+2]+a[g+2]),c[y]+=.0625*(s[p]+s[g]),c[y+1]+=.0625*(s[p+1]+s[g+1]),c[y+2]+=.0625*(s[p+2]+s[g+2]),h[y]+=.0625*(o[p]+o[g]),h[y+1]+=.0625*(o[p+1]+o[g+1]),h[y+2]+=.0625*(o[p+2]+o[g+2]));return v}},{key:"computeFaceVertex",value:function(e,t,r,i){var n=3*e,a=3*t,s=3*r,o=3*i,l=this._vAr,u=this._cAr,c=this._mAr,h=this._vArOut,d=this._cArOut,f=this._mArOut,_=this._nbVertices++,p=3*_;return h[p]=.25*(l[n]+l[a]+l[s]+l[o]),h[p+1]=.25*(l[n+1]+l[a+1]+l[s+1]+l[o+1]),h[p+2]=.25*(l[n+2]+l[a+2]+l[s+2]+l[o+2]),d[p]=.25*(u[n]+u[a]+u[s]+u[o]),d[p+1]=.25*(u[n+1]+u[a+1]+u[s+1]+u[o+1]),d[p+2]=.25*(u[n+2]+u[a+2]+u[s+2]+u[o+2]),f[p]=.25*(c[n]+c[a]+c[s]+c[o]),f[p+1]=.25*(c[n+1]+c[a+1]+c[s+1]+c[o+1]),f[p+2]=.25*(c[n+2]+c[a+2]+c[s+2]+c[o+2]),_}}])&&Oi(t.prototype,r),e}(),Ni=function(e,t,r,i){var n=e.getNbVertices();r.set(e.getColors().subarray(0,3*n)),i.set(e.getMaterials().subarray(0,3*n));for(var a=e.getVertices(),s=e.getFaces(),l=e.getEdges(),u=e.getFaceEdges(),c=e.getVerticesOnEdge(),h=e.getVerticesRingVertStartCount(),d=e.getVerticesRingVert(),f=e.getVerticesRingFaceStartCount(),_=e.getVerticesRingFace(),p=e.hasOnlyTriangles(),g=0;g<n;++g){var m=3*g,v=0,y=0,b=0,T=0,M=0,S=0,k=0;if(c[g]||Li.LINEAR){var E=f[2*g],A=E+f[2*g+1];for(S=E;S<A;++S){var C=4*_[S],w=s[C],R=s[C+1],x=s[C+2],P=s[C+3],D=P===o.Z.TRI_INDEX;k=o.Z.TRI_INDEX,w===g?1===l[u[C]]?k=R:1===l[u[D?C+2:C+3]]&&(k=D?x:P):R===g?1===l[u[C]]?k=w:1===l[u[C+1]]&&(k=x):x===g?1===l[u[C+1]]?k=R:1===l[u[C+2]]&&(k=D?w:P):P===g&&(1===l[u[C+2]]?k=x:1===l[u[C+3]]&&(k=w)),k!==o.Z.TRI_INDEX&&(v+=a[k*=3],y+=a[k+1],b+=a[k+2],T++)}T<2?(t[m]=a[m],t[m+1]=a[m+1],t[m+2]=a[m+2]):(T=.25/T,M=.75,t[m]=a[m]*M+v*T,t[m+1]=a[m+1]*M+y*T,t[m+2]=a[m+2]*M+b*T)}else{var I=h[2*g],F=h[2*g+1],O=I+F;for(S=I;S<O;++S)v+=a[k=3*d[S]],y+=a[k+1],b+=a[k+2];if(p)6===F?(T=.0625,M=.625):3===F?(T=.1875,M=.4375):(T=.375/F,M=.625),t[m]=a[m]*M+v*T,t[m+1]=a[m+1]*M+y*T,t[m+2]=a[m+2]*M+b*T;else{var L=0,V=0,N=0,B=0,U=f[2*g],Z=U+f[2*g+1],G=0;for(S=U;S<Z;++S){var W=s[3+(k=4*_[S])];if(W!==o.Z.TRI_INDEX){G++;var j,z=s[k],X=s[k+1],K=s[k+2];L+=a[j=z===g?3*K:X===g?3*W:K===g?3*z:3*X],V+=a[j+1],N+=a[j+2]}}G!==Z-U?0!==G?(T=.5*(M=1/(1+.5*F+.25*G)),B=.25*M,t[m]=a[m]*M+v*T+L*B,t[m+1]=a[m+1]*M+y*T+V*B,t[m+2]=a[m+2]*M+b*T+N*B):(6===F?(T=.0625,M=.625):3===F?(T=.1875,M=.4375):(T=.375/F,M=.625),t[m]=a[m]*M+v*T,t[m+1]=a[m+1]*M+y*T,t[m+2]=a[m+2]*M+b*T):(4===F?(M=.5625,T=.09375,B=.015625):M=1-((T=1.5/(F*F))+(B=.25/(F*F)))*F,t[m]=a[m]*M+v*T+L*B,t[m+1]=a[m+1]*M+y*T+V*B,t[m+2]=a[m+2]*M+b*T+N*B)}}}},Bi=function(e,t,r,i,n){for(var a=e.getFaces(),s=e.getFaceEdges(),l=new Vi(e,t,r,i),u=0,c=e.getNbFaces();u<c;++u){var h,d,f,_,p,g=4*u,m=a[g],v=a[g+1],y=a[g+2],b=a[g+3],T=b!==o.Z.TRI_INDEX;T?(h=l.computeQuadEdgeVertex(m,v,y,b,s[g]),d=l.computeQuadEdgeVertex(v,y,b,m,s[g+1]),f=l.computeQuadEdgeVertex(y,b,m,v,s[g+2]),_=l.computeQuadEdgeVertex(b,m,v,y,s[g+3]),p=l.computeFaceVertex(m,v,y,b)):(h=l.computeTriangleEdgeVertex(m,v,y,s[g]),d=l.computeTriangleEdgeVertex(v,y,m,s[g+1]),f=l.computeTriangleEdgeVertex(y,m,v,s[g+2])),n&&(g*=4,T?(n[g+1]=n[g+4]=h,n[g+6]=n[g+9]=d,n[g+11]=n[g+14]=f,n[g+3]=n[g+12]=_,n[g+2]=n[g+7]=n[g+8]=n[g+13]=p,n[g]=m,n[g+5]=v,n[g+10]=y,n[g+15]=b):(n[g]=n[g+5]=n[g+8]=h,n[g+1]=n[g+10]=n[g+12]=d,n[g+2]=n[g+6]=n[g+14]=f,n[g+3]=n[g+7]=n[g+11]=n[g+15]=o.Z.TRI_INDEX,n[g+4]=m,n[g+9]=v,n[g+13]=y))}return l._tagEdges};Li.fullSubdivision=function(e,t){var r=e.getNbVertices()+e.getNbEdges()+e.getNbQuads();t.setVertices(new Float32Array(3*r)),t.setColors(new Float32Array(3*r)),t.setMaterials(new Float32Array(3*r)),t.setFaces(new Uint32Array(4*e.getNbFaces()*4)),Ni(e,t.getVertices(),t.getColors(),t.getMaterials());var i=Bi(e,t.getVertices(),t.getColors(),t.getMaterials(),t.getFaces());e.hasUV()&&function(e,t,r){var i=t.getNbVertices(),n=new Uint32Array(2*i);n.set(e.getVerticesDuplicateStartCount());var a=e.getFaces(),s=e.getFacesTexCoord(),l=3*t.getNbFaces(),u=e.getTexCoords(),c=new Float32Array(o.Z.getMemory(4*l*2),0,2*l),h=0,d=e.getNbVertices(),f=i-d;for(h=0;h<d;++h){var _=n[2*h];_>0&&(n[2*h]=_+f)}c.set(u),c.set(u.subarray(2*d),2*(d+f));var p=f+e.getNbTexCoords(),g=e.getFaceEdges(),m=new Uint32Array(r.length),v=new Uint32Array(r.length);for(d=a.length,h=0;h<d;++h){var y=g[h];if(y!==o.Z.TRI_INDEX){var b=(h+1)%4==0?h-3:h+1,T=s[h],M=s[b];M===o.Z.TRI_INDEX&&(M=s[h-2]);var S=r[y]-1,k=v[y],E=T>M?T:M,A=T<M?T:M;0!==k?k===E&&m[y]===A||(c[2*p]=.5*(u[2*T]+u[2*M]),c[2*p+1]=.5*(u[2*T+1]+u[2*M+1]),n[2*S]=p++,n[2*S+1]=1):(c[2*S]=.5*(u[2*T]+u[2*M]),c[2*S+1]=.5*(u[2*T+1]+u[2*M+1]),m[y]=A,v[y]=E)}}var C=new Float32Array(2*p);C.set(c.subarray(0,2*p)),t.setTexCoords(C),t.setVerticesDuplicateStartCount(n),function(e,t,r){for(var i=e.getFacesTexCoord(),n=t.getFaces(),a=new Uint32Array(n.length),s=e.getFaceEdges(),l=e.getNbVertices(),u=t.getNbVertices()-l,c=t.getVerticesDuplicateStartCount(),h=t.getTexCoords(),d=0,f=e.getNbFaces();d<f;++d){var _=4*d,p=i[_],g=i[_+1],m=i[_+2],v=i[_+3];p>=l&&(p+=u),g>=l&&(g+=u),m>=l&&(m+=u),v!==o.Z.TRI_INDEX&&v>=l&&(v+=u);var y=s[_],b=r[y]-1;b<0?b=c[2*(-b-1)]:c[2*b]>0&&(r[y]=-b);var T=r[y=s[_+1]]-1;T<0?T=c[2*(-T-1)]:c[2*T]>0&&(r[y]=-T);var M=r[y=s[_+2]]-1;if(M<0?M=c[2*(-M-1)]:c[2*M]>0&&(r[y]=-M),_*=4,v!==o.Z.TRI_INDEX){var S=r[y=s[4*d+3]]-1;S<0?S=c[2*(-S-1)]:c[2*S]>0&&(r[y]=-S),a[_+1]=a[_+4]=b,a[_+6]=a[_+9]=T,a[_+11]=a[_+14]=M,a[_+3]=a[_+12]=S,a[_+2]=a[_+7]=a[_+8]=a[_+13]=n[_+2],a[_]=p,a[_+5]=g,a[_+10]=m,a[_+15]=v;var k=2*n[_+2];h[k]=.25*(h[2*p]+h[2*g]+h[2*m]+h[2*v]),h[k+1]=.25*(h[2*p+1]+h[2*g+1]+h[2*m+1]+h[2*v+1])}else a[_]=a[_+5]=a[_+8]=b,a[_+1]=a[_+10]=a[_+12]=T,a[_+2]=a[_+6]=a[_+14]=M,a[_+3]=a[_+7]=a[_+11]=a[_+15]=o.Z.TRI_INDEX,a[_+4]=p,a[_+9]=g,a[_+13]=m}t.setFacesTexCoord(a)}(e,t,r)}(e,t,i),t.allocateArrays()},Li.partialSubdivision=function(e,t,r,i){Ni(e,t,r,i),Bi(e,t,r,i)};const Ui=Li;var Zi={importOBJ:function(e,t){for(var r=[],i=[],n=[],a=[],s=[],l=[],u=[],c=[],h=[],d=0,f=0,_=0,p=0,g=e.split("\n"),m=[],v=1/255,y=g.length,b=0;b<y;++b){var T=g[b].trim();if(0!==T.length){var M,S=T[0];if("v"===S)" "===(M=T[1])?(m=T.split(/\s+/),i.push(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])),m[4]&&n.push(parseFloat(m[4]),parseFloat(m[5]),parseFloat(m[6])),++_):"t"===M&&(m=T.split(/\s+/),u.push(parseFloat(m[1]),parseFloat(m[2])),++p);else if("f"===S){var k=(m=T.split(/\s+/)).length-1;if(k<3)continue;for(var E=Math.ceil(k/2)-1,A=0;A<E;++A){var C=A+1,w=A+2,R=k-C,x=k-A;R===w&&(R=x,x=o.Z.TRI_INDEX);var P,D=m[C].split("/"),I=m[w].split("/"),F=m[R].split("/"),O=x!==o.Z.TRI_INDEX;O&&(P=m[x].split("/"));var L=parseInt(D[0],10),V=parseInt(I[0],10),N=parseInt(F[0],10),B=O?parseInt(P[0],10):void 0;if((!O||B!==L&&B!==V&&B!==N)&&L!==V&&L!==N&&V!==N)if(L=(L<0?L+_:L-1)-d,V=(V<0?V+_:V-1)-d,N=(N<0?N+_:N-1)-d,O&&(B=(B<0?B+_:B-1)-d),c.push(L,V,N,O?B:o.Z.TRI_INDEX),D[1]){var U=parseInt(D[1],10),Z=parseInt(I[1],10),G=parseInt(F[1],10),W=O?parseInt(P[1],10):void 0;U=(U<0?U+p:U-1)-f,Z=(Z<0?Z+p:Z-1)-f,G=(G<0?G+p:G-1)-f,O&&(W=(W<0?W+p:W-1)-f),h.push(U,Z,G,O?W:o.Z.TRI_INDEX)}else h.length>0&&h.push(L,V,N,O?B:o.Z.TRI_INDEX)}}else if("#"===S){if("M"!==T[1])continue;if(T.startsWith("#MRGB "))for(var j=(m=T.split(/\s+/))[1],z=2,X=j.length;z<X;z+=8){var K=parseInt(j.substr(z,6),16);a.push((K>>16)*v,(K>>8&255)*v,(255&K)*v)}else if(T.startsWith("#MAT "))for(var H=(m=T.split(/\s+/))[1],Y=0,q=H.length;Y<q;Y+=6){var J=parseInt(H.substr(Y,6),16);l.push((J>>16)*v,(J>>8&255)*v,(255&J)*v)}}else T.startsWith("o ")&&(r.length>0&&(Zi.initMeshOBJ(r[r.length-1],i,c,n,s,u,h,a,l),d=_,f=p),r.push(new sr(t)))}}return 0===r.length&&(r[0]=new sr(t)),Zi.initMeshOBJ(r[r.length-1],i,c,n,s,u,h,a,l),r},initMeshOBJ:function(e,t,r,i,n,a,s,o,l){e.setVertices(new Float32Array(t)),e.setFaces(new Uint32Array(r)),o.length===t.length?e.setColors(new Float32Array(o)):i.length===t.length&&e.setColors(new Float32Array(i)),l.length===t.length?e.setMaterials(new Float32Array(l)):n.length===t.length&&e.setMaterials(new Float32Array(n)),a.length>0&&s.length===r.length&&e.initTexCoordsDataFromOBJData(a,s),t.length=r.length=0,o.length=i.length=0,l.length=n.length=0,a.length=s.length=0}};const Gi=Zi;var Wi={VERSION:3,exportSGL:function(e,t){var r,i=e.length,n=4*(9+31*i),a=0;for(a=0;a<i;++a)n+=4*(r=e[a]).getNbVertices()*3,r.getColors()&&(n+=4*r.getNbVertices()*3),r.getMaterials()&&(n+=4*r.getNbVertices()*3),n+=4*r.getNbFaces()*4,r.hasUV()&&(n+=4*r.getNbTexCoords()*2,n+=4*r.getNbFaces()*4);var s=new ArrayBuffer(n),o=new Float32Array(s),l=new Uint32Array(s),u=0;l[u++]=Wi.VERSION,l[u++]=t._showGrid,l[u++]=x.showSymmetryLine,l[u++]=t._showContour;var c=t.getCamera();for(l[u++]=c.getProjectionType(),l[u++]=c.getMode(),o[u++]=c.getFov(),l[u++]=c.getUsePivot(),l[u++]=i,a=0;a<i;++a){r=e[a],l[u++]=r.getShaderType(),l[u++]=r.getMatcap(),l[u++]=r.getShowWireframe(),l[u++]=r.getFlatShading(),o[u++]=r.getOpacity(),o.set(r.getCenter(),u),u+=3,o.set(r.getMatrix(),u),u+=16,o[u++]=r.getScale();var h=r.getNbVertices();l[u++]=h,o.set(r.getVertices().subarray(0,3*h),u),u+=3*h;var d=r.getColors()?h:0;l[u++]=d,d>0&&o.set(r.getColors().subarray(0,3*h),u),u+=3*d;var f=r.getMaterials()?h:0;l[u++]=f,f>0&&o.set(r.getMaterials().subarray(0,3*h),u),u+=3*f;var _=r.getNbFaces();l[u++]=_,l.set(r.getFaces().subarray(0,4*_),u),u+=4*_;var p=r.hasUV(),g=r.getNbTexCoords();l[u++]=p?g:0,p&&(o.set(r.getTexCoords().subarray(0,2*g),u),u+=2*g),l[u++]=p?_:0,p&&(l.set(r.getFacesTexCoord().subarray(0,4*_),u),u+=4*_)}var m=new DataView(s,0,4*u);return new Blob([m])}};const ji=Wi;var zi={},Xi=function(e){for(var t=new Uint32Array(e),r=t.length/4,i=0;i<r;++i){var n=4*i+3;e[n]<0&&(t[n]=o.Z.TRI_INDEX)}return t};zi.importSGL=function(e,t,r){var i=new Float32Array(e),n=new Uint32Array(e),a=new Int32Array(e),s=0,o=n[s++];if(o>ji.VERSION)return[];if(o>=2){r._showGrid=n[s++],x.showSymmetryLine=n[s++],r._showContour=n[s++];var l=r.getCamera();l.setProjectionType(n[s++]),l.setMode(n[s++]),l.setFov(i[s++]),l.setUsePivot(n[s++])}for(var u=n[s++],c=new Array(u),h=0;h<u;++h){var d=c[h]=new sr(t);if(o>=2){var f=d.getRenderData();f._shaderType=n[s++],f._matcap=n[s++],f._showWireframe=n[s++],f._flatShading=n[s++],f._alpha=i[s++]}d.getCenter().set(i.subarray(s,s+3)),s+=3,d.getMatrix().set(i.subarray(s,s+16)),s+=16,s++;var _=n[s++];d.setVertices(i.subarray(s,s+3*_)),s+=3*_,(_=n[s++])>0&&d.setColors(i.subarray(s,s+3*_)),s+=3*_,(_=n[s++])>0&&d.setMaterials(i.subarray(s,s+3*_)),s+=3*_,_=n[s++],o<=2?d.setFaces(Xi(a.subarray(s,s+4*_))):d.setFaces(n.subarray(s,s+4*_)),s+=4*_;var p=null;(_=n[s++])&&(p=i.subarray(s,s+2*_)),s+=2*_;var g=null;(_=n[s++])&&(g=o<=2?Xi(a.subarray(s,s+4*_)):n.subarray(s,s+4*_)),s+=4*_,p&&g&&d.initTexCoordsDataFromOBJData(p,g)}return c};const Ki=zi;var Hi={},Yi=function(e){switch(e){case"uchar":case"char":case"int8":case"uint8":return 1;case"ushort":case"short":case"int16":case"uint16":return 2;case"uint":case"int":case"float":case"int32":case"uint32":case"float32":return 4;case"double":case"float64":return 8;default:return 0}},qi=function(e,t){var r=t?1/255:1;switch(e){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return function(e){return parseInt(e,10)*r};case"float":case"double":case"float32":case"float64":return parseFloat;default:return function(e){return e}}},Ji=function(e,t,r){var i=r?1/255:1,n=t.offsetOctet;switch(t.type){case"int8":case"char":return function(t){return e.getInt8(t+n)*i};case"uint8":case"uchar":return function(t){return e.getUint8(t+n)*i};case"int16":case"short":return function(t){return e.getInt16(t+n,!0)*i};case"uint16":case"ushort":return function(t){return e.getUint16(t+n,!0)*i};case"int32":case"int":return function(t){return e.getInt32(t+n,!0)*i};case"uint32":case"uint":return function(t){return e.getUint32(t+n,!0)*i};case"float32":case"float":return function(t){return e.getFloat32(t+n,!0)};case"float64":case"double":return function(t){return e.getFloat64(t+n,!0)}}},Qi=function(e,t){var r=e.properties,i=e.objProperties={};e.offsetOctet=0;for(var n=0,a=r.length;n<a;++n){var s=r[n],o=i[s.name]={};o.type=s.type,o.type2=s.type2,t.isBinary?(o.offsetOctet=e.offsetOctet,e.offsetOctet+=Yi(s.type)):o.id=n}},$i=function(e,t){Qi(e,t);var r,i=t.vertices=new Float32Array(3*e.count),n=e.objProperties;(n.red||n.green||n.blue)&&(r=t.colors=new Float32Array(3*e.count)),t.isBinary?function(e,t,r,i){var n,a,s,o=e.count,l=e.objProperties,u=e.offsetOctet,c=u*o,h=new DataView(t.buffer,t.offsetOctet,c),d=Ji(h,l.x,!0),f=Ji(h,l.y,!0),_=Ji(h,l.z,!0);l.red&&(n=Ji(h,l.red,!0)),l.green&&(a=Ji(h,l.green,!0)),l.blue&&(s=Ji(h,l.blue,!0));for(var p=0;p<o;++p){var g=3*p,m=p*u;r[g]=d(m),r[g+1]=f(m),r[g+2]=_(m),n&&(i[g]=n(m)),a&&(i[g+1]=a(m)),s&&(i[g+2]=s(m))}t.offsetOctet+=c}(e,t,i,r):function(e,t,r,i){var n,a,s,o,l,u,c=e.count,h=t.lines,d=e.objProperties,f=t.offsetLine,_=qi(d.x.type,!0),p=qi(d.y.type,!0),g=qi(d.z.type,!0),m=d.x.id,v=d.y.id,y=d.z.id;d.red&&(n=qi(d.red.type,!0)),d.green&&(a=qi(d.green.type,!0)),d.blue&&(s=qi(d.blue.type,!0)),d.red&&(o=d.red.id),d.green&&(l=d.green.id),d.blue&&(u=d.blue.id);for(var b=0;b<c;++b){var T=3*b,M=h[f+b].trim().split(/\s+/);r[T]=_(M[m]),r[T+1]=p(M[v]),r[T+2]=g(M[y]),n&&(i[T]=n(M[o])),a&&(i[T+1]=a(M[l])),s&&(i[T+2]=s(M[u]))}t.offsetLine+=c}(e,t,i,r)},en=function(e,t,r,i){for(var n=e.count,a=e.objProperties,s=a&&(a.vertex_index||a.vertex_indices)||e.properties[0],l=new DataView(t.buffer,t.offsetOctet),u=Ji(l,s),c=Ji(l,{type:s.type2,offsetOctet:s.offsetOctet+Yi(s.type)}),h=Yi(s.type2),d=e.offsetOctet,f=0,_=0,p=0;p<n;++p){var g=u(f);3!==g&&4!==g||(r[_++]=c(f),r[_++]=c(f+h),r[_++]=c(f+2*h),r[_++]=3===g?o.Z.TRI_INDEX:c(f+3*h)),f+=g*h+d}i||(t.faces=r.subarray(0,_)),t.offsetOctet+=f},tn=function(e,t){Qi(e,t);var r=t.faces=new Uint32Array(4*e.count);t.isBinary?en(e,t,r):function(e,t,r){for(var i=e.count,n=t.lines,a=e.objProperties,s=t.offsetLine,l=a.vertex_index||a.vertex_indices,u=qi(l.type),c=qi(l.type2),h=l.id,d=0,f=0;f<i;++f){var _=n[s+f].trim().split(/\s+/),p=u(_[0]);3!==p&&4!==p||(r[d]=c(_[h+1]),r[d+1]=c(_[h+2]),r[d+2]=c(_[h+3]),r[d+3]=4===p?c(_[h+4]):o.Z.TRI_INDEX,d+=4)}t.offsetLine+=i}(e,t,r)},rn=function(e,t){var r=e.count;t.isBinary?en(e,t,[],!0):t.offsetLine+=r};Hi.importPLY=function(e,t){for(var r=function(e){for(var t,r=o.Z.ab2str(e).split("\n"),i={isBinary:!1,start:0,elements:[],lines:r,buffer:e,vertices:null,faces:null,colors:null,offsetLine:0,offsetOctet:0},n=0;;){var a=r[n++];if(i.offsetOctet+=a.length+1,i.offsetLine=n,(a=a.trim()).startsWith("format binary"))i.isBinary=!0;else if(a.startsWith("element"))t=a.split(/\s+/),i.elements.push({name:t[1],count:parseInt(t[2],10),properties:[]});else if(a.startsWith("property")){var s="list"===(t=a.split(/\s+/))[1];i.elements[i.elements.length-1].properties.push({type:t[s?2:1],type2:s?t[3]:void 0,name:t[s?4:2]})}else if(a.startsWith("end_header"))break}return i}(e),i=r.elements,n=0,a=i.length;n<a;++n){var s=i[n];"vertex"===s.name?$i(s,r):"face"===s.name?tn(s,r):rn(s,r)}var l=new sr(t);return l.setVertices(r.vertices),l.setFaces(r.faces),l.setColors(r.colors),[l]};const nn=Hi;var an={importSTL:function(e,t){var r,i=new Uint32Array(e,80,1)[0]||0,n=84+50*i===e.byteLength,a=n?an.importBinarySTL(e,i):an.importAsciiSTL(o.Z.ab2str(e));n&&(r=a[1],a=a[0]),i=a.length/9;for(var s=new Map,l=[0],u=new Uint32Array(4*i),c=0;c<i;++c){var h=4*c,d=9*c;u[h]=an.detectNewVertex(s,a,r,d,l),u[h+1]=an.detectNewVertex(s,a,r,d+3,l),u[h+2]=an.detectNewVertex(s,a,r,d+6,l),u[h+3]=o.Z.TRI_INDEX}var f=new sr(t);return f.setVertices(a.subarray(0,3*l[0])),r&&f.setColors(r.subarray(0,3*l[0])),f.setFaces(u),[f]},detectNewVertex:function(e,t,r,i,n){var a=t[i],s=t[i+1],o=t[i+2],l=a+"+"+s+"+"+o,u=e.get(l);if(void 0===u){u=n[0],e.set(l,u);var c=3*u;t[c]=a,t[c+1]=s,t[c+2]=o,r&&(r[c]=r[i],r[c+1]=r[i+1],r[c+2]=r[i+2]),n[0]++}return u},importAsciiSTL:function(e){for(var t=e.split("\n"),r=t.length,i=new Float32Array(Math.ceil(9*r/7)),n=0,a=0;a<r;++a)if(t[a].trim().startsWith("facet")){var s=t[a+2].trim().split(/\s+/);i[n++]=parseFloat(s[1]),i[n++]=parseFloat(s[2]),i[n++]=parseFloat(s[3]),s=t[a+3].trim().split(/\s+/),i[n++]=parseFloat(s[1]),i[n++]=parseFloat(s[2]),i[n++]=parseFloat(s[3]),s=t[a+4].trim().split(/\s+/),i[n++]=parseFloat(s[1]),i[n++]=parseFloat(s[2]),i[n++]=parseFloat(s[3])}return i.subarray(0,n)},importBinarySTL:function(e,t){var r=new Uint8Array(e),i=r.subarray(0,80),n=-1!==String.fromCharCode.apply(null,i).indexOf("COLOR="),a=0,s=new Uint8Array(36*t),o=new Uint8Array(2*t),l=96,u=0,c=0;for(a=0;a<t;a++){for(var h=0;h<36;++h)s[u++]=r[l++];o[c++]=r[l++],o[c++]=r[l++],l+=12}var d=new Uint16Array(o.buffer);o=new Float32Array(9*t);var f=1/31;for(a=0;a<t;++a){u=9*a;var _=d[a],p=1,g=1,m=1,v=32768&_;n?v||(p=(31&_)*f,g=(_>>5&31)*f,m=(_>>10&31)*f):v&&(p=(_>>10&31)*f,g=(_>>5&31)*f,m=(31&_)*f),o[u]=o[u+3]=o[u+6]=p,o[u+1]=o[u+4]=o[u+7]=g,o[u+2]=o[u+5]=o[u+8]=m}return[new Float32Array(s.buffer),o]}};const sn=an,on={importOBJ:Gi.importOBJ,importSGL:Ki.importSGL,importPLY:nn.importPLY,importSTL:sn.importSTL};var ln=r(88),un=r.n(ln);function cn(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const hn=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=r._main,this._menu=null,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){var t=this._menu=e.addMenu((0,V.Z)("backgroundTitle"));t.domContainer&&(t.domContainer.style.display="none"),this._bg=this._main.getBackground(),t.addCombobox("Type",this._bg._type,this.onBackgroundType.bind(this),["Image","Environment","Ambient env"]),this._ctrlBlur=t.addSlider("Blur",this._bg._blur,this.onEnvBlur.bind(this),0,1,.01),this._ctrlBlur.setVisibility(1===this._bg._type),t.addTitle("Image"),t.addButton((0,V.Z)("backgroundReset"),this,"resetBackground"),t.addButton((0,V.Z)("backgroundImport"),this,"importBackground"),t.addCheckbox((0,V.Z)("backgroundFill"),this._main.getBackground()._fill,this.updateFill.bind(this))}},{key:"updateFill",value:function(e){this._bg._fill=e,this._main.onCanvasResize()}},{key:"resetBackground",value:function(){this._bg.deleteTexture(),this._main.render()}},{key:"onEnvBlur",value:function(e){this._bg._blur=e,this._main.render()}},{key:"onBackgroundType",value:function(e){this._bg.setType(e),this._main.onCanvasResize(),this._main.render(),this._ctrlBlur.setVisibility(1===e)}},{key:"importBackground",value:function(){document.getElementById("backgroundopen").click()}}])&&cn(t.prototype,r),e}();function dn(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const fn=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=r._main,this._menu=null,this._camera=this._main.getCamera(),this._cameraTimer=-1,this._cbTranslation=this.cbOnTranslation.bind(this),this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){var t=this._camera,r=this._menu=e.addMenu((0,V.Z)("cameraTitle"));r.addTitle((0,V.Z)("cameraReset")),r.addDualButton((0,V.Z)("cameraCenter"),(0,V.Z)("cameraFront"),this.resetCamera.bind(this),this.resetFront.bind(this)),r.addDualButton((0,V.Z)("cameraLeft"),(0,V.Z)("cameraTop"),this.resetLeft.bind(this),this.resetTop.bind(this)),this._ctrlProjectionTitle=r.addTitle((0,V.Z)("cameraProjection"));var i=[];i[s.Z.Projection.PERSPECTIVE]=(0,V.Z)("cameraPerspective"),i[s.Z.Projection.ORTHOGRAPHIC]=(0,V.Z)("cameraOrthographic"),this._ctrlProjection=r.addCombobox("",t.getProjectionType(),this.onCameraTypeChange.bind(this),i),this._ctrlFov=r.addSlider((0,V.Z)("cameraFov"),t.getFov(),this.onFovChange.bind(this),10,90,1),this._ctrlFov.setVisibility(t.getProjectionType()===s.Z.Projection.PERSPECTIVE),r.addTitle((0,V.Z)("cameraMode"));var n=[];n[s.Z.CameraMode.ORBIT]=(0,V.Z)("cameraOrbit"),n[s.Z.CameraMode.SPHERICAL]=(0,V.Z)("cameraSpherical"),n[s.Z.CameraMode.PLANE]=(0,V.Z)("cameraPlane"),r.addCombobox("",t.getMode(),this.onCameraModeChange.bind(this),n),this._ctrlPivot=r.addCheckbox((0,V.Z)("cameraPivot"),t.getUsePivot(),this.onPivotChange.bind(this)),r.addSlider("speed",this._main,"_cameraSpeed",.05,1,.001)}},{key:"onCameraModeChange",value:function(e){this._camera.setMode(e),this._main.render()}},{key:"onCameraTypeChange",value:function(e){this._camera.setProjectionType(e),this._ctrlFov.setVisibility(e===s.Z.Projection.PERSPECTIVE),this._main.render()}},{key:"onFovChange",value:function(e){this._camera.setFov(e),this._main.render()}},{key:"onKeyDown",value:function(e){if(!0!==e.handled&&(e.stopPropagation(),!this._main._focusGui)){e.preventDefault();var t=this._main,r=t.getCamera();switch(e.handled=!0,e.shiftKey&&t._action===s.Z.Action.CAMERA_ROTATE&&(r.snapClosestRotation(),t.render()),u.Z.getShortKey(e.which)){case s.Z.KeyAction.STRIFE_LEFT:r._moveX=-1;break;case s.Z.KeyAction.STRIFE_RIGHT:r._moveX=1;break;case s.Z.KeyAction.STRIFE_UP:r._moveZ=-1;break;case s.Z.KeyAction.STRIFE_DOWN:r._moveZ=1;break;default:e.handled=!1}!0===e.handled&&-1===this._cameraTimer&&(this._cameraTimer=window.setInterval(this._cbTranslation,16.6))}}},{key:"cbOnTranslation",value:function(){var e=this._main;e.getCamera().updateTranslation(),e.render()}},{key:"onKeyUp",value:function(e){if(!0!==e.handled&&(e.stopPropagation(),!this._main._focusGui)){e.preventDefault(),e.handled=!0;var t=this._camera;switch(u.Z.getShortKey(e.which)){case s.Z.KeyAction.STRIFE_LEFT:case s.Z.KeyAction.STRIFE_RIGHT:t._moveX=0;break;case s.Z.KeyAction.STRIFE_UP:case s.Z.KeyAction.STRIFE_DOWN:t._moveZ=0;break;case s.Z.KeyAction.CAMERA_RESET:this.resetCamera();break;case s.Z.KeyAction.CAMERA_FRONT:this.resetFront();break;case s.Z.KeyAction.CAMERA_TOP:this.resetTop();break;case s.Z.KeyAction.CAMERA_LEFT:this.resetLeft();break;default:e.handled=!1}-1!==this._cameraTimer&&0===t._moveX&&0===t._moveZ&&(clearInterval(this._cameraTimer),this._cameraTimer=-1)}}},{key:"resetCamera",value:function(){this._camera.resetView(),this._main.render()}},{key:"resetFront",value:function(){this._camera.toggleViewFront(),this._main.render()}},{key:"resetLeft",value:function(){this._camera.toggleViewLeft(),this._main.render()}},{key:"resetTop",value:function(){this._camera.toggleViewTop(),this._main.render()}},{key:"onPivotChange",value:function(){this._camera.toggleUsePivot(),this._main.render()}}])&&dn(t.prototype,r),e}();function _n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const pn=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._ctrlGui=r,this._menu=null,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){this._langs=Object.keys(V.Z.languages),this._menu=e.addMenu("Language"),this._menu.addCombobox("",this._langs.indexOf(V.Z.select),this.onLangChange.bind(this),this._langs),this._menu.domContainer&&(this._menu.domContainer.style.display="none")}},{key:"onLangChange",value:function(e){V.Z.select=this._langs[parseInt(e,10)],this._ctrlGui.initGui()}}])&&_n(t.prototype,r),e}();var gn=r(652),mn=r(141),vn={exportOBJ:function(e){for(var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i="s 0\n",n=[1,1],a=0,s=e.length;a<s;++a)i+="o mesh_"+a+"\n",i=vn.addMesh(e[a],i,n,t,r);return new Blob([i])}},yn=function(e,t,r){for(var i=0,n=t.length;i<n;i++)e[r++]=t.charCodeAt(i);return r};vn.addMesh=function(e,t,r,n,a){var s=e.getVertices(),l=e.getColors(),u=e.getMaterials(),c=e.getFaces(),h=e.getNbVertices(),d=e.getNbFaces(),f=e.getNbTexCoords(),_=e.getMatrix(),p=0,g=0,m="",v=0;v=a?128*h:79*h,v+=45*f+66*d;var y=new Uint8Array(Math.max(1e3,v)),b=0,T=[0,0,0];for(p=0;p<h;++p)g=3*p,T[0]=s[g],T[1]=s[g+1],T[2]=s[g+2],i.fF(T,T,_),m="v "+T[0]+" "+T[1]+" "+T[2],m+=a?" "+l[g]+" "+l[g+1]+" "+l[g+2]+"\n":"\n",b=yn(y,m,b);if(n){var M=Math.ceil(h/64);for(p=0;p<M;++p){m="#MRGB ",g=64*p;for(var S=p===M-1?h:g+64;g<S;++g){m+="ff";var k=3*g,E=Math.round(255*l[k]).toString(16),A=Math.round(255*l[k+1]).toString(16),C=Math.round(255*l[k+2]).toString(16);m+=1===E.length?"0"+E:E,m+=1===A.length?"0"+A:A,m+=1===C.length?"0"+C:C}b=yn(y,m+="\n",b)}for(M=Math.ceil(h/46),p=0;p<M;++p){m="#MAT ",g=46*p;for(var w=p===M-1?h:g+46;g<w;++g){var R=3*g,x=Math.round(255*u[R]).toString(16),P=Math.round(255*u[R+1]).toString(16),D=Math.round(255*u[R+2]).toString(16);m+=1===x.length?"0"+x:x,m+=1===P.length?"0"+P:P,m+=1===D.length?"0"+D:D}b=yn(y,m+="\n",b)}}var I=e.getFacesTexCoord(),F=e.getTexCoords(),O=e.hasUV();if(O)for(p=0;p<f;++p)m="vt "+F[g=2*p]+" "+F[g+1]+"\n",b=yn(y,m,b);var L=r[0],V=r[1];for(r[0]+=h,r[1]+=f,p=0;p<d;++p){var N=c[3+(g=4*p)];O?(m="f "+(L+c[g])+"/"+(V+I[g]),m+=" "+(L+c[g+1])+"/"+(V+I[g+1]),m+=" "+(L+c[g+2])+"/"+(V+I[g+2]),m+=N!==o.Z.TRI_INDEX?" "+(L+N)+"/"+(V+I[g+3])+"\n":"\n"):(m="f "+(L+c[g]),m+=" "+(L+c[g+1]),m+=" "+(L+c[g+2]),m+=N!==o.Z.TRI_INDEX?" "+(L+N)+"\n":"\n"),b=yn(y,m,b)}if(y=y.subarray(0,b),window.TextDecoder)return t+(new TextDecoder).decode(y);for(p=0;p<b;++p)t+=String.fromCharCode(y[p]);return t};const bn=vn;var Tn={},Mn=function(e){return Gr.mergeArrays(e,{vertices:null,colors:null,faces:null})};Tn.exportAsciiPLY=function(e){var t=Mn(e),r=t.nbVertices,i=t.nbFaces,n=t.vertices,a=t.colors,s=t.faces,l=0,u=0,c="ply\nformat ascii 1.0\ncomment created by SculptGL\n";for(c+="element vertex "+r+"\n",c+="property float x\nproperty float y\nproperty float z\n",c+="property uchar red\nproperty uchar green\nproperty uchar blue\n",c+="element face "+i+"\n",c+="property list uchar uint vertex_indices\nend_header\n",l=0;l<r;++l)c+=n[u=3*l]+" "+n[u+1]+" "+n[u+2]+" "+(255*a[u]|0)+" "+(255*a[u+1]|0)+" "+(255*a[u+2]|0)+"\n";for(l=0;l<i;++l){var h=s[3+(u=4*l)],d=h!==o.Z.TRI_INDEX;c+=(d?"4 ":"3 ")+s[u]+" "+s[u+1]+" "+s[u+2]+(d?" "+h+"\n":"\n")}return new Blob([c])},Tn.exportBinaryPLY=function(e,t){var r=Mn(e),i=r.nbVertices,n=r.nbFaces,a=r.nbQuads,s=r.nbTriangles,l=r.vertices,u=r.colors,c=r.faces,h=0,d=0,f=0;if(t&&t.swapXY)for(h=0;h<i;++h){var _=l[1+(f=3*h)];l[f+1]=-l[f+2],l[f+2]=_}var p="ply\nformat binary_"+(o.Z.littleEndian?"little":"big")+"_endian 1.0\ncomment created by SculptGL\n";p+="element vertex "+i+"\n",p+="property float x\nproperty float y\nproperty float z\n",p+="property uchar red\nproperty uchar green\nproperty uchar blue\n",p+="element face "+n+"\n",p+="property list uchar uint vertex_indices\nend_header\n";var g=4*l.length+u.length,m=4*(4*a+3*s)+n,v=p.length+g+2*m,y=new Uint8Array(v),b=new DataView(y.buffer);d=p.length;var T=0;for(T=0;T<d;++T)y[T]=p.charCodeAt(T);for(h=0;h<i;++h)d=3*h,b.setFloat32(T,l[d],!0),T+=4,b.setFloat32(T,l[d+1],!0),T+=4,b.setFloat32(T,l[d+2],!0),T+=4,b.setUint8(T,Math.round(255*u[d])),T+=1,b.setUint8(T,Math.round(255*u[d+1])),T+=1,b.setUint8(T,Math.round(255*u[d+2])),T+=1;for(h=0;h<n;++h){var M=c[3+(d=4*h)]!==o.Z.TRI_INDEX;b.setUint8(T,M?4:3),T+=1,b.setUint32(T,c[d],!0),T+=4,b.setUint32(T,c[d+1],!0),T+=4,b.setUint32(T,c[d+2],!0),T+=4,M&&(b.setUint32(T,c[d+3],!0),T+=4)}return new Blob([y])};const Sn=Tn;var kn={},En=function(e){for(var t=Gr.mergeArrays(e,{vertices:null,colors:null,triangles:null}),r=t.vertices,n=t.triangles,a=i.Ue(),s=i.Ue(),o=i.Ue(),l=t.faceNormals=new Float32Array(3*t.nbTriangles),u=0;u<t.nbTriangles;++u){var c=3*u,h=3*n[c],d=3*n[c+1],f=3*n[c+2];i.t8(a,r[h],r[h+1],r[h+2]),i.t8(s,r[d],r[d+1],r[d+2]),i.t8(o,r[f],r[f+1],r[f+2]),i.lu(s,s,a),i.lu(o,o,s),i.kC(a,s,o),i.Fv(a,a),l[c]=a[0],l[c+1]=a[1],l[c+2]=a[2]}return t};kn.exportAsciiSTL=function(e){for(var t=En(e),r=t.nbTriangles,i=t.vertices,n=t.triangles,a=t.faceNormals,s="solid mesh\n",o=0;o<r;++o){var l=3*o;s+=" facet normal "+a[l]+" "+a[l+1]+" "+a[l+2]+"\n",s+=" outer loop\n";var u=3*n[l],c=3*n[l+1],h=3*n[l+2];s+=" vertex "+i[u]+" "+i[u+1]+" "+i[u+2]+"\n",s+=" vertex "+i[c]+" "+i[c+1]+" "+i[c+2]+"\n",s+=" vertex "+i[h]+" "+i[h+1]+" "+i[h+2]+"\n",s+=" endloop\n",s+=" endfacet\n"}return s+="endsolid mesh\n",new Blob([s])},kn.exportBinarySTL=function(e,t){var r,i,n=En(e),a=n.nbTriangles,s=n.vertices,o=n.colors,l=n.triangles,u=n.faceNormals;if(t&&t.swapXY){var c=n.nbVertices;for(r=0;r<c;++r){var h=s[1+(i=3*r)];s[i+1]=-s[i+2],s[i+2]=h}}var d=new Uint8Array(84+50*a),f=t&&t.colorMagic;if(f){var _=[67,79,76,79,82,61,255,255,255,255];for(r=0;r<_.length;++r)d[r]=_[r]}new DataView(d.buffer).setUint32(80,a,!0);var p=new Uint8Array(s.buffer),g=new Uint8Array(u.buffer),m=84,v=0,y=f?0:32768,b=31/3;for(r=0;r<a;++r){for(i=12*r,v=0;v<12;++v)d[m++]=g[i++];var T=3*l[i=3*r],M=3*l[i+1],S=3*l[i+2],k=4*T;for(v=0;v<12;++v)d[m++]=p[k++];var E=4*M;for(v=0;v<12;++v)d[m++]=p[E++];var A=4*S;for(v=0;v<12;++v)d[m++]=p[A++];var C=Math.round((o[T]+o[M]+o[S])*b),w=Math.round((o[T+1]+o[M+1]+o[S+1])*b)<<5,R=Math.round((o[T+2]+o[M+2]+o[S+2])*b);f?R<<=10:C<<=10;var x=C+w+R+y;d[m++]=255&x,d[m++]=x>>8}return new Blob([d])};const An=kn;var Cn=r(751),wn=r.n(Cn);function Rn(e){return(Rn="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)}var xn={exportSketchfab:function(e,t){if(window.sketchfabOAuth2Config){var r=new XMLHttpRequest;return new(wn())(window.sketchfabOAuth2Config).connect().then((function(i){!function(e,t,r,i){e.open("POST","https://api.sketchfab.com/v2/models",!0),e.onprogress=function(e){if(e.lengthComputable&&e.total){var t=Math.round(100*e.loaded/e.total);i.setVisibility("Sketchfab upload: "+t+"%")}};var n=function(){i.setMessage("")};e.onerror=n,e.onabort=n,e.onload=function(){n();var t=JSON.parse(e.responseText),i=t.uid;i?(window.prompt((0,V.Z)("sketchfabUploadProcessing"),"https://sketchfab.com/models/"+i),function e(){var t=new XMLHttpRequest,n="https://api.sketchfab.com/v2/models/"+i+"/status";"object"===Rn(r)&&r.hasOwnProperty("token_type")&&"Bearer"===r.token_type?(t.open("GET",n,!0),t.setRequestHeader("Authorization","Bearer "+r.access_token)):t.open("GET",n+"?token="+r,!0),t.onload=function(){var r=JSON.parse(t.responseText);"FAILED"===r.processing?window.alert((0,V.Z)("sketchfabUploadError",r.warning.generic.join("\n"))):"SUCCEEDED"===r.processing?window.prompt((0,V.Z)("sketchfabUploadSuccess"),"https://sketchfab.com/models/"+i):window.setTimeout(e,5e3)},t.send()}()):window.alert((0,V.Z)("sketchfabUploadError",t.detail))},i.setMessage("Creating zip..."),mn.zip.useWebWorkers=!0,mn.zip.workerScriptsPath="worker/",mn.zip.createWriter(new mn.zip.BlobWriter("application/zip"),(function(n){var a=Sn.exportBinaryPLY(t.getMeshes(),{swapXY:!0});n.add("yourMesh.ply",new mn.zip.BlobReader(a),(function(){n.close(xn.exportFileSketchfab.bind(this,r,e,i))}))}),onerror)}(r,e,i,t)})).catch((function(e){console.error(e)})),r}},exportFileSketchfab:function(e,t,r,i){if(!t.isAborted){var n=new FormData;n.append("modelFile",i,"sculptglModel.zip"),n.append("name","My model"),n.append("tags","sculptgl"),"object"===Rn(e)&&e.hasOwnProperty("token_type")&&"Bearer"===e.token_type?t.setRequestHeader("Authorization","Bearer "+e.access_token):n.append("token",e),r.setMessage("Sketchfab upload..."),t.send(n)}}};const Pn=xn;var Dn={exportSculpteo:function(e,t){var r=new XMLHttpRequest;r.open("POST","uploadSculpteo.php",!0),r.onprogress=function(e){if(e.lengthComputable&&e.total){var r=Math.round(100*e.loaded/e.total);t.setMessage("Sculpteo upload: "+r+"%")}};var i=function(){t.setMessage("")};r.onerror=i,r.onabort=i,r.onload=function(){if(i(),200===this.status){var e=r.responseText.match(/\/print\/(.+?)(?=")/);e&&window.open("https://www.sculpteo.com/en"+e[0],"_blank")}};var n=e.getMeshes(),a=e.computeBoundingBoxMeshes(n),s=e.computeRadiusFromBoundingBox(a),o=Sn.exportBinaryPLY(n,{swapXY:!0});return t.setMessage("Creating zip..."),mn.zip.useWebWorkers=!0,mn.zip.workerScriptsPath="worker/",mn.zip.createWriter(new mn.zip.BlobWriter("application/zip"),(function(e){e.add("yourMesh.ply",new mn.zip.BlobReader(o),(function(){e.close(Dn.exportFileSculpteo.bind(this,s,r,t))}))}),onerror),r},exportFileSculpteo:function(e,t,r,i){if(!t.isAborted){var n=new FormData;n.append("file",i),n.append("name","fromSculptgl"),n.append("scale",4/e),r.setMessage("Sculpteo upload..."),t.send(n)}}};const In=Dn;var Fn={exportMaterialise:function(e,t){var r=new XMLHttpRequest;r.open("POST","https://i.materialise.com/web-api/tool/20cc0fd6-3cef-4111-a201-0b87026d892c/model",!0),r.onprogress=function(e){if(e.lengthComputable&&e.total){var r=Math.round(100*e.loaded/e.total);t.setMessage("Materialise upload: "+r+"%")}};var i=function(){t.setMessage("")};r.onerror=i,r.onabort=i,r.onload=function(){if(i(),200===r.status){var e=JSON.parse(r.responseText);window.open("https://i.materialise.com/en/3dprint#modelId="+e.modelID,"_blank")}};var n=e.getMeshes(),a=e.computeBoundingBoxMeshes(n),s=e.computeRadiusFromBoundingBox(a),o=An.exportBinarySTL(n,{colorMagic:!0,swapXY:!0});return t.setMessage("Creating zip..."),mn.zip.useWebWorkers=!0,mn.zip.workerScriptsPath="worker/",mn.zip.createWriter(new mn.zip.BlobWriter("application/zip"),(function(e){e.add("yourMesh.stl",new mn.zip.BlobReader(o),(function(){e.close(Fn.exportFileMaterialise.bind(this,s,r,t))}))}),onerror),r},exportFileMaterialise:function(e,t,r,i){if(!t.isAborted){var n=new FormData;n.append("file",i,"yourMesh.zip"),r.setMessage("Materialise upload..."),t.send(n)}}};const On=Fn;var Ln={};Ln.exportOBJ=bn.exportOBJ,Ln.exportSGL=ji.exportSGL,Ln.exportAsciiPLY=Sn.exportAsciiPLY,Ln.exportBinaryPLY=Sn.exportBinaryPLY,Ln.exportAsciiSTL=An.exportAsciiSTL,Ln.exportBinarySTL=An.exportBinarySTL,Ln.exportSketchfab=Pn.exportSketchfab,Ln.exportSculpteo=In.exportSculpteo,Ln.exportMaterialise=On.exportMaterialise;const Vn=Ln;var Nn={_gl:null,_checkRTT:{},_webGLExtensions:{}};Nn.HALF_FLOAT=Nn.HALF_FLOAT_OES=36193,Nn.checkRTTSupport=function(e,t){var r=Nn._gl;if(void 0===r)return!1;var i=e+","+t;if(void 0!==Nn._checkRTT[i])return Nn._checkRTT[i];var n=r.createTexture();r.bindTexture(r.TEXTURE_2D,n),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,2,2,0,r.RGBA,e,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,t);var a=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,a),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,n,0);var s=Nn._checkRTT[i]=r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE;return r.deleteTexture(n),r.deleteFramebuffer(a),r.bindTexture(r.TEXTURE_2D,null),r.bindFramebuffer(r.FRAMEBUFFER,null),s},Nn.hasRTTLinearHalfFloat=function(){return Nn._webGLExtensions.OES_texture_half_float_linear&&Nn.checkRTTSupport(Nn.HALF_FLOAT,Nn._gl.LINEAR)},Nn.hasRTTLinearFloat=function(){return Nn._webGLExtensions.OES_texture_float_linear&&Nn.checkRTTSupport(Nn._gl.FLOAT,Nn._gl.LINEAR)},Nn.hasRTTHalfFloat=function(){return Nn._webGLExtensions.OES_texture_half_float&&Nn.checkRTTSupport(Nn.HALF_FLOAT,Nn._gl.NEAREST)},Nn.hasRTTFloat=function(){return Nn._webGLExtensions.OES_texture_float&&Nn.checkRTTSupport(Nn._gl.FLOAT,Nn._gl.NEAREST)},Nn.getWebGLExtension=function(e){return Nn._webGLExtensions[e]},Nn.getWebGLExtensions=function(){return Nn._webGLExtensions},Nn.initWebGLExtensions=function(e){Nn._gl=e;for(var t=e.getSupportedExtensions(),r=Nn._webGLExtensions,i=0,n=t.length;i<n;++i){var a=t[i];r[a]=e.getExtension(a)}};const Bn=Nn;function Un(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Zn(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Gn;const Wn=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.createRenderbuffer(),n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Un(this,e),this._gl=t,this._texture=t.createTexture(),this._depth=i,this._framebuffer=t.createFramebuffer(),this._shaderType=r,this._invSize=new Float32Array(2),this._vertexBuffer=null,n&&Bn.hasRTTHalfFloat()?this._type=Bn.HALF_FLOAT_OES:n&&Bn.hasRTTFloat()?this._type=t.FLOAT:this._type=t.UNSIGNED_BYTE,this.setWrapRepeat(!1),this.setFilterNearest(!1),this.init()}var t,r;return t=e,(r=[{key:"getGL",value:function(){return this._gl}},{key:"getVertexBuffer",value:function(){return this._vertexBuffer}},{key:"getFramebuffer",value:function(){return this._framebuffer}},{key:"getTexture",value:function(){return this._texture}},{key:"getDepth",value:function(){return this._depth}},{key:"getInverseSize",value:function(){return this._invSize}},{key:"init",value:function(){var e=this._gl;Gn||(Gn=new g(e,e.ARRAY_BUFFER,e.STATIC_DRAW)).update(new Float32Array([-1,-1,4,-1,-1,4])),this._vertexBuffer=Gn}},{key:"setWrapRepeat",value:function(e){this._wrapRepeat=e}},{key:"setFilterNearest",value:function(e){this._filterNearest=e}},{key:"onResize",value:function(e,t){var r=this._gl;this._invSize[0]=1/e,this._invSize[1]=1/t,r.bindTexture(r.TEXTURE_2D,this._texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,e,t,0,r.RGBA,this._type,null);var i=this._filterNearest?r.NEAREST:r.LINEAR;r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,i);var n=this._wrapRepeat?r.REPEAT:r.CLAMP_TO_EDGE;r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,n),this._depth&&(r.bindRenderbuffer(r.RENDERBUFFER,this._depth),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,e,t)),r.bindFramebuffer(r.FRAMEBUFFER,this._framebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,this._texture,0),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,this._depth),r.bindTexture(r.TEXTURE_2D,null)}},{key:"release",value:function(){this._texture&&this._gl.deleteTexture(this._texture),this.getVertexBuffer().release()}},{key:"render",value:function(e){de[this._shaderType].getOrCreate(this._gl).draw(this,e)}}])&&Zn(t.prototype,r),e}();function jn(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const zn=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=r._main,this._ctrlGui=r,this._menu=null,this._parent=t,this._exportAll=!0,this._objColorZbrush=!0,this._objColorAppended=!1,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){var t=this._menu=e.addMenu((0,V.Z)("fileTitle"));t.addTitle((0,V.Z)("fileImportTitle")),t.addButton((0,V.Z)("fileAdd"),this,"addFile"),t.addCheckbox((0,V.Z)("fileAutoMatrix"),this._main,"_autoMatrix"),t.addCheckbox((0,V.Z)("fileVertexSRGB"),this._main,"_vertexSRGB"),t.addTitle("Comparison Images"),t.addButton("Add Comparison Image",this,"addComparisonImage"),t.addTitle((0,V.Z)("fileExportSceneTitle")),t.addCheckbox((0,V.Z)("fileExportAll"),this,"_exportAll"),t.addButton((0,V.Z)("fileExportSGL"),this,"saveFileAsSGL"),t.addButton((0,V.Z)("fileExportOBJ"),this,"saveFileAsOBJ"),t.addButton((0,V.Z)("fileExportPLY"),this,"saveFileAsPLY"),t.addButton((0,V.Z)("fileExportSTL"),this,"saveFileAsSTL"),t.addCheckbox("OBJ color zbrush",this,"_objColorZbrush"),t.addCheckbox("OBJ color append",this,"_objColorAppended"),t.addButton((0,V.Z)("sketchfabTitle"),this._ctrlGui,"exportSketchfab"),t.addTitle((0,V.Z)("fileExportTextureTitle")),this._guiTexSize=t.addSlider((0,V.Z)("fileExportTextureSize"),10,this.onTextureSize.bind(this),8,12,1),this._guiTexSize.setValue(10),t.addButton((0,V.Z)("fileExportColor"),this,"saveColor"),t.addButton((0,V.Z)("fileExportRoughness"),this,"saveRoughness"),t.addButton((0,V.Z)("fileExportMetalness"),this,"saveMetalness")}},{key:"addFile",value:function(){document.getElementById("fileopen").click()}},{key:"addComparisonImage",value:function(){console.log("[GuiFiles] addComparisonImage called");var e=document.getElementById("comparisonimageopen");if(!e){console.warn("[GuiFiles] comparisonimageopen input not found, creating it..."),(e=document.createElement("input")).type="file",e.id="comparisonimageopen",e.accept="image/*",e.style.display="none",document.body.appendChild(e);var t=this;e.addEventListener("change",(function(e){console.log("[GuiFiles] Comparison image file selected:",e.target.files.length,"file(s)"),e.target.files.length>0&&(console.log("[GuiFiles] Adding comparison image:",e.target.files[0].name),t._main.addComparisonImage(e.target.files[0]),e.target.value="")}),!1)}e?(console.log("[GuiFiles] Found comparison image input, clicking..."),e.value="",e.click()):console.error("[GuiFiles] Failed to create comparison image input element!")}},{key:"onTextureSize",value:function(e){this._texSize=1<<e,this._guiTexSize.domInputText.value=this._texSize}},{key:"_getExportMeshes",value:function(){if(this._exportAll)return this._main.getMeshes();var e=this._main.getSelectedMeshes();return e.length?e:void 0}},{key:"_extractTexture",value:function(e,t,r){var i=document.createElement("canvas");i.width=t,i.height=r;var n=new Uint8Array(4*t*r);if(e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE)return console.error("FRAMEBUFFER not complete"),i;e.flush(),e.finish(),e.readPixels(0,0,t,r,e.RGBA,e.UNSIGNED_BYTE,n);var a=i.getContext("2d"),s=a.getImageData(0,0,t,r);return s.data.set(n),a.putImageData(s,0,0),i}},{key:"_getRttPaint",value:function(e){return this._rttPaint||(this._rttPaint=new Wn(e,s.Z.Shader.PAINTUV,null),this._rttPaint.setWrapRepeat(!0),this._rttPaint.setFilterNearest(!0),le.INPUT_TEXTURE=this._getRttPaint()),this._rttPaint}},{key:"_getRttBlur",value:function(e){return this._rttBlur||(this._rttBlur=new Wn(e,s.Z.Shader.BLUR,null)),this._rttBlur}},{key:"_saveTexture",value:function(e){var t=this._main.getMesh();if(t)if(t.getTexCoords()){var r=t.getGL(),i=this._texSize,n=this._texSize,a=t.getShaderType();t.setShaderType(s.Z.Shader.PAINTUV);var o=this._getRttPaint(r);o.onResize(i,n),r.bindFramebuffer(r.FRAMEBUFFER,o.getFramebuffer()),r.clear(r.COLOR_BUFFER_BIT),r.viewport(0,0,i,n),t.render(),t.setShaderType(a),this._blurImage(r,i,n),this._extractTexture(r,i,n).toBlob(function(t){(0,gn.saveAs)(t,e+".png")}.bind(this)),this._main.onCanvasResize()}else window.alert("The selected mesh has no UV!")}},{key:"_blurImage",value:function(e,t,r){var i=this._getRttBlur(e);i.onResize(t,r),e.bindFramebuffer(e.FRAMEBUFFER,i.getFramebuffer()),e.clear(e.COLOR_BUFFER_BIT),i.render(this._main)}},{key:"saveColor",value:function(){se.CHANNEL_VALUE=0,this._saveTexture("diffuse")}},{key:"saveRoughness",value:function(){se.CHANNEL_VALUE=1,this._saveTexture("roughness")}},{key:"saveMetalness",value:function(){se.CHANNEL_VALUE=2,this._saveTexture("metalness")}},{key:"saveFileAsSGL",value:function(){var e=this._getExportMeshes();e&&this._save(Vn.exportSGL(e,this._main),"yourMesh.sgl")}},{key:"saveFileAsOBJ",value:function(){var e=this._getExportMeshes();e&&this._save(Vn.exportOBJ(e,this._objColorZbrush,this._objColorAppended),"yourMesh.obj")}},{key:"saveFileAsPLY",value:function(){var e=this._getExportMeshes();e&&this._save(Vn.exportBinaryPLY(e),"yourMesh.ply")}},{key:"saveFileAsSTL",value:function(){var e=this._getExportMeshes();e&&this._save(Vn.exportBinarySTL(e),"yourMesh.stl")}},{key:"_save",value:function(e,t,r){if(!r)return(0,gn.saveAs)(e,t);mn.zip.useWebWorkers=!0,mn.zip.workerScriptsPath="worker/",mn.zip.createWriter(new mn.zip.BlobWriter("application/zip"),(function(r){r.add(t,new mn.zip.BlobReader(e),(function(){r.close((function(e){(0,gn.saveAs)(e,"yourMesh.zip")}))}))}),onerror)}},{key:"onKeyDown",value:function(e){if(!0!==e.handled){e.stopPropagation(),this._main._focusGui||e.preventDefault();var t=e.which;e.ctrlKey&&e.altKey&&78===t?(this._main.clearScene(),e.handled=!0):!e.ctrlKey||79!==t&&73!==t?e.ctrlKey&&69===t&&(this.saveFileAsOBJ(),e.handled=!0):(this.addFile(),e.handled=!0)}}}])&&jn(t.prototype,r),e}();function Xn(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Kn=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=r._main,this.domVerts=null,this.domFaces=null,this.domUl=null,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){this.domVerts=document.createElement("ul"),this.domVerts.innerHTML=(0,V.Z)("meshNbVertices"),this.domFaces=document.createElement("ul"),this.domFaces.innerHTML=(0,V.Z)("meshNbFaces"),this.domUl=document.createElement("span"),this.domUl.appendChild(this.domVerts),this.domUl.appendChild(this.domFaces);var t=this.domUl.style;t.cursor="default",void 0===t.float?t.cssFloat="right":t.float="right",e.domTopbar.appendChild(this.domUl)}},{key:"updateMeshInfo",value:function(){var e=this._main.getMesh();this.domVerts.innerHTML=(0,V.Z)("meshNbVertices")+(e?e.getNbVertices():0),this.domFaces.innerHTML=(0,V.Z)("meshNbFaces")+(e?e.getNbFaces():0)}}])&&Xn(t.prototype,r),e}();function Hn(e){return(Hn="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 Yn(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function qn(e,t){return(qn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Jn(e,t){return!t||"object"!==Hn(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Qn(e){return(Qn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const $n=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&qn(e,t)}(s,e);var t,r,i,n,a=(i=s,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Qn(i);if(n){var r=Qn(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return Jn(this,e)});function s(e,t){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),(r=a.call(this)).setID(e.getID()),r.setMeshData(t?e.getMeshData():{_nbVertices:0,_nbFaces:0,_nbTexCoords:0,_verticesXYZ:null,_normalsXYZ:null,_colorsRGB:null,_materialsPBR:null,_vertOnEdge:null,_vertRingFace:null,_vrfStartCount:null,_vrvStartCount:null,_vertRingVert:null,_vertTagFlags:null,_vertSculptFlags:null,_vertStateFlags:null,_vertProxy:null,_facesABCD:null,_faceEdges:null,_faceNormalsXYZ:null,_facesToTriangles:null,_trianglesABC:null,_facesTagFlags:null,_edges:null,_drawArraysWireframe:null,_drawElementsWireframe:null,_texCoordsST:null,_duplicateStartCount:null,_UVfacesABCD:null,_UVtrianglesABC:null,_DAverticesXYZ:null,_DAnormalsXYZ:null,_DAcolorsRGB:null,_DAmaterialsPBR:null,_DAtexCoordsST:null,_octree:null,_faceBoxes:null,_faceCentersXYZ:null,_facePosInLeaf:null,_faceLeaf:[],_leavesToUpdate:[],_worldBound:[1/0,1/0,1/0,-1/0,-1/0,-1/0]}),r.setRenderData(e.getRenderData()),r.setTransformData(e.getTransformData()),r._detailsXYZ=null,r._detailsRGB=null,r._detailsPBR=null,r._vertMapping=null,r._evenMapping=!1,r}return t=s,(r=[{key:"optimize",value:function(){}},{key:"getEvenMapping",value:function(){return this._evenMapping}},{key:"getVerticesMapping",value:function(){return this._vertMapping}},{key:"setVerticesMapping",value:function(e){this._vertMapping=e}},{key:"setEvenMapping",value:function(e){this._evenMapping=e}},{key:"higherSynthesis",value:function(e){e.computePartialSubdivision(this.getVertices(),this.getColors(),this.getMaterials(),this.getNbVertices()),this.applyDetails()}},{key:"lowerAnalysis",value:function(e){this.copyDataFromHigherRes(e);var t=e.getNbVertices(),r=new Float32Array(3*t),i=new Float32Array(3*t),n=new Float32Array(3*t);this.computePartialSubdivision(r,i,n,t),e.computeDetails(r,i,n,t)}},{key:"copyDataFromHigherRes",value:function(e){var t=this.getVertices(),r=this.getColors(),i=this.getMaterials(),n=this.getNbVertices(),a=e.getVertices(),s=e.getColors(),o=e.getMaterials();if(!1===this.getEvenMapping())t.set(a.subarray(0,3*n)),r.set(s.subarray(0,3*n)),i.set(o.subarray(0,3*n));else for(var l=this.getVerticesMapping(),u=0;u<n;++u){var c=3*u,h=3*l[u];t[c]=a[h],t[c+1]=a[h+1],t[c+2]=a[h+2],r[c]=s[h],r[c+1]=s[h+1],r[c+2]=s[h+2],i[c]=o[h],i[c+1]=o[h+1],i[c+2]=o[h+2]}}},{key:"computePartialSubdivision",value:function(e,t,r,i){var n=this.getVerticesMapping();if(n){var a=new Float32Array(3*i),s=new Float32Array(3*i),o=new Float32Array(3*i);Ui.partialSubdivision(this,a,s,o);var l=!0===this.getEvenMapping()?0:this.getNbVertices();l>0&&(e.set(a.subarray(0,3*l)),t.set(s.subarray(0,3*l)),r.set(o.subarray(0,3*l)));for(var u=l;u<i;++u){var c=3*u,h=3*n[u];e[h]=a[c],e[h+1]=a[c+1],e[h+2]=a[c+2],t[h]=s[c],t[h+1]=s[c+1],t[h+2]=s[c+2],r[h]=o[c],r[h+1]=o[c+1],r[h+2]=o[c+2]}}else Ui.partialSubdivision(this,e,t,r)}},{key:"applyDetails",value:function(){var e=this.getVerticesRingVertStartCount(),t=this.getVerticesRingVert(),r=this.getVertices(),i=this.getNormals(),n=this.getColors(),a=this.getMaterials(),s=this.getNbVertices(),l=new Float32Array(o.Z.getMemory(3*s*4),0,3*s);l.set(r.subarray(0,3*s));for(var u=this._detailsXYZ,c=this._detailsRGB,h=this._detailsPBR,d=Math.min,f=Math.max,_=0;_<s;++_){var p=3*_;n[p]=d(1,f(0,n[p]+c[p])),n[p+1]=d(1,f(0,n[p+1]+c[p+1])),n[p+2]=d(1,f(0,n[p+2]+c[p+2])),a[p]=d(1,f(0,a[p]+h[p])),a[p+1]=d(1,f(0,a[p+1]+h[p+1])),a[p+2]=d(1,f(0,a[p+2]+h[p+2]));var g=l[p],m=l[p+1],v=l[p+2],y=i[p],b=i[p+1],T=i[p+2],M=y*y+b*b+T*T;if(0!==M){y*=M=1/Math.sqrt(M),b*=M,T*=M;var S=3*t[e[2*_]],k=l[S]-g,E=l[S+1]-m,A=l[S+2]-v;if(0!=(M=(k-=y*(M=k*y+E*b+A*T))*k+(E-=b*M)*E+(A-=T*M)*A)){var C=b*(A*=M=1/Math.sqrt(M))-T*(E*=M),w=T*(k*=M)-y*A,R=y*E-b*k,x=u[p],P=u[p+1],D=u[p+2];r[p]=g+y*x+k*P+C*D,r[p+1]=m+b*x+E*P+w*D,r[p+2]=v+T*x+A*P+R*D}}}}},{key:"computeDetails",value:function(e,t,r,i){for(var n=this.getVerticesRingVertStartCount(),a=this.getVerticesRingVert(),s=this.getVertices(),o=this.getNormals(),l=this.getColors(),u=this.getMaterials(),c=this.getNbVertices(),h=this._detailsXYZ=new Float32Array(3*i),d=this._detailsRGB=new Float32Array(3*i),f=this._detailsPBR=new Float32Array(3*i),_=0;_<c;++_){var p=3*_;d[p]=l[p]-t[p],d[p+1]=l[p+1]-t[p+1],d[p+2]=l[p+2]-t[p+2],f[p]=u[p]-r[p],f[p+1]=u[p+1]-r[p+1],f[p+2]=u[p+2]-r[p+2];var g=o[p],m=o[p+1],v=o[p+2],y=g*g+m*m+v*v;if(0!==y){g*=y=1/Math.sqrt(y),m*=y,v*=y;var b=3*a[n[2*_]],T=e[b]-e[p],M=e[b+1]-e[p+1],S=e[b+2]-e[p+2];if(0!=(y=(T-=g*(y=T*g+M*m+S*v))*T+(M-=m*y)*M+(S-=v*y)*S)){var k=m*(S*=y=1/Math.sqrt(y))-v*(M*=y),E=v*(T*=y)-g*S,A=g*M-m*T,C=s[p]-e[p],w=s[p+1]-e[p+1],R=s[p+2]-e[p+2];h[p]=g*C+m*w+v*R,h[p+1]=T*C+M*w+S*R,h[p+2]=k*C+E*w+A*R}}}}}])&&Yn(t.prototype,r),s}(Qt);var ea={},ta=function(e,t,r){var i=++o.Z.TAG_FLAG,n=e.getVerticesTagFlags(),a=e.getVerticesRingVertStartCount(),s=e.getVerticesRingVert(),l=e.getVerticesOnEdge(),u=function(e,t,r){var i=0,n=e.getNbVertices();for(i=0;i<n;++i)if(0===t[i]&&1===r[i])return i;var a=e.getVerticesOnEdge();for(i=0;i<n&&(0!==t[i]||1===a[i]);++i);if(i===n)return-1;for(i=0;i<n;++i)if(0===t[i])return i;return-1}(e,r,t);if(u<0)return!1;r[u]=1;var c=new Uint32Array(o.Z.getMemory(4*e.getNbVertices()),0,e.getNbVertices());c[0]=u;for(var h=1;h>0;){var d=c[--h],f=a[2*d],_=f+a[2*d+1],p=0,g=++i;for(p=f;p<_;++p){var m=s[p];if(n[m]=g,1===r[m])return o.Z.TAG_FLAG=i,!1;r[m]=-1,n[m]=g}for(g=++i,p=f;p<_;++p){var v=s[p];if(0!==t[v]&&!l[v])return o.Z.TAG_FLAG=i,!1;for(var y=a[2*v],b=y+a[2*v+1],T=y;T<b;++T){var M=s[T];if(M!==d&&!(n[M]>=g-1)&&(n[M]=g,0===r[M])){for(var S=a[2*M],k=S+a[2*M+1],E=0,A=S;A<k;++A)n[s[A]]===g-1&&E++;2===E?r[M]=-1:(r[M]=1,c[h++]=M)}}}}return o.Z.TAG_FLAG=i,!0};ea.computeReverse=function(e,t){var r=e.getNbFaces();if(r%4!=0)return!1;var i=new Int8Array(e.getNbVertices());if(!function(e,t){for(var r=e.getNbVertices(),i=function(e){for(var t=e.getNbVertices(),r=e.getFaces(),i=e.getVerticesOnEdge(),n=e.getVerticesRingVertStartCount(),a=e.getVerticesRingFace(),s=e.getVerticesRingFaceStartCount(),l=new Int8Array(t),u=0;u<t;++u){for(var c=2*u,h=n[c+1],d=s[c],f=s[c+1],_=i[u],p=0,g=d,m=d+f;g<m;++g)p+=r[4*a[g]+3]===o.Z.TRI_INDEX?0:1;0===p?(!_&&6!==h||_&&4!==h)&&(l[u]=1):p===f?(!_&&4!==h||_&&3!==h)&&(l[u]=1):(_||5!==h)&&(l[u]=1)}return l}(e),n=!0;n;){if(!ta(e,i,t))return!1;n=!1;for(var a=0;a<r;++a)if(0===t[a]){n=!0;break}}return!0}(e,i))return!1;var n=new Int32Array(r/4);return!!function(e,t,r,i){var n=e.getFaceEdges(),a=e.getFaces(),s=new Int32Array(e.getNbEdges()),l=0,u=e.getNbFaces(),c=0,h=new Uint32Array(e.getNbVertices()),d=new Uint32Array(u);for(l=0;l<u;++l)d[l]=o.Z.TRI_INDEX;for(l=0;l<u;++l){var f=4*l,_=a[f],p=a[f+1],g=a[f+2],m=a[f+3],v=r[_],y=r[p],b=r[g];if(m!==o.Z.TRI_INDEX){var T=0,M=0,S=0;1===v?(T=_,M=g,S=s[n[f+1]]-1,s[n[f+2]]=_+1):1===y?(T=p,M=m,S=s[n[f+2]]-1,s[n[f+3]]=p+1):1===b?(T=g,M=_,S=s[n[f+3]]-1,s[n[f]]=g+1):(T=m,M=p,S=s[n[f]]-1,s[n[f+1]]=m+1);var k=h[M]-1;if(k<0)i[c]=-M-1,d[4*c+3]=T,h[M]=++c;else{var E=4*k;S<0?d[E+2]>=o.Z.TRI_INDEX-1?(d[E+2]=T,d[E]=o.Z.TRI_INDEX-1):d[E]===o.Z.TRI_INDEX?d[E+1]=T:(d[E+1]=d[E+2],d[E+2]=T):d[E+1]===S?d[E]=T:(d[E]=d[E+1],d[E+2]===S?d[E+1]=T:(d[E+1]=d[E+2],d[E+2]=T))}}else{if(v+y+b===-3){i[c++]=l;continue}1===v?s[n[f+1]]=_+1:1===y?s[n[f+2]]=p+1:1===b&&(s[n[f]]=g+1)}}for(u/=4,l=0;l<u;++l){var A=i[l],C=4*l;if(A<0){var w=o.Z.TRI_INDEX-1;if(d[C]>=w||d[C+1]>=o.Z.TRI_INDEX||d[C+2]>=o.Z.TRI_INDEX)return!1}else{var R=4*A;d[C]=s[n[R]]-1,d[C+1]=s[n[R+1]]-1,d[C+2]=s[n[R+2]]-1}}return t.setFaces(d),!0}(e,t,i,n)&&(function(e,t,r){var i=0,n=new Uint32Array(e.getNbVertices());t.setVerticesMapping(n);var a=t.getFaces(),s=new Int32Array(e.getNbVertices()),l=0,u=4*t.getNbFaces();for(l=0;l<u;++l){var c=a[l];if(c!==o.Z.TRI_INDEX){var h=s[c]-1;-1===h&&(h=i++,s[c]=h+1,n[h]=c),a[l]=h}}t.setVertices(new Float32Array(3*i));var d=e.getFaces(),f=e.getVerticesRingFace(),_=e.getVerticesRingFaceStartCount(),p=new Uint8Array(e.getNbVertices());for(u/=4,l=0;l<u;++l){var g,m,v,y,b,T,M,S,k,E,A=r[l];if(A>=0){var C=4*A;g=d[C+1],m=d[C+2],v=d[C],y=o.Z.TRI_INDEX,b=o.Z.TRI_INDEX}else{b=-A-1;for(var w=4*l,R=n[a[w]],x=n[a[w+1]],P=n[a[w+2]],D=n[a[w+3]],I=_[2*b],F=I+4,O=I;O<F;++O){var L=4*f[O],V=d[L],N=d[L+1],B=d[L+2],U=d[L+3];V===R?g=N:N===R?g=B:B===R?g=U:U===R&&(g=V),V===x?m=N:N===x?m=B:B===x?m=U:U===x&&(m=V),V===P?v=N:N===P?v=B:B===P?v=U:U===P&&(v=V),V===D?y=N:N===D?y=B:B===D?y=U:U===D&&(y=V)}}T=p[g],M=p[m],S=p[v],k=y!==o.Z.TRI_INDEX?p[y]:-1,E=b!==o.Z.TRI_INDEX?p[b]:-1,0===T&&(p[g]=1,n[i++]=g),0===M&&(p[m]=1,n[i++]=m),0===S&&(p[v]=1,n[i++]=v),0===k&&(p[y]=1,n[i++]=y),0===E&&(p[b]=1,n[i++]=b)}}(e,t,n),function(e,t){var r=e.getVertices(),i=e.getColors(),n=e.getMaterials(),a=t.getVertices(),s=new Float32Array(a.length),l=new Float32Array(a.length);t.setColors(s),t.setMaterials(l);var u=t.getVerticesMapping(),c=0,h=t.getNbVertices();for(c=0;c<h&&!(u[c]>=h);++c);if(c===h){var d=t.getFaces(),f=d.length;for(c=0;c<f;++c){var _=d[c];_!==o.Z.TRI_INDEX&&(d[c]=u[_])}for(c=0;c<h;++c)u[c]=c;a.set(r.subarray(0,3*h)),s.set(i.subarray(0,3*h)),l.set(n.subarray(0,3*h))}else for(t.setEvenMapping(!0),c=0;c<h;++c){var p=3*c,g=3*u[c];a[p]=r[g],a[p+1]=r[g+1],a[p+2]=r[g+2],s[p]=i[g],s[p+1]=i[g+1],s[p+2]=i[g+2],l[p]=n[g],l[p+1]=n[g+1],l[p+2]=n[g+2]}}(e,t),e.hasUV()&&function(e,t,r){for(var i=e.getVerticesDuplicateStartCount(),n=t.getNbVertices(),a=new Uint32Array(2*n),s=t.getVerticesMapping(),l=e.getTexCoords(),u=new Float32Array(o.Z.getMemory(4*e.getNbTexCoords()*2),0,2*e.getNbTexCoords()),c=new Uint32Array(n),h=n,d=0;d<n;++d){var f=s[d],_=i[2*f];if(u[2*d]=l[2*f],u[2*d+1]=l[2*f+1],0!==_){for(var p=c[d]=_-h,g=i[2*f+1],m=h,v=h+g;m<v;++m)u[2*m]=l[2*(p+m)],u[2*m+1]=l[2*(p+m)+1];a[2*d]=h,a[2*d+1]=g,h+=g}}t.setTexCoords(new Float32Array(u.subarray(0,2*h))),t.setVerticesDuplicateStartCount(a),function(e,t,r,i){for(var n=e.getFaces(),a=e.getFacesTexCoord(),s=e.getVerticesRingFaceStartCount(),l=e.getVerticesRingFace(),u=e.getVerticesDuplicateStartCount(),c=t.getFaces(),h=new Uint32Array(c),d=t.getVerticesMapping(),f=0,_=c.length;f<_;++f){var p=c[f];if(p!==o.Z.TRI_INDEX){var g=d[p];if(0!==u[2*g]){var m=f%4,v=r[(f-m)/4],y=o.Z.TRI_INDEX;if(v>=0){var b,T,M=4*v;0===m?(b=n[M+1],T=n[M]):1===m?(b=n[M+2],T=n[M+1]):(b=n[M],T=n[M+2]);for(var S=s[2*g],k=S+s[2*g+1],E=S;E<k;++E){var A=4*l[E],C=n[A],w=n[A+1],R=n[A+2];if(C===b?w===T&&(y=a[A+2]):w===b?R===T&&(y=a[A]):R===b&&C===T&&(y=a[A+1]),y!==o.Z.TRI_INDEX)break}}else for(var x=s[2*(v=-v-1)],P=x+4,D=x;D<P;++D){var I=4*l[D];if(n[I]===g?y=a[I]:n[I+1]===g?y=a[I+1]:n[I+2]===g?y=a[I+2]:n[I+3]===g&&(y=a[I+3]),y!==o.Z.TRI_INDEX)break}h[f]=y===g?y:y-i[p]}}}t.setFacesTexCoord(h)}(e,t,r,c)}(e,t,n),t.allocateArrays(),!0)};const ra=ea;function ia(e){return(ia="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 na(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function aa(e,t,r){return(aa="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=la(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(r):n.value}})(e,t,r||e)}function sa(e,t){return(sa=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function oa(e,t){return!t||"object"!==ia(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function la(e){return(la=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ua=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&sa(e,t)}(o,e);var t,r,i,n,a,s=(n=o,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=la(n);if(a){var r=la(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return oa(this,e)});function o(e){var t;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this)).setID(e.getID()),t.setRenderData(e.getRenderData()),t.setTransformData(e.getTransformData()),t._meshes=[new $n(e,!0)],t.setSelection(0);var r=e.getGL();return t._indexBuffer=new g(r,r.ELEMENT_ARRAY_BUFFER,r.STATIC_DRAW),t._wireframeBuffer=new g(r,r.ELEMENT_ARRAY_BUFFER,r.STATIC_DRAW),t}return t=o,i=[{key:"NONE",get:function(){return 0}},{key:"SCULPT",get:function(){return 1}},{key:"CAMERA",get:function(){return 2}},{key:"PICKING",get:function(){return 3}}],(r=[{key:"getCurrentMesh",value:function(){return this._meshes[this._sel]}},{key:"setSelection",value:function(e){this._sel=e,this.setMeshData(this.getCurrentMesh().getMeshData())}},{key:"addLevel",value:function(){if(this._meshes.length-1!==this._sel)return this.getCurrentMesh();var e=this.getCurrentMesh().getNbFaces(),t="addLevel : "+e+" -> "+4*e;console.time(t);var r=this.getCurrentMesh(),i=new $n(r);return r.setVerticesMapping(void 0),Ui.fullSubdivision(r,i),i.initTopology(),this.pushMesh(i),this.initRender(),console.timeEnd(t),i}},{key:"computeReverse",value:function(){if(0!==this._sel)return this.getCurrentMesh();var e=this.getCurrentMesh(),t=new $n(e);return ra.computeReverse(e,t)?(t.initTopology(),this.unshiftMesh(t),this.initRender(),t):void 0}},{key:"lowerLevel",value:function(){return 0===this._sel?this._meshes[0]:(this._meshes[this._sel-1].lowerAnalysis(this.getCurrentMesh()),this.setSelection(this._sel-1),this.updateResolution(),this.getCurrentMesh())}},{key:"higherLevel",value:function(){return this._sel===this._meshes.length-1||(this._meshes[this._sel+1].higherSynthesis(this.getCurrentMesh()),this.setSelection(this._sel+1),this.updateResolution()),this.getCurrentMesh()}},{key:"updateResolution",value:function(){this.updateGeometry(),this.updateDuplicateColorsAndMaterials(),this.updateBuffers();var e=this._meshes[this.getLowIndexRender()];this._indexBuffer.update(e.getTriangles()),this._wireframeBuffer.update(e.getWireframe())}},{key:"selectResolution",value:function(e){for(;this._sel>e;)this.lowerLevel();for(;this._sel<e;)this.higherLevel()}},{key:"findIndexFromMesh",value:function(e){for(var t=this._meshes,r=0,i=t.length;r<i;++r)if(e===t[r])return r}},{key:"selectMesh",value:function(e){var t=this.findIndexFromMesh(e);this.selectResolution(t)}},{key:"pushMesh",value:function(e){this._meshes.push(e),this.setSelection(this._meshes.length-1),this.updateResolution()}},{key:"unshiftMesh",value:function(e){this._meshes.unshift(e),this.setSelection(1),this.lowerLevel()}},{key:"popMesh",value:function(){this._meshes.pop(),this.setSelection(this._meshes.length-1),this.updateResolution()}},{key:"shiftMesh",value:function(){this._meshes.shift(),this.setSelection(0),this.updateResolution()}},{key:"deleteLower",value:function(){this._meshes.splice(0,this._sel),this.setSelection(0)}},{key:"deleteHigher",value:function(){this._meshes.splice(this._sel+1)}},{key:"getLowIndexRender",value:function(){for(var e=this._sel;e>=0;){var t=this._meshes[e];if(!0===t.getEvenMapping())return e===this._sel?e:e+1;if(t.getNbTriangles()<5e5)return e;--e}return 0}},{key:"_renderLow",value:function(e){var t=this.getRenderData(),r=this._sel,i=this.getIndexBuffer();this.setSelection(this.getLowIndexRender()),t._indexBuffer=this._indexBuffer,aa(la(o.prototype),"render",this).call(this,e),t._indexBuffer=i,this.setSelection(r)}},{key:"_renderWireframeLow",value:function(e){var t=this.getRenderData(),r=this._sel,i=this.getWireframeBuffer();this.setSelection(this.getLowIndexRender()),t._wireframeBuffer=this._wireframeBuffer,aa(la(o.prototype),"renderWireframe",this).call(this,e),t._wireframeBuffer=i,this.setSelection(r)}},{key:"_canUseLowRender",value:function(e){return!(this.isUsingTexCoords()||this.isUsingDrawArrays()||o.RENDER_HINT===o.PICKING||o.RENDER_HINT===o.NONE||e.getMesh()===this&&o.RENDER_HINT!==o.CAMERA||this.getLowIndexRender()===this._sel)}},{key:"render",value:function(e){return this._canUseLowRender(e)?this._renderLow(e):aa(la(o.prototype),"render",this).call(this,e)}},{key:"renderWireframe",value:function(e){return this._canUseLowRender(e)?this._renderWireframeLow(e):aa(la(o.prototype),"renderWireframe",this).call(this,e)}}])&&na(t.prototype,r),i&&na(t,i),o}(Qt);ua.RENDER_HINT=0;const ca=ua;var ha,da,fa,_a,pa,ga={_mesh:null,_linear:!1,_verticesMap:new Map,_states:null,_center:[0,0,0],_radius2:0,_edgeMax2:0},ma=function(e,t,r,i,n){var a=ga._mesh,s=a.getVerticesRingVert(),l=a.getVerticesRingFace(),u=a.getFacePosInLeaf(),c=a.getFaceLeaf(),h=a.getFacesStateFlags(),d=a.getFaces(),f=4*e;d[f]=t,d[f+1]=n,d[f+2]=i,d[f+3]=o.Z.TRI_INDEX;var _=c[e],p=_._iFaces;s[n].push(i),s[i].push(n);var g=a.getNbTriangles();l[n].push(e,g),d[f=4*g]=n,d[f+1]=r,d[f+2]=i,d[f+3]=o.Z.TRI_INDEX,h[g]=o.Z.STATE_FLAG,c[g]=_,u[g]=p.length,l[i].push(g),o.Z.replaceElement(l[r],e,g),p.push(g),a.addNbFace(1)},va=function(e){for(var t=ga._mesh,r=t.getVerticesRingVert(),i=t.getFaces(),n=e.length,a=new Uint32Array(o.Z.getMemory(8*n),0,2*n),s=0,l=ga._verticesMap,u=0;u<n;++u){var c=e[u],h=4*c,d=i[h],f=i[h+1],_=i[h+2],p=l.get(Math.min(d,f)+"+"+Math.max(d,f)),g=l.get(Math.min(f,_)+"+"+Math.max(f,_)),m=l.get(Math.min(d,_)+"+"+Math.max(d,_)),v=r[d].length,y=r[f].length,b=r[_].length,T=0;if(p?T=g?m?v<y&&v<b?2:y<b?3:1:v<b?2:1:m&&y<b?3:1:g?T=m&&y<v?3:2:m&&(T=3),1===T)ma(c,d,f,_,p);else if(2===T)ma(c,f,_,d,g);else{if(3!==T)continue;ma(c,_,d,f,m)}a[s++]=c,a[s++]=t.getNbTriangles()-1}return new Uint32Array(a.subarray(0,s))},ya=function(e,t,r,i){var n=ga._mesh,a=n.getVertices(),s=n.getNormals(),l=n.getColors(),u=n.getMaterials(),c=n.getFaces(),h=n.getFacePosInLeaf(),d=n.getFaceLeaf(),f=n.getVerticesRingVert(),_=n.getVerticesRingFace(),p=n.getFacesStateFlags(),g=n.getVerticesStateFlags(),m=ga._verticesMap,v=Math.min(t,r)+"+"+Math.max(t,r),y=!1,b=m.get(v);void 0===b&&(b=n.getNbVertices(),y=!0,m.set(v,b)),f[i].push(b);var T=4*e;c[T]=t,c[T+1]=b,c[T+2]=i,c[T+3]=o.Z.TRI_INDEX;var M=n.getNbTriangles();c[T=4*M]=b,c[T+1]=r,c[T+2]=i,c[T+3]=o.Z.TRI_INDEX,p[M]=o.Z.STATE_FLAG,_[i].push(M),o.Z.replaceElement(_[r],e,M);var S=d[e],k=S._iFaces;if(d[M]=S,h[M]=k.length,k.push(M),!y)return f[b].push(i),_[b].push(e,M),void n.addNbFace(1);var E=3*t,A=a[E],C=a[E+1],w=a[E+2],R=s[E],x=s[E+1],P=s[E+2],D=3*r,I=a[D],F=a[D+1],O=a[D+2],L=s[D],V=s[D+1],N=s[D+2],B=R+L,U=x+V,Z=P+N;if(s[T=3*b]=.5*B,s[T+1]=.5*U,s[T+2]=.5*Z,l[T]=.5*(l[E]+l[D]),l[T+1]=.5*(l[E+1]+l[D+1]),l[T+2]=.5*(l[E+2]+l[D+2]),u[T]=.5*(u[E]+u[D]),u[T+1]=.5*(u[E+1]+u[D+1]),u[T+2]=.5*(u[E+2]+u[D+2]),ga._linear)a[T]=.5*(A+I),a[T+1]=.5*(C+F),a[T+2]=.5*(w+O);else{var G=R*R+x*x+P*P;0===G?R=1:(R*=G=1/Math.sqrt(G),x*=G,P*=G),0==(G=L*L+V*V+N*N)?L=1:(L*=G=1/Math.sqrt(G),V*=G,N*=G);var W=R*L+x*V+P*N,j=A-I,z=C-F,X=w-O,K=.12*(W<=-1?Math.PI:W>=1?0:Math.acos(W));K*=Math.sqrt(j*j+z*z+X*X),(G=B*B+U*U+Z*Z)>0&&(K/=Math.sqrt(G)),j*(R-L)+z*(x-V)+X*(P-N)<0&&(K=-K),a[T]=.5*(A+I)+B*K,a[T+1]=.5*(C+F)+U*K,a[T+2]=.5*(w+O)+Z*K}g[b]=o.Z.STATE_FLAG,f[b]=[t,r,i],_[b]=[e,M],o.Z.replaceElement(f[t],r,b),o.Z.replaceElement(f[r],t,b),n.addNbVertice(1),n.addNbFace(1)},ba=(ha=[0,0,0],da=[0,0,0],fa=[0,0,0],_a=tt.Z.triangleInsideSphere,pa=tt.Z.pointInsideTriangle,function(e,t){var r=ga._mesh,n=r.getVertices(),a=r.getFaces(),s=4*e,o=3*a[s],l=3*a[s+1],u=3*a[s+2];if(ha[0]=n[o],ha[1]=n[o+1],ha[2]=n[o+2],da[0]=n[l],da[1]=n[l+1],da[2]=n[l+2],fa[0]=n[u],fa[1]=n[u+1],fa[2]=n[u+2],t&&!_a(ga._center,ga._radius2,ha,da,fa)&&!pa(ga._center,ha,da,fa))return 0;var c=r.getMaterials(),h=c[o+2],d=c[l+2],f=c[u+2],_=i.nI(ha,da),p=i.nI(da,fa),g=i.nI(ha,fa);return _>p&&_>g?.5*(h+d)*_>ga._edgeMax2?1:0:p>g?.5*(d+f)*p>ga._edgeMax2?2:0:.5*(h+f)*g>ga._edgeMax2?3:0}),Ta=function(e){var t=ga._mesh,r=t.getNbVertices(),i=t.getNbTriangles();ga._verticesMap=new Map;var n=function(e){for(var t=e.length,r=o.Z.getMemory(5*t),i=new Uint32Array(r,0,t),n=new Uint8Array(r,4*t,t),a=0,s=0;s<t;++s){var l=e[s],u=ba(l,!0);0!==u&&(n[a]=u,i[a++]=l)}return[new Uint32Array(i.subarray(0,a)),new Uint8Array(n.subarray(0,a))]}(e),a=n[0],s=n[1];a.length>5&&(a=t.expandsFaces(a,3),(s=new Uint8Array(a.length)).set(n[1])),ga._states.pushVertices(t.getVerticesFromFaces(a)),ga._states.pushFaces(a),t.reAllocateArrays(s.length),function(e,t){for(var r=ga._mesh.getFaces(),i=e.length,n=0;n<i;++n){var a=e[n],s=t[n];0===s&&(s=ba(a));var o=4*a;1===s?ya(a,r[o],r[o+1],r[o+2]):2===s?ya(a,r[o+1],r[o+2],r[o]):3===s&&ya(a,r[o+2],r[o],r[o+1])}}(a,s);var l=0,u=t.getNbTriangles()-i,c=new Uint32Array(u);for(l=0;l<u;++l)c[l]=i+l;a=(c=t.expandsFaces(c,1)).subarray(u),ga._states.pushVertices(t.getVerticesFromFaces(a)),ga._states.pushFaces(a);var h=e,d=e.length;(e=new Uint32Array(d+c.length)).set(h),e.set(c,d);var f=t.getFacesTagFlags(),_=e.length,p=new Uint32Array(o.Z.getMemory(4*_),0,_),g=0,m=++o.Z.TAG_FLAG;for(l=0;l<_;++l){var v=e[l];f[v]!==m&&(f[v]=m,p[g++]=v)}p=new Uint32Array(p.subarray(0,g));for(var y=t.getNbTriangles();c.length>0;)t.reAllocateArrays(c.length),c=va(c);for(u=t.getNbTriangles()-y,h=p,(p=new Uint32Array(g+u)).set(h),l=0;l<u;++l)p[g+l]=y+l;var b=t.getNbVertices()-r,T=new Uint32Array(b);for(l=0;l<b;++l)T[l]=r+l;if(T=t.expandsVertices(T,1),!ga._linear){var M=T.subarray(b),S=new ft;S.setToolMesh(t),S.smoothTangent(M,1)}var k=t.getVertices(),E=t.getVerticesSculptFlags(),A=ga._center,C=A[0],w=A[1],R=A[2],x=o.Z.SCULPT_FLAG;for(b=T.length,l=0;l<b;++l){var P=T[l],D=3*P,I=k[D]-C,F=k[D+1]-w,O=k[D+2]-R;E[P]=I*I+F*F+O*O<ga._radius2?x:x-1}return p};const Ma={subdivision:function(e,t,r,n,a,s,o){ga._mesh=e,ga._linear=o,i.JG(ga._center,r),ga._radius2=n,ga._edgeMax2=a,ga._states=s;for(var l=0;l!==e.getNbTriangles();)l=e.getNbTriangles(),t=Ta(t);return t}};var Sa={_mesh:null,_states:null,_iTrisToDelete:[],_iVertsToDelete:[],_iVertsDecimated:[]},ka=function(e,t){return e-t},Ea=function(e){var t=Sa._mesh,r=t.getVerticesRingFace(),i=t.getFacesTagFlags(),n=t.getFaces(),a=t.getFacePosInLeaf(),s=t.getFaceLeaf(),l=t.getFacesStateFlags(),u=a[e],c=s[e]._iFaces,h=c[c.length-1];e!==h&&(c[u]=h,a[h]=u),c.pop();var d=t.getNbTriangles()-1;if(d!==e){var f=4*d,_=n[f],p=n[f+1],g=n[f+2];Sa._states.pushVertices([_,p,g]),Sa._states.pushFaces([d]),o.Z.replaceElement(r[_],d,e),o.Z.replaceElement(r[p],d,e),o.Z.replaceElement(r[g],d,e);var m=s[d],v=a[d];m._iFaces[v]=e,s[e]=m,a[e]=v,i[e]=i[d],l[e]=l[d],n[e*=4]=_,n[e+1]=p,n[e+2]=g,n[e+3]=o.Z.TRI_INDEX,Sa._iVertsDecimated.push(_,p,g),t.addNbFace(-1)}else t.addNbFace(-1)},Aa=function(e){var t=Sa._mesh,r=t.getVerticesRingVert(),i=t.getVerticesRingFace(),n=t.getVertices(),a=t.getNormals(),s=t.getColors(),l=t.getMaterials(),u=t.getFaces(),c=t.getVerticesTagFlags(),h=t.getVerticesStateFlags(),d=t.getVerticesSculptFlags(),f=t.getNbVertices()-1;if(e!==f){var _=0,p=Sa._states;p.pushVertices([f]);var g=i[f],m=r[f],v=g.length,y=m.length,b=0;for(b=0;b<v;++b)_=g[b],p.pushFaces([_]),u[_*=4]===f?u[_]=e:u[_+1]===f?u[_+1]=e:u[_+2]=e;for(b=0;b<y;++b)_=m[b],p.pushVertices([_]),o.Z.replaceElement(r[_],f,e);r[e]=r[f].slice(),i[e]=i[f].slice(),c[e]=c[f],h[e]=h[f],d[e]=d[f];var T=3*f;n[_=3*e]=n[T],n[_+1]=n[T+1],n[_+2]=n[T+2],a[_]=a[T],a[_+1]=a[T+1],a[_+2]=a[T+2],s[_]=s[T],s[_+1]=s[T+1],s[_+2]=s[T+2],l[_]=l[T],l[_+1]=l[T+1],l[_+2]=l[T+2],t.addNbVertice(-1)}else t.addNbVertice(-1)},Ca=function(e,t,r,i,n,a,s){var l=Sa._mesh,u=l.getVertices(),c=l.getNormals(),h=l.getColors(),d=l.getMaterials(),f=l.getFaces(),_=l.getVerticesTagFlags(),p=l.getFacesTagFlags(),g=l.getVerticesRingVert(),m=l.getVerticesRingFace(),v=g[r],y=g[i],b=m[r],T=m[i];if(v.length===b.length&&y.length===T.length){var M=g[n],S=g[a],k=m[n],E=m[a];if(M.length===k.length&&S.length===E.length){Sa._iVertsDecimated.push(r,i),Sa._states.pushVertices(v),Sa._states.pushVertices(y),Sa._states.pushFaces(b),Sa._states.pushFaces(T),v.sort(ka),y.sort(ka);var A=0;if(o.Z.intersectionArrays(v,y).length>=3)return o.Z.removeElement(b,t),o.Z.removeElement(T,e),k.push(t),E.push(e),f[A=4*e]===i?f[A]=a:f[A+1]===i?f[A+1]=a:f[A+2]=a,f[A=4*t]===r?f[A]=n:f[A+1]===r?f[A+1]=n:f[A+2]=n,l.computeRingVertices(r),l.computeRingVertices(i),l.computeRingVertices(n),void l.computeRingVertices(a);var C=3*i,w=c[A=3*r]+c[C],R=c[A+1]+c[C+1],x=c[A+2]+c[C+2],P=w*w+R*R+x*x;0===P?w=1:(w*=P=1/Math.sqrt(P),R*=P,x*=P),c[A]=w,c[A+1]=R,c[A+2]=x,h[A]=.5*(h[A]+h[C]),h[A+1]=.5*(h[A+1]+h[C+1]),h[A+2]=.5*(h[A+2]+h[C+2]),d[A]=.5*(d[A]+d[C]),d[A+1]=.5*(d[A+1]+d[C+1]),d[A+2]=.5*(d[A+2]+d[C+2]),o.Z.removeElement(b,e),o.Z.removeElement(b,t),o.Z.removeElement(T,e),o.Z.removeElement(T,t),o.Z.removeElement(k,e),o.Z.removeElement(E,t);var D=T.length,I=0;for(I=0;I<D;++I){var F=T[I];b.push(F);var O=4*F;f[O]===i?f[O]=r:f[O+1]===i?f[O+1]=r:f[O+2]=r}for(D=y.length,I=0;I<D;++I)v.push(y[I]);l.computeRingVertices(r);var L=0,V=0,N=0,B=v.length;for(I=0;I<B;++I){var U=v[I];l.computeRingVertices(U),L+=u[U*=3],V+=u[U+1],N+=u[U+2]}V/=B,N/=B;var Z=w*((L/=B)-u[A])+R*(V-u[A+1])+x*(N-u[A+2]);for(u[A]=L-w*Z,u[A+1]=V-R*Z,u[A+2]=N-x*Z,_[i]=p[e]=p[t]=-1,Sa._iVertsToDelete.push(i),Sa._iTrisToDelete.push(e,t),D=b.length,I=0;I<D;++I)s.push(b[I])}}},wa=function(e,t,r){if(-1!==t){var i=Sa._mesh.getFaces(),n=4*e,a=i[n],s=i[n+1],o=i[n+2],l=i[n=4*t],u=i[n+1],c=i[n+2];a===l?s===c?Ca(e,t,a,s,o,u,r):Ca(e,t,a,o,s,c,r):a===u?s===l?Ca(e,t,a,s,o,c,r):Ca(e,t,a,o,s,l,r):a===c?s===u?Ca(e,t,a,s,o,l,r):Ca(e,t,a,o,s,u,r):Ca(e,t,o,s,a,s===l?u:s===u?c:l,r)}},Ra=function(e,t,r){var i=Sa._mesh.getVerticesRingFace(),n=i[t],a=i[r];n.sort(ka),a.sort(ka);var s=o.Z.intersectionArrays(n,a);return 2!==s.length?-1:s[0]===e?s[1]:s[0]},xa={decimation:function(e,t,r,i,n,a){Sa._mesh=e,Sa._states=a,Sa._iVertsDecimated.length=0,Sa._iTrisToDelete.length=0,Sa._iVertsToDelete.length=0;var s=Math.sqrt(i),l=e.getFacesTagFlags(),u=e.getVertices(),c=e.getMaterials(),h=e.getFaces(),d=r[0],f=r[1],_=r[2],p=0,g=t.length,m=new Array(g);for(p=0;p<g;++p)m[p]=t[p];for(p=0;p<m.length;++p){var v=m[p];if(!(l[v]<0)){var y=4*v,b=h[y],T=h[y+1],M=h[y+2],S=3*b,k=3*T,E=3*M,A=u[S],C=u[S+1],w=u[S+2],R=u[k],x=u[k+1],P=u[k+2],D=u[E],I=u[E+1],F=u[E+2],O=(A+R+D)/3-d,L=(C+x+I)/3-f,V=(w+P+F)/3-_,N=O*O+L*L+V*V;if(N<i)N=1;else{if(!(N<2*i))continue;var B=(N=(Math.sqrt(N)-s)/(s*Math.SQRT2-s))*N;N=3*B*B-4*B*N+1}var U=(O=R-A)*O+(L=x-C)*L+(V=P-w)*V,Z=(O=R-D)*O+(L=x-I)*L+(V=P-F)*V,G=(O=A-D)*O+(L=C-I)*L+(V=w-F)*V,W=c[S+2],j=c[k+2],z=c[E+2];U<Z&&U<G?U<n*N*(W+j)*.5&&wa(v,Ra(v,b,T),m):Z<G?Z<n*N*(j+z)*.5&&wa(v,Ra(v,T,M),m):G<n*N*(W+z)*.5&&wa(v,Ra(v,b,M),m)}}return function(){var e=Sa._iTrisToDelete;o.Z.tidy(e);var t=0;for(t=e.length-1;t>=0;--t)Ea(e[t]);var r=Sa._iVertsToDelete;for(o.Z.tidy(r),t=r.length-1;t>=0;--t)Aa(r[t])}(),function(e,t){var r=Sa._mesh,i=r.getFacesTagFlags(),n=r.getNbTriangles(),a=r.getFacesFromVertices(e),s=t,l=t.length;(t=new Uint32Array(l+a.length)).set(s),t.set(a,l);var u=++o.Z.TAG_FLAG;l=t.length;for(var c=new Uint32Array(o.Z.getMemory(4*l),0,l),h=0,d=0;d<l;++d){var f=t[d];f>=n||i[f]!==u&&(i[f]=u,c[h++]=f)}return new Uint32Array(c.subarray(0,h))}(function(){for(var e=Sa._mesh,t=e.getVerticesTagFlags(),r=e.getNbVertices(),i=++o.Z.TAG_FLAG,n=Sa._iVertsDecimated,a=n.length,s=new Uint32Array(o.Z.getMemory(4*a),0,a),l=0,u=0;u<a;++u){var c=n[u];c>=r||t[c]!==i&&(t[c]=i,s[l++]=c)}return new Uint32Array(s.subarray(0,l))}(),m)}};const Pa=xa;function Da(e){return(Da="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 Ia(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Fa(e,t,r){return(Fa="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Va(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(r):n.value}})(e,t,r||e)}function Oa(e,t){return(Oa=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function La(e,t){return!t||"object"!==Da(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Va(e){return(Va=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Na=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Oa(e,t)}(l,e);var t,r,i,n,a=(i=l,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Va(i);if(n){var r=Va(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return La(this,e)});function l(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(t=a.call(this)).setID(e.getID()),t._meshData={_nbVertices:0,_nbFaces:0,_nbTexCoords:0,_verticesXYZ:null,_normalsXYZ:null,_colorsRGB:null,_materialsPBR:null,_vertOnEdge:null,_vertRingFace:null,_vrfStartCount:null,_vrvStartCount:null,_vertRingVert:null,_vertTagFlags:null,_vertSculptFlags:null,_vertStateFlags:null,_vertProxy:null,_facesABCD:null,_faceEdges:null,_faceNormalsXYZ:null,_facesToTriangles:null,_trianglesABC:null,_facesTagFlags:null,_edges:null,_drawArraysWireframe:null,_drawElementsWireframe:null,_texCoordsST:null,_duplicateStartCount:null,_UVfacesABCD:null,_UVtrianglesABC:null,_DAverticesXYZ:null,_DAnormalsXYZ:null,_DAcolorsRGB:null,_DAmaterialsPBR:null,_DAtexCoordsST:null,_octree:null,_faceBoxes:null,_faceCentersXYZ:null,_facePosInLeaf:null,_faceLeaf:[],_leavesToUpdate:[],_worldBound:[1/0,1/0,1/0,-1/0,-1/0,-1/0]},t.setRenderData(e.getRenderData()),t.setTransformData(e.getTransformData()),t._facesStateFlags=null,t._wireframe=null,t.initFromMesh(e),t.initRender(),t.isDynamic=!0,t}return t=l,(r=[{key:"subdivide",value:function(e,t,r,i,n){return Ma.subdivision(this,e,t,r,i,n,l.LINEAR)}},{key:"decimate",value:function(e,t,r,i,n){return Pa.decimation(this,e,t,r,i,n)}},{key:"getSubdivisionFactor",value:function(){return.01*l.SUBDIVISION_FACTOR}},{key:"getDecimationFactor",value:function(){return.01*l.DECIMATION_FACTOR}},{key:"getVerticesProxy",value:function(){return this.getVertices()}},{key:"addNbVertice",value:function(e){this._meshData._nbVertices+=e}},{key:"getNbTriangles",value:function(){return this.getNbFaces()}},{key:"addNbFace",value:function(e){this._meshData._nbFaces+=e}},{key:"getNbEdges",value:function(){return 3*this.getNbTriangles()}},{key:"getFacesStateFlags",value:function(){return this._facesStateFlags}},{key:"allocateArrays",value:function(){Fa(Va(l.prototype),"allocateArrays",this).call(this),this._meshData._vertRingVert=[],this._meshData._vertRingFace=[],this._facesStateFlags=new Int32Array(this.getNbFaces())}},{key:"initFromMesh",value:function(e){var t=e.getNbVertices();this.setVertices(new Float32Array(e.getVertices().subarray(0,3*t))),this.setColors(new Float32Array(e.getColors().subarray(0,3*t))),this.setMaterials(new Float32Array(e.getMaterials().subarray(0,3*t))),this.setNbVertices(t),this.setFacesFromMesh(e),this.init(),e.isUsingTexCoords()&&this.setShaderType(s.Z.Shader.MATCAP)}},{key:"setFacesFromMesh",value:function(e){this.setFaces(new Uint32Array(4*e.getNbTriangles())),this.setNbFaces(e.getNbTriangles());var t=e.getTriangles(),r=this.getNbTriangles(),i=this.getFaces();this._meshData._trianglesABC=new Uint32Array(t.subarray(0,3*r));for(var n=0;n<r;++n){var a=3*n,s=4*n;i[s]=t[a],i[s+1]=t[a+1],i[s+2]=t[a+2],i[s+3]=o.Z.TRI_INDEX}}},{key:"updateTopology",value:function(e,t){this.updateRenderTriangles(e),this.updateVerticesOnEdge(t),this.getShowWireframe()&&this.updateWireframe(e),this.isUsingDrawArrays()&&this.updateDrawArrays(e)}},{key:"getWireframe",value:function(){return this._wireframe||(this._wireframe=new Uint32Array(2*this.getTriangles().length),this.updateWireframe()),this._wireframe}},{key:"setShowWireframe",value:function(e){this._wireframe=null,Fa(Va(l.prototype),"setShowWireframe",this).call(this,e)}},{key:"updateWireframe",value:function(e){for(var t=this._wireframe,r=this.getTriangles(),i=void 0===e,n=this.isUsingDrawArrays(),a=i?this.getNbTriangles():e.length,s=0;s<a;++s){var o=i?s:e[s],l=6*o,u=3*o;n?(t[l]=t[l+5]=u,t[l+1]=t[l+2]=u+2,t[l+3]=t[l+4]=u+1):(t[l]=t[l+5]=r[u],t[l+1]=t[l+2]=r[u+1],t[l+3]=t[l+4]=r[u+2])}}},{key:"updateRenderTriangles",value:function(e){for(var t=this.getTriangles(),r=this.getFaces(),i=void 0===e,n=i?this.getNbFaces():e.length,a=0;a<n;++a){var s=i?a:e[a],o=3*s,l=4*s;t[o]=r[l],t[o+1]=r[l+1],t[o+2]=r[l+2]}}},{key:"updateVerticesOnEdge",value:function(e){for(var t=this.getVerticesOnEdge(),r=this.getVerticesRingVert(),i=this.getVerticesRingFace(),n=void 0===e,a=n?this.getNbVertices():e.length,s=0;s<a;++s){var o=n?s:e[s];t[o]=r[o].length!==i[o].length?1:0}}},{key:"resizeArray",value:function(e,t){if(!e)return null;if(e.length>=t)return e.subarray(0,2*t);var r=new e.constructor(2*t);return r.set(e),r}},{key:"reAllocateArrays",value:function(e){var t=this._meshData,r=this._facesStateFlags.length,i=this.getNbTriangles(),n=i+e;(r<n||r>4*n)&&(this._facesStateFlags=this.resizeArray(this._facesStateFlags,n),this.getShowWireframe()&&(this._wireframe=this.resizeArray(this._wireframe,6*n)),t._facesABCD=this.resizeArray(t._facesABCD,4*n),t._trianglesABC=this.resizeArray(t._trianglesABC,3*n),t._faceBoxes=this.resizeArray(t._faceBoxes,6*n),t._faceNormalsXYZ=this.resizeArray(t._faceNormalsXYZ,3*n),t._faceCentersXYZ=this.resizeArray(t._faceCentersXYZ,3*n),t._facesTagFlags=this.resizeArray(t._facesTagFlags,n),t._facePosInLeaf=this.resizeArray(t._facePosInLeaf,n)),((r=t._verticesXYZ.length/3)<(n=this.getNbVertices()+e)||r>4*n)&&(t._verticesXYZ=this.resizeArray(t._verticesXYZ,3*n),t._normalsXYZ=this.resizeArray(t._normalsXYZ,3*n),t._colorsRGB=this.resizeArray(t._colorsRGB,3*n),t._materialsPBR=this.resizeArray(t._materialsPBR,3*n),t._vertOnEdge=this.resizeArray(t._vertOnEdge,n),t._vertTagFlags=this.resizeArray(t._vertTagFlags,n),t._vertSculptFlags=this.resizeArray(t._vertSculptFlags,n),t._vertStateFlags=this.resizeArray(t._vertStateFlags,n)),this.isUsingDrawArrays()&&((r=t._verticesXYZ.length/9)<(n=i+10*e)||r>4*n)&&(t._verticesXYZ=this.resizeArray(t._verticesXYZ,9*n),t._normalsXYZ=this.resizeArray(t._normalsXYZ,9*n),t._colorsRGB=this.resizeArray(t._colorsRGB,9*n),t._materialsPBR=this.resizeArray(t._materialsPBR,9*n))}},{key:"initTopology",value:function(){var e=this.getVerticesRingVert(),t=this.getVerticesRingFace(),r=0,i=this.getNbVertices();for(e.length=t.length=i,r=0;r<i;++r)e[r]=[],t[r]=[];var n=this.getNbTriangles(),a=this.getTriangles();for(r=0;r<n;++r){var s=3*r;t[a[s]].push(r),t[a[s+1]].push(r),t[a[s+2]].push(r)}var o=this.getVerticesOnEdge();for(r=0;r<i;++r)this.computeRingVertices(r),o[r]=t[r].length!==e[r].length?1:0}},{key:"computeRingVertices",value:function(e){var t=++o.Z.TAG_FLAG,r=this.getFaces(),i=this.getVerticesTagFlags(),n=this._meshData._vertRingVert[e],a=this._meshData._vertRingFace[e];n.length=0;for(var s=a.length,l=0;l<s;++l){var u=4*a[l],c=r[u],h=r[u+1];c===e?c=r[u+2]:h===e&&(h=r[u+2]),i[c]!==t&&(i[c]=t,n.push(c)),i[h]!==t&&(i[h]=t,n.push(h))}}}])&&Ia(t.prototype,r),l}(Qt);Na.SUBDIVISION_FACTOR=75,Na.DECIMATION_FACTOR=0,Na.LINEAR=!1;const Ba=Na;function Ua(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Za=function(){function e(t,r,i,n){switch(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=t,this._multimesh=r,this._mesh=r.getCurrentMesh(),this._type=i,i){case e.DELETE_LOWER:this._deletedMeshes=r._meshes.slice(0,r._sel);break;case e.DELETE_HIGHER:this._deletedMeshes=r._meshes.slice(r._sel+1),n||(this._vMappingState=this._mesh.getVerticesMapping());break;case e.SUBDIVISION:case e.REVERSION:n||(this._vArState=new Float32Array(this._mesh.getVertices()),this._cArState=new Float32Array(this._mesh.getColors()),this._mArState=new Float32Array(this._mesh.getMaterials()))}}var t,r,i;return t=e,i=[{key:"SUBDIVISION",get:function(){return 0}},{key:"REVERSION",get:function(){return 1}},{key:"SELECTION",get:function(){return 2}},{key:"DELETE_LOWER",get:function(){return 3}},{key:"DELETE_HIGHER",get:function(){return 4}}],(r=[{key:"isNoop",value:function(){return!1}},{key:"undo",value:function(){var t=this._multimesh;switch(this._type){case e.SELECTION:t.selectMesh(this._mesh);break;case e.DELETE_LOWER:Array.prototype.unshift.apply(t._meshes,this._deletedMeshes);break;case e.DELETE_HIGHER:Array.prototype.push.apply(t._meshes,this._deletedMeshes),this._mesh.setVerticesMapping(this._vMappingState);break;case e.SUBDIVISION:case e.REVERSION:var r=this._mesh.getNbVertices();this._mesh.setVertices(new Float32Array(this._vArState)),this._mesh.setColors(new Float32Array(this._cArState)),this._mesh.setMaterials(new Float32Array(this._mArState)),this._mesh.setNbVertices(r),this._type===e.SUBDIVISION?t.popMesh():t.shiftMesh()}t.setSelection(t.findIndexFromMesh(this._mesh)),this._main.setMesh(t)}},{key:"redo",value:function(){var t=this._multimesh;switch(this._type){case e.SELECTION:t.selectMesh(this._mesh);break;case e.DELETE_LOWER:t.deleteLower();break;case e.DELETE_HIGHER:t.deleteHigher();break;case e.SUBDIVISION:t.pushMesh(this._mesh);break;case e.REVERSION:t.unshiftMesh(this._mesh)}t.setSelection(t.findIndexFromMesh(this._mesh)),this._main.setMesh(t)}},{key:"createRedo",value:function(){return new e(this._main,this._multimesh,this._type,!0)}}])&&Ua(t.prototype,r),i&&Ua(t,i),e}();function Ga(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Wa=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._ctrlGui=r,this._main=r._main,this._menu=null,this._ctrlResolution=null,this._ctrlDynamic=null,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){var t=this._menu=e.addMenu((0,V.Z)("topologyTitle"));t.close(),t.addTitle((0,V.Z)("multiresTitle")),this._ctrlResolution=t.addSlider((0,V.Z)("multiresResolution"),1,this.onResolutionChanged.bind(this),1,1,1);var r=t.addDualButton((0,V.Z)("multiresReverse"),(0,V.Z)("multiresSubdivide"),this,this,"reverse","subdivide");this._ctrlReverse=r[0],this._ctrlSubdivide=r[1],r=this._dualButtonDel=t.addDualButton((0,V.Z)("multiresDelLower"),(0,V.Z)("multiresDelHigher"),this,this,"deleteLower","deleteHigher"),this._ctrlDelLower=r[0],this._ctrlDelHigher=r[1],this._ctrlDelLower.domButton.style.background=this._ctrlDelHigher.domButton.style.background="rgba(230,53,59,0.35)";var i=this.remeshResolution.bind(this);t.addTitle((0,V.Z)("remeshTitle")),this._ctrlRes1=t.addSlider((0,V.Z)("remeshResolution"),Gr.RESOLUTION,i,8,400,1),t.addCheckbox((0,V.Z)("remeshBlock"),Gr,"BLOCK"),t.addButton((0,V.Z)("remeshRemesh"),this,"remesh"),t.addTitle((0,V.Z)("remeshTitleMC")),this._ctrlRes2=t.addSlider((0,V.Z)("remeshResolution"),Gr.RESOLUTION,i,8,400,1),t.addCheckbox((0,V.Z)("remeshSmoothingMC"),Gr,"SMOOTHING"),t.addButton((0,V.Z)("remeshRemeshMC"),this,"remeshMC"),t.addTitle((0,V.Z)("dynamicTitle")),this._ctrlDynamic=t.addCheckbox((0,V.Z)("dynamicActivated"),!1,this.dynamicToggleActivate.bind(this)),this._ctrlDynSubd=t.addSlider((0,V.Z)("dynamicSubdivision"),Ba,"SUBDIVISION_FACTOR",0,100,1),this._ctrlDynDec=t.addSlider((0,V.Z)("dynamicDecimation"),Ba,"DECIMATION_FACTOR",0,100,1),this._ctrlDynLin=t.addCheckbox((0,V.Z)("dynamicLinear"),Ba,"LINEAR"),this.updateDynamicVisibility(!1)}},{key:"onKeyUp",value:function(e){if(!0!==e.handled){var t=u.Z.getShortKey(e.which);e.stopPropagation(),t===s.Z.KeyAction.REMESH&&this.remesh()}}},{key:"updateDynamicVisibility",value:function(e){this._ctrlDynSubd.setVisibility(e),this._ctrlDynDec.setVisibility(e),this._ctrlDynLin.setVisibility(e)}},{key:"dynamicToggleActivate",value:function(){var e=this._main,t=e.getMesh();if(t){var r=t.isDynamic?this.convertToStaticMesh(t):new Ba(t);this.updateDynamicVisibility(!t.isDynamic),e.getStateManager().pushStateAddRemove(r,t),e.replaceMesh(t,r)}}},{key:"remeshResolution",value:function(e){Gr.RESOLUTION=e,this._ctrlRes1.setValue(e,!0),this._ctrlRes2.setValue(e,!0)}},{key:"remesh",value:function(e){var t=this._main,r=t.getMesh();if(r){for(var i=r.isDynamic,n=t.getMeshes(),a=t.getSelectedMeshes().slice(),s=0,o=a.length;s<o;++s){var l=a[s];n.splice(t.getIndexMesh(l),1),a[s]=this.convertToStaticMesh(l),l===r&&(r=a[s])}var u=Gr.remesh(a,r,e);i&&(u=new Ba(u)),t.getStateManager().pushStateAddRemove(u,t.getSelectedMeshes().slice()),t.getMeshes().push(u),t.setMesh(u)}}},{key:"remeshMC",value:function(){this.remesh(!0)}},{key:"isMultimesh",value:function(e){return!(!e||!e._meshes)}},{key:"convertToStaticMesh",value:function(e){if(!e.isDynamic)return e;var t=new sr(e.getGL());return t.setID(e.getID()),t.setTransformData(e.getTransformData()),t.setVertices(e.getVertices().subarray(0,3*e.getNbVertices())),t.setColors(e.getColors().subarray(0,3*e.getNbVertices())),t.setMaterials(e.getMaterials().subarray(0,3*e.getNbVertices())),t.setFaces(e.getFaces().subarray(0,4*e.getNbFaces())),Qt.OPTIMIZE=!1,t.init(),Qt.OPTIMIZE=!0,t.setRenderData(e.getRenderData()),t.initRender(),t}},{key:"convertToMultimesh",value:function(e){return this.isMultimesh(e)?e:new ca(this.convertToStaticMesh(e))}},{key:"subdivide",value:function(){var e=this._main,t=e.getMesh();if(t){var r=this.convertToMultimesh(t);r._sel===r._meshes.length-1?r.getNbTriangles()>4e5&&!window.confirm((0,V.Z)("multiresWarnBigMesh",4*r.getNbFaces()))||(t!==r&&(e.replaceMesh(t,r),e.getStateManager().pushStateAddRemove(r,t,!0)),e.getStateManager().pushState(new Za(e,r,Za.SUBDIVISION)),r.addLevel(),e.setMesh(r),e.render()):window.alert((0,V.Z)("multiresSelectHighest"))}}},{key:"reverse",value:function(){var e=this._main,t=e.getMesh();if(t){var r=this.convertToMultimesh(t);if(0===r._sel){var i=new Za(e,r,Za.REVERSION);r.computeReverse()?(t!==r&&(e.replaceMesh(t,r),e.getStateManager().pushStateAddRemove(r,t,!0)),e.getStateManager().pushState(i),e.setMesh(r),e.render()):window.alert((0,V.Z)("multiresNotReversible"))}else window.alert((0,V.Z)("multiresSelectLowest"))}}},{key:"deleteLower",value:function(){var e=this._main,t=e._mesh;this.isMultimesh(t)&&0!==t._sel?(e.getStateManager().pushState(new Za(e,t,Za.DELETE_LOWER)),t.deleteLower(),this.updateMeshResolution()):window.alert((0,V.Z)("multiresNoLower"))}},{key:"deleteHigher",value:function(){var e=this._main,t=e.getMesh();this.isMultimesh(t)&&t._sel!==t._meshes.length-1?(e.getStateManager().pushState(new Za(e,t,Za.DELETE_HIGHER)),t.deleteHigher(),this.updateMeshResolution()):window.alert((0,V.Z)("multiresNoHigher"))}},{key:"onResolutionChanged",value:function(e){var t=e-1,r=this._main,i=r.getMesh();if(i){var n=this.isMultimesh(i),a=n&&i._meshes.length-1===t;this._ctrlReverse.setEnable(!n||0===t),this._ctrlSubdivide.setEnable(!n||a),this._ctrlDelLower.setEnable(n&&0!==t),this._ctrlDelHigher.setEnable(n&&!a),n&&i._sel!==t&&(r.getStateManager().pushState(new Za(r,i,Za.SELECTION)),i.selectResolution(t),this._ctrlGui.updateMeshInfo(),r.render())}}},{key:"updateMeshResolution",value:function(){var e=this._main.getMesh();if(!e||!this.isMultimesh(e))return this._ctrlResolution.setMax(1),void this._ctrlResolution.setValue(0);this._ctrlResolution.setMax(e._meshes.length),this._ctrlResolution.setValue(e._sel+1)}},{key:"updateMesh",value:function(){if(this._main.getMesh()){this._menu.setVisibility(!0),this.updateMeshResolution();var e=this._main.getMesh().isDynamic;this.updateDynamicVisibility(e),this._ctrlDynamic.setValue(e,!0)}else this._menu.setVisibility(!1)}}])&&Ga(t.prototype,r),e}();function ja(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var za=de[s.Z.Shader.MERGE],Xa=de[s.Z.Shader.UV],Ka=de[s.Z.Shader.PBR],Ha=de[s.Z.Shader.MATCAP];const Ya=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=r._main,this._menu=null,this._ctrlFlatShadizfng=null,this._ctrlShowWireframe=null,this._ctrlShaders=null,this._ctrlMatcap=null,this._ctrlUV=null,this._ctrlSectionCut=null,this._ctrlSectionAxis=null,this._ctrlSectionOffset=null,this._ctrlSectionInvert=null,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){var t=this._menu=e.addMenu((0,V.Z)("renderingTitle"));t.close();var r=[];r[s.Z.Shader.MATCAP]=(0,V.Z)("renderingMatcap"),r[s.Z.Shader.PBR]=(0,V.Z)("renderingPBR"),r[s.Z.Shader.NORMAL]=(0,V.Z)("renderingNormal"),r[s.Z.Shader.UV]=(0,V.Z)("renderingUV"),t.addTitle((0,V.Z)("renderingShader")),this._ctrlShaders=t.addCombobox("",s.Z.Shader.MATCAP,this.onShaderChanged.bind(this),r),this._ctrlCurvature=t.addSlider((0,V.Z)("renderingCurvature"),20,this.onCurvatureChanged.bind(this),0,100,1),this._ctrlFilmic=t.addCheckbox((0,V.Z)("renderingFilmic"),za.FILMIC,this.onFilmic.bind(this));for(var i={},n=0,a=Ka.environments,o=a.length;n<o;++n)i[n]=a[n].name;this._ctrlEnvTitle=t.addTitle((0,V.Z)("renderingEnvironment")),this._ctrlEnv=t.addCombobox("",Ka.idEnv,this.onEnvironmentChanged.bind(this),i);for(var l={},u=0,c=Ha.matcaps,h=c.length;u<h;++u)l[u]=c[u].name;this._ctrlMatcapTitle=t.addTitle((0,V.Z)("renderingMaterial")),this._ctrlMatcap=t.addCombobox((0,V.Z)("renderingMatcap"),0,this.onMatcapChanged.bind(this),l),this._ctrlImportMatcap=t.addButton((0,V.Z)("renderingImportMatcap"),this,"importMatcap"),this._ctrlUV=t.addButton((0,V.Z)("renderingImportUV"),this,"importTexture"),this._ctrlExposure=t.addSlider((0,V.Z)("renderingExposure"),1,this.onExposureChanged.bind(this),0,5,.001),this.onUpdateCtrlExposure(),t.addTitle((0,V.Z)("renderingExtra")),this._ctrlTransparency=t.addSlider((0,V.Z)("renderingTransparency"),0,this.onTransparencyChanged.bind(this),0,100,1),this._ctrlFlatShading=t.addCheckbox((0,V.Z)("renderingFlat"),!1,this.onFlatShading.bind(this)),this._ctrlShowWireframe=t.addCheckbox((0,V.Z)("renderingWireframe"),!1,this.onShowWireframe.bind(this)),Yt.ONLY_DRAW_ARRAYS&&this._ctrlShowWireframe.setVisibility(!1),this._ctrlSectionCut=t.addCheckbox((0,V.Z)("renderingSectionCut"),x.sectionCut,this.onSectionCut.bind(this)),this._ctrlSectionAxis=t.addCombobox((0,V.Z)("renderingSectionAxis"),x.sectionCutAxis,this.onSectionAxis.bind(this),{0:"X",1:"Y",2:"Z"}),this._ctrlSectionOffset=t.addSlider((0,V.Z)("renderingSectionOffset"),x.sectionCutOffset,this.onSectionOffset.bind(this),-1,1,.001),this._ctrlSectionInvert=t.addCheckbox((0,V.Z)("renderingSectionInvert"),x.sectionCutInvert,this.onSectionInvert.bind(this)),this.updateSectionVisibility(),this.addEvents()}},{key:"onFilmic",value:function(e){za.FILMIC=e,this._main.render()}},{key:"onCurvatureChanged",value:function(e){this._main.getMesh()&&(this._main.getMesh().setCurvature(e/20),this._main.render())}},{key:"onEnvironmentChanged",value:function(e){Ka.idEnv=e,this.onUpdateCtrlExposure(),this._main.render()}},{key:"onUpdateCtrlExposure",value:function(){this._ctrlExposure.setValue(Ka.environments[Ka.idEnv].exposure)}},{key:"onExposureChanged",value:function(e){Ka.exposure=e,this._main.render()}},{key:"onTransparencyChanged",value:function(e){for(var t=this._main.getSelectedMeshes(),r=0,i=t.length;r<i;++r)t[r].setOpacity(1-e/100);this._main.render()}},{key:"onShaderChanged",value:function(e){for(var t=this._main,r=!1,i=this._main.getSelectedMeshes(),n=0,a=i.length;n<a;++n){var o=i[n];o&&(e!==s.Z.Shader.UV||o.hasUV()?(o.setShaderType(e),t.render()):(r||window.alert("No UV on the mesh."),r=!0),r&&this.updateMesh())}this.updateVisibility()}},{key:"onMatcapChanged",value:function(e){for(var t=this._main.getSelectedMeshes(),r=0,i=t.length;r<i;++r){var n=t[r];n.getShaderType()!==s.Z.Shader.MATCAP&&n.setShaderType(s.Z.Shader.MATCAP),n.setMatcap(e)}this._main.render()}},{key:"onFlatShading",value:function(e){for(var t=this._main.getSelectedMeshes(),r=0,i=t.length;r<i;++r)t[r].setFlatShading(e);this._main.render()}},{key:"onShowWireframe",value:function(e){for(var t=this._main.getSelectedMeshes(),r=0,i=t.length;r<i;++r)t[r].setShowWireframe(e);this._main.render()}},{key:"onSectionCut",value:function(e){x.sectionCut=e,this.updateSectionVisibility(),this._main.render()}},{key:"onSectionAxis",value:function(e){x.sectionCutAxis=0|e,this._main.render()}},{key:"onSectionOffset",value:function(e){x.sectionCutOffset=e,this._main.render()}},{key:"onSectionInvert",value:function(e){x.sectionCutInvert=e,this._main.render()}},{key:"addEvents",value:function(){var e=this.loadTextureUV.bind(this),t=this.loadMatcap.bind(this);document.getElementById("textureopen").addEventListener("change",e,!1),document.getElementById("matcapopen").addEventListener("change",t,!1),this.removeCallback=function(){document.getElementById("textureopen").removeEventListener("change",e,!1),document.getElementById("matcapopen").removeEventListener("change",t,!1)}}},{key:"removeEvents",value:function(){this.removeCallback&&this.removeCallback()}},{key:"updateMesh",value:function(){var e=this._main.getMesh();e?(this._menu.setVisibility(!0),this._ctrlShaders.setValue(e.getShaderType(),!0),this._ctrlFlatShading.setValue(e.getFlatShading(),!0),this._ctrlShowWireframe.setValue(e.getShowWireframe(),!0),this._ctrlMatcap.setValue(e.getMatcap(),!0),this._ctrlTransparency.setValue(100-100*e.getOpacity(),!0),this._ctrlCurvature.setValue(20*e.getCurvature(),!0),this._ctrlSectionCut.setValue(x.sectionCut,!0),this._ctrlSectionAxis.setValue(x.sectionCutAxis,!0),this._ctrlSectionOffset.setValue(x.sectionCutOffset,!0),this._ctrlSectionInvert.setValue(x.sectionCutInvert,!0),this.updateVisibility()):this._menu.setVisibility(!1)}},{key:"updateVisibility",value:function(){var e=this._main.getMesh();if(e){var t=e.getShaderType();this._ctrlMatcapTitle.setVisibility(t===s.Z.Shader.MATCAP),this._ctrlMatcap.setVisibility(t===s.Z.Shader.MATCAP),this._ctrlImportMatcap.setVisibility(t===s.Z.Shader.MATCAP),this._ctrlExposure.setVisibility(t===s.Z.Shader.PBR),this._ctrlEnvTitle.setVisibility(t===s.Z.Shader.PBR),this._ctrlEnv.setVisibility(t===s.Z.Shader.PBR),this._ctrlUV.setVisibility(t===s.Z.Shader.UV),this.updateSectionVisibility()}}},{key:"updateSectionVisibility",value:function(){var e=x.sectionCut;this._ctrlSectionAxis.setVisibility(e),this._ctrlSectionOffset.setVisibility(e),this._ctrlSectionInvert.setVisibility(e)}},{key:"getFlatShading",value:function(){return this._ctrlFlatShading.getValue()}},{key:"getWireframe",value:function(){return this._ctrlShowWireframe.getValue()}},{key:"getShaderName",value:function(){return this._ctrlShaders.getValue()}},{key:"importTexture",value:function(){document.getElementById("textureopen").click()}},{key:"loadTextureUV",value:function(e){if(0!==e.target.files.length){var t=e.target.files[0];if(t.type.match("image.*")){var r=new FileReader,i=this._main;r.onload=function(e){Xa.texture0=void 0,Xa.texPath=e.target.result,i.render()},document.getElementById("textureopen").value="",r.readAsDataURL(t)}}}},{key:"loadMatcap",value:function(e){if(0!==e.target.files.length){var t=e.target.files[0];if(t.type.match("image.*")){var r=new FileReader,i=this._main,n=this._ctrlMatcap;r.onload=function(e){var r=new Image;r.src=e.target.result,r.onload=function(){var e=Ha.matcaps.length;Ha.matcaps.push({name:t.name}),Ha.createTexture(i._gl,r,e);var a={};a[e]=t.name,n.addOptions(a),n.setValue(e),i.render()}},document.getElementById("matcapopen").value="",r.readAsDataURL(t)}}}},{key:"importMatcap",value:function(){document.getElementById("matcapopen").click()}},{key:"onKeyUp",value:function(e){u.Z.getShortKey(e.which)!==s.Z.KeyAction.WIREFRAME||e.ctrlKey||this._ctrlShowWireframe.setValue(!this._ctrlShowWireframe.getValue())}}])&&ja(t.prototype,r),e}();function qa(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Ja=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=r._main,this._menu=null,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){var t=this._menu=e.addMenu((0,V.Z)("sceneTitle"));t.addButton((0,V.Z)("sceneReset"),this,"clearScene"),this._ctrlAddSphere=t.addButton((0,V.Z)("sceneAddSphere"),this._main,"addSphere"),this._ctrlAddCube=t.addButton((0,V.Z)("sceneAddCube"),this._main,"addCube"),this._ctrlAddCylinder=t.addButton((0,V.Z)("sceneAddCylinder"),this._main,"addCylinder"),this._ctrlAddTorus=t.addButton((0,V.Z)("sceneAddTorus"),this._main,"addTorus"),this._ctrlAddSphere&&(this._ctrlAddSphere.setVisibility?this._ctrlAddSphere.setVisibility(!1):this._ctrlAddSphere.domContainer&&(this._ctrlAddSphere.domContainer.style.display="none")),this._ctrlAddCube&&(this._ctrlAddCube.setVisibility?this._ctrlAddCube.setVisibility(!1):this._ctrlAddCube.domContainer&&(this._ctrlAddCube.domContainer.style.display="none")),this._ctrlAddCylinder&&(this._ctrlAddCylinder.setVisibility?this._ctrlAddCylinder.setVisibility(!1):this._ctrlAddCylinder.domContainer&&(this._ctrlAddCylinder.domContainer.style.display="none")),this._ctrlAddTorus&&(this._ctrlAddTorus.setVisibility?this._ctrlAddTorus.setVisibility(!1):this._ctrlAddTorus.domContainer&&(this._ctrlAddTorus.domContainer.style.display="none")),t.addTitle((0,V.Z)("sceneSelection")),this._ctrlIsolate=t.addCheckbox((0,V.Z)("renderingIsolate"),!1,this.showHide.bind(this)),this._ctrlIsolate.setVisibility(!1),this._ctrlMerge=t.addButton((0,V.Z)("sceneMerge"),this,"merge"),this._ctrlMerge.setVisibility(!1),t.addButton((0,V.Z)("sceneDuplicate"),this,"duplicateSelection"),t.addButton((0,V.Z)("sceneDelete"),this,"deleteSelection"),t.addTitle((0,V.Z)("renderingExtra")),t.addCheckbox((0,V.Z)("darkenUnselected"),x.darkenUnselected,this.onDarkenUnselected.bind(this)),t.addCheckbox((0,V.Z)("contourShow"),this._main._showContour,this.onShowContour.bind(this)),t.addCheckbox((0,V.Z)("renderingGrid"),this._main._showGrid,this.onShowGrid.bind(this)),t.addCheckbox((0,V.Z)("renderingSymmetryLine"),x.showSymmetryLine,this.onShowSymmetryLine.bind(this)),this._ctrlOffSym=t.addSlider("SymOffset",0,this.onOffsetSymmetry.bind(this),-1,1,.001)}},{key:"clearScene",value:function(){window.confirm((0,V.Z)("sceneResetConfirm"))&&this._main.clearScene()}},{key:"onOffsetSymmetry",value:function(e){var t=this._main.getMesh();t&&(t.setSymmetryOffset(e),this._main.render())}},{key:"duplicateSelection",value:function(){this._main.duplicateSelection()}},{key:"deleteSelection",value:function(){this._main.deleteCurrentSelection()}},{key:"validatePreview",value:function(){this._main._meshPreview||this._main.addTorus(!0),this._main._meshPreview.setShowWireframe(!1),this._main.addNewMesh(this._main._meshPreview),this._main._meshPreview=null,this.ctrlDiscard.setVisibility(!1),this.ctrlValidate.setVisibility(!1),this._main.render()}},{key:"discardPreview",value:function(){this._main._meshPreview=null,this.ctrlDiscard.setVisibility(!1),this.ctrlValidate.setVisibility(!1),this._main.render()}},{key:"updateTorusRadius",value:function(e){this._main._torusRadius=e,this.updateTorus()}},{key:"updateTorusRadial",value:function(e){this._main._torusRadial=e,this.updateTorus()}},{key:"updateTorusTubular",value:function(e){this._main._torusTubular=e,this.updateTorus()}},{key:"updateTorusWidth",value:function(e){this._main._torusWidth=e,this._main._torusLength<this._main._torusWidth?this.ctrlLE.setValue(e):this.updateTorus()}},{key:"updateTorusLength",value:function(e){this._main._torusLength=e,this._main._torusLength<this._main._torusWidth?this.ctrlWI.setValue(e):this.updateTorus()}},{key:"updateTorus",value:function(){this._main.addTorus(!0),this.ctrlDiscard.setVisibility(!0),this.ctrlValidate.setVisibility(!0),this._main.render()}},{key:"hasHiddenMeshes",value:function(){for(var e=this._main.getMeshes(),t=0;t<e.length;++t)if(!e[t].isVisible())return!0;return!1}},{key:"updateMesh",value:function(){var e=this._main.getMeshes().length,t=this._main.getSelectedMeshes().length;this._ctrlIsolate.setVisibility(this.hasHiddenMeshes()||e!==t&&t>=1),this._ctrlMerge.setVisibility(t>1);var r=this._main.getMesh();this._ctrlOffSym.setValue(r?r.getSymmetryOffset():0)}},{key:"merge",value:function(){var e=this._main,t=e.getSelectedMeshes();if(!(t.length<2)){var r=Gr.mergeMeshes(t,e.getMesh()||t[0]);e.removeMeshes(t),e.getStateManager().pushStateAddRemove(r,t.slice()),e.getMeshes().push(r),e.setMesh(r)}}},{key:"toggleShowHide",value:function(e){this._ctrlIsolate.setValue(!this._ctrlIsolate.getValue(),!!e)}},{key:"showHide",value:function(e){e?this.isolate():this.showAll(),this.updateMesh()}},{key:"setMeshesVisible",value:function(e,t){for(var r=0;r<e.length;++r)e[r].setVisible(t);this._ctrlIsolate.setValue(!t,!0)}},{key:"pushSetMeshesVisible",value:function(e,t){this.setMeshesVisible(e,t);var r=this.setMeshesVisible.bind(this,e,!t),i=this.setMeshesVisible.bind(this,e,t);this._main.getStateManager().pushStateCustom(r,i)}},{key:"isolate",value:function(){var e=this._main,t=e.getSelectedMeshes(),r=e.getMeshes();if(r.length===t.length||r.length<2)this._ctrlIsolate.setValue(!1,!0);else{for(var i=[],n=0;n<r.length;++n)e.getIndexSelectMesh(r[n])<0&&i.push(r[n]);this.pushSetMeshesVisible(i,!1),e.render()}}},{key:"showAll",value:function(){for(var e=this._main,t=e.getMeshes(),r=[],i=0;i<t.length;++i)t[i].isVisible()||r.push(t[i]);this.pushSetMeshesVisible(r,!0),e.render()}},{key:"onDarkenUnselected",value:function(e){x.darkenUnselected=e,this._main.render()}},{key:"onShowSymmetryLine",value:function(e){x.showSymmetryLine=e,this._main.render()}},{key:"onShowGrid",value:function(e){var t=this._main;t._showGrid=e,t.render()}},{key:"onShowContour",value:function(e){var t=this._main;t._showContour=e,t.render()}},{key:"onKeyDown",value:function(e){!0!==e.handled&&(e.stopPropagation(),this._main._focusGui||e.preventDefault(),73===e.which?(this.toggleShowHide(),e.handled=!0):68===e.which&&e.ctrlKey&&(this._main.duplicateSelection(),e.handled=!0))}}])&&qa(t.prototype,r),e}();var Qa=r(358),$a={tools:[]},es=$a.tools;$a.initGuiTools=function(e,t,r){for(var i=0,n=Di.length;i<n;++i)if(Di[i]){var a=es[i];a||(console.error("No gui for tool index : "+i),$a[i]={_ctrls:[],init:function(){}}),a.init(e.getTool(i),t,r),$a.hide(i)}},$a.hide=function(e){for(var t=0,r=es[e]._ctrls,i=r.length;t<i;++t)r[t].setVisibility(!1)},$a.show=function(e){for(var t=0,r=es[e]._ctrls,i=r.length;t<i;++t)r[t].setVisibility(!0)};var ts=function(e,t,r){this[e]=t?r/t:r},rs=function(e,t,r,i){var n=t.addSlider((0,V.Z)("sculptRadius"),e._radius,(function(t){ts.call(e,"_radius",1,t),i.getSculptManager().getSelection().setIsEditMode(!0),i.renderSelectOverRtt()}),5,500,1);return r._ctrlRadius=n,n},is=function(e,t,r){var i=t.addSlider((0,V.Z)("sculptIntensity"),100*e._intensity,ts.bind(e,"_intensity",100),0,100,1);return r._ctrlIntensity=i,i},ns=function(e,t){return t.addSlider((0,V.Z)("sculptHardness"),100*e._hardness,ts.bind(e,"_hardness",100),0,100,1)},as=function(e,t){return t.addCheckbox((0,V.Z)("sculptCulling"),e,"_culling")},ss=function(e,t,r,i){var n=t.addCheckbox(i||(0,V.Z)("sculptNegative"),e,"_negative");return r.toggleNegative=function(){n.setValue(!n.getValue())},n},os=function(){document.getElementById("alphaopen").click()},ls=function(e,t,r,i){e.push(t.addTitle((0,V.Z)("sculptAlphaTitle"))),void 0!==r._lockPosition&&e.push(t.addCheckbox((0,V.Z)("sculptLockPositon"),r,"_lockPosition")),i._ctrlAlpha=t.addCombobox((0,V.Z)("sculptAlphaTex"),r,"_idAlpha",Qa.Z.ALPHAS_NAMES),e.push(i._ctrlAlpha),e.push(t.addButton((0,V.Z)("sculptImportAlpha"),os))};es[s.Z.Tools.BRUSH]={_ctrls:[],init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),this._ctrls.push(is(e,t,this)),this._ctrls.push(ss(e,t,this)),this._ctrls.push(t.addCheckbox((0,V.Z)("sculptClay"),e,"_clay")),this._ctrls.push(t.addCheckbox((0,V.Z)("sculptAccumulate"),e,"_accumulate")),this._ctrls.push(as(e,t)),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.CREASE]={_ctrls:[],init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),this._ctrls.push(is(e,t,this)),this._ctrls.push(ss(e,t,this)),this._ctrls.push(as(e,t)),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.DRAG]={_ctrls:[],init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.FLATTEN]={_ctrls:[],init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),this._ctrls.push(is(e,t,this)),this._ctrls.push(ss(e,t,this)),this._ctrls.push(as(e,t)),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.INFLATE]={_ctrls:[],init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),this._ctrls.push(is(e,t,this)),this._ctrls.push(ss(e,t,this)),this._ctrls.push(as(e,t)),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.PAINT]={_ctrls:[],onMaterialChanged:function(e,t,r){i.JG(t._color,r[0].getValue()),t._material[0]=r[1].getValue()/100,t._material[1]=r[2].getValue()/100;var n=e.getMesh();n&&(t._writeAlbedo&&n.setAlbedo(t._color),t._writeRoughness&&n.setRoughness(t._material[0]),t._writeMetalness&&n.setMetallic(t._material[1]),e.render())},resetMaterialOverride:function(e,t){this._ctrlPicker.getValue()!==t._pickColor&&this._ctrlPicker.setValue(t._pickColor);var r=e.getMesh();r&&r.getAlbedo&&(r.getAlbedo()[0]=-1,r.setRoughness(-1),r.setMetallic(-1),e.render())},onPickedMaterial:function(e,t,r,n,a,s){r.setCanvasCursor(o.Z.cursors.dropper),e[0].setValue(n,!0),e[1].setValue(100*a,!0),e[2].setValue(100*s,!0),i.JG(t._color,n),t._material[0]=a,t._material[1]=s},onColorPick:function(e,t,r){e._pickColor=r,t.setCanvasCursor(r?o.Z.cursors.dropper:"default"),t._action=r?s.Z.Action.SCULPT_EDIT:s.Z.Action.NOTHING,t.renderSelectOverRtt()},init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),this._ctrls.push(is(e,t,this)),this._ctrls.push(ns(e,t)),this._ctrls.push(as(e,t)),this._ctrls.push(t.addTitle((0,V.Z)("sculptPBRTitle"))),this._ctrls.push(t.addButton((0,V.Z)("sculptPaintAll"),e,"paintAll")),this._ctrlPicker=t.addCheckbox((0,V.Z)("sculptPickColor"),e._pickColor,this.onColorPick.bind(this,e,r)),this._ctrls.push(this._ctrlPicker);var i=[],n=this.onMaterialChanged.bind(this,r,e,i),a=t.addColor((0,V.Z)("sculptColor"),e._color,n),s=t.addSlider((0,V.Z)("sculptRoughness"),100*e._material[0],n,0,100,1),o=t.addSlider((0,V.Z)("sculptMetallic"),100*e._material[1],n,0,100,1);i.push(a,s,o),this._ctrls.push(a,s,o),e.setPickCallback(this.onPickedMaterial.bind(this,i,e,r)),this._ctrls.push(t.addTitle("Write channel")),this._ctrls.push(t.addCheckbox((0,V.Z)("sculptColor"),e,"_writeAlbedo")),this._ctrls.push(t.addCheckbox((0,V.Z)("sculptRoughness"),e,"_writeRoughness")),this._ctrls.push(t.addCheckbox((0,V.Z)("sculptMetallic"),e,"_writeMetalness")),window.addEventListener("keyup",this.resetMaterialOverride.bind(this,r,e)),window.addEventListener("mouseup",this.resetMaterialOverride.bind(this,r,e)),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.PINCH]={_ctrls:[],init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),this._ctrls.push(is(e,t,this)),this._ctrls.push(ss(e,t,this)),this._ctrls.push(as(e,t)),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.TWIST]={_ctrls:[],init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),this._ctrls.push(as(e,t)),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.LOCALSCALE]={_ctrls:[],init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),this._ctrls.push(as(e,t)),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.MOVE]={_ctrls:[],init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),this._ctrls.push(is(e,t,this)),this._ctrls.push(t.addCheckbox((0,V.Z)("sculptTopologicalCheck"),e,"_topoCheck")),this._ctrls.push(ss(e,t,this,(0,V.Z)("sculptMoveAlongNormal"))),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.SMOOTH]={_ctrls:[],init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),this._ctrls.push(is(e,t,this)),this._ctrls.push(t.addCheckbox((0,V.Z)("sculptTangentialSmoothing"),e,"_tangent")),this._ctrls.push(as(e,t)),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.MASKING]={_ctrls:[],init:function(e,t,r){this._ctrls.push(rs(e,t,this,r)),this._ctrls.push(is(e,t,this)),this._ctrls.push(ns(e,t)),this._ctrls.push(ss(e,t,this)),this._ctrls.push(as(e,t)),this._main=r,this._tool=e;var i=t.addDualButton((0,V.Z)("sculptMaskingClear"),(0,V.Z)("sculptMaskingInvert"),e,e,"clear","invert"),n=t.addDualButton((0,V.Z)("sculptMaskingBlur"),(0,V.Z)("sculptMaskingSharpen"),e,e,"blur","sharpen");this._ctrls.push(i[0],i[1],n[0],n[1]),this._ctrls.push(t.addTitle((0,V.Z)("sculptExtractTitle"))),this._ctrls.push(t.addSlider((0,V.Z)("sculptExtractThickness"),e,"_thickness",-5,5,.001)),this._ctrls.push(t.addButton((0,V.Z)("sculptExtractAction"),e,"extract")),ls(this._ctrls,t,e,this)}},es[s.Z.Tools.TRANSFORM]={_ctrls:[],init:function(){}},es[s.Z.Tools.PEN]={_ctrls:[],init:function(e,t){var r={};r[0]=(0,V.Z)("penModePoints"),r[1]=(0,V.Z)("penModeStroke"),this._ctrls.push(t.addCombobox((0,V.Z)("penMode"),e._mode,(function(t){e._mode=0|t}),r)),this._ctrls.push(t.addCheckbox((0,V.Z)("penCloseLoop"),e._closeLoop,e.setCloseLoop.bind(e))),this._ctrls.push(t.addSlider((0,V.Z)("penSpacing"),1e3*e._spacing,(function(t){e._spacing=t/1e3}),1,50,1)),this._ctrls.push(t.addButton((0,V.Z)("penClear"),e,"clearStroke"))}};const us=$a;function cs(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var hs=us.tools;const ds=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=r._main,this._ctrlGui=r,this._sculptManager=r._main.getSculptManager(),this._toolOnRelease=-1,this._invertSign=!1,this._modalBrushRadius=!1,this._modalBrushIntensity=!1,this._lastPageX=0,this._lastPageY=0,this._refX=0,this._refY=0,this._menu=null,this._ctrlSculpt=null,this._ctrlSymmetry=null,this._ctrlContinuous=null,this._ctrlTitleCommon=null,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){var t=this._menu=e.addMenu((0,V.Z)("sculptTitle"));t.open(),t.addTitle((0,V.Z)("sculptTool"));for(var r=[],i=0,n=Di.length;i<n;++i)Di[i]&&(r[i]=(0,V.Z)(Di[i].uiName));this._ctrlSculpt=t.addCombobox((0,V.Z)("sculptTool"),this._sculptManager.getToolIndex(),this.onChangeTool.bind(this),r),us.initGuiTools(this._sculptManager,this._menu,this._main),this._ctrlTitleCommon=t.addTitle((0,V.Z)("sculptCommon")),this._ctrlSymmetry=t.addCheckbox((0,V.Z)("sculptSymmetry"),this._sculptManager._symmetry,this.onSymmetryChange.bind(this)),this._ctrlContinuous=t.addCheckbox((0,V.Z)("sculptContinuous"),this._sculptManager,"_continuous"),us.show(this._sculptManager.getToolIndex()),this.addEvents(),this.onChangeTool(this._sculptManager.getToolIndex())}},{key:"onSymmetryChange",value:function(e){this._sculptManager._symmetry=e,this._main.render()}},{key:"addEvents",value:function(){var e=this.loadAlpha.bind(this);document.getElementById("alphaopen").addEventListener("change",e,!1),this.removeCallback=function(){document.getElementById("alphaopen").removeEventListener("change",e,!1)}}},{key:"removeEvents",value:function(){this.removeCallback&&this.removeCallback()}},{key:"getSelectedTool",value:function(){return this._ctrlSculpt.getValue()}},{key:"releaseInvertSign",value:function(){if(this._invertSign){this._invertSign=!1;var e=hs[this.getSelectedTool()];e.toggleNegative&&e.toggleNegative()}}},{key:"onChangeTool",value:function(e){us.hide(this._sculptManager.getToolIndex()),this._sculptManager.setToolIndex(e),us.show(e);var t=!0===this._sculptManager.canBeContinuous();this._ctrlContinuous.setVisibility(t);var r=e!==s.Z.Tools.TRANSFORM;this._ctrlSymmetry.setVisibility(r),this._ctrlTitleCommon.setVisibility(t||r),this._main.getPicking().updateLocalAndWorldRadius2()}},{key:"loadAlpha",value:function(e){if(0!==e.target.files.length){var t=e.target.files[0];if(t.type.match("image.*")){var r=new FileReader,i=this._main,n=hs[this._sculptManager.getToolIndex()];r.onload=function(e){var r=new Image;r.src=e.target.result,r.onload=i.onLoadAlphaImage.bind(i,r,t.name||"new alpha",n)},document.getElementById("alphaopen").value="",r.readAsDataURL(t)}}}},{key:"addAlphaOptions",value:function(e){for(var t=0,r=hs.length;t<r;++t){var i=hs[t];i&&i._ctrlAlpha&&i._ctrlAlpha.addOptions(e)}}},{key:"updateMesh",value:function(){this._menu.setVisibility(!!this._main.getMesh())}},{key:"_startModalBrushRadius",value:function(e,t){this._refX=e,this._refY=t;var r=hs[this.getSelectedTool()];if(r._ctrlRadius){var i=r._ctrlRadius.getValue();this._refX-=i,this._main.getSculptManager().getSelection().setOffsetX(-i*this._main.getPixelRatio()),this._main.renderSelectOverRtt()}}},{key:"_checkModifierKey",value:function(e){var t=this.getSelectedTool();if(this._main._action===s.Z.Action.NOTHING&&(!e.shiftKey||e.altKey||e.ctrlKey||t!==s.Z.Tools.SMOOTH&&(this._toolOnRelease=t,this._ctrlSculpt.setValue(s.Z.Tools.SMOOTH)),!e.ctrlKey||e.shiftKey||e.altKey||t!==s.Z.Tools.MASKING&&(this._toolOnRelease=t,this._ctrlSculpt.setValue(s.Z.Tools.MASKING))),e.altKey){if(this._invertSign||e.shiftKey)return!0;this._invertSign=!0;var r=hs[t];return r.toggleNegative&&r.toggleNegative(),!0}return!1}},{key:"onKeyDown",value:function(e){if(!0!==e.handled){var t=this._main,r=u.Z.getShortKey(e.which);if(e.stopPropagation(),t._focusGui&&r!==s.Z.KeyAction.RADIUS&&r!==s.Z.KeyAction.INTENSITY||e.preventDefault(),e.handled=!0,!this._checkModifierKey(e)&&t._action===s.Z.Action.NOTHING){if(void 0!==r&&Di[r])return this._ctrlSculpt.setValue(r);var i=hs[this.getSelectedTool()];switch(r){case s.Z.KeyAction.DELETE:t.deleteCurrentSelection();break;case s.Z.KeyAction.INTENSITY:this._modalBrushIntensity=t._focusGui=!0;break;case s.Z.KeyAction.RADIUS:this._modalBrushRadius||this._startModalBrushRadius(this._lastPageX,this._lastPageY),this._modalBrushRadius=t._focusGui=!0;break;case s.Z.KeyAction.NEGATIVE:i.toggleNegative&&i.toggleNegative();break;case s.Z.KeyAction.PICKER:var n=i._ctrlPicker;n&&!n.getValue()&&n.setValue(!0);break;default:e.handled=!1}}}}},{key:"onKeyUp",value:function(e){var t=this._main._action===s.Z.Action.NOTHING&&-1!==this._toolOnRelease&&!e.ctrlKey&&!e.shiftKey;e.altKey&&!t||this.releaseInvertSign(),t&&(this._ctrlSculpt.setValue(this._toolOnRelease),this._toolOnRelease=-1);var r=this._main;switch(u.Z.getShortKey(e.which)){case s.Z.KeyAction.RADIUS:this._modalBrushRadius=r._focusGui=!1,this._main.getSculptManager().getSelection().setOffsetX(0),e.pageX=this._lastPageX,e.pageY=this._lastPageY,r.setMousePosition(e),r.getPicking().intersectionMouseMeshes(),r.renderSelectOverRtt();break;case s.Z.KeyAction.PICKER:var i=hs[this.getSelectedTool()]._ctrlPicker;i&&i.getValue()&&i.setValue(!1);break;case s.Z.KeyAction.INTENSITY:this._modalBrushIntensity=r._focusGui=!1}}},{key:"onMouseUp",value:function(e){-1===this._toolOnRelease||e.ctrlKey||e.shiftKey||(this.releaseInvertSign(),this._ctrlSculpt.setValue(this._toolOnRelease),this._toolOnRelease=-1)}},{key:"onMouseMove",value:function(e){var t=hs[this.getSelectedTool()];if(this._modalBrushRadius&&t._ctrlRadius){var r=e.pageX-this._refX,i=e.pageY-this._refY;t._ctrlRadius.setValue(Math.sqrt(r*r+i*i)),this._main.renderSelectOverRtt()}this._modalBrushIntensity&&t._ctrlIntensity&&t._ctrlIntensity.setValue(t._ctrlIntensity.getValue()+e.pageX-this._lastPageX),this._lastPageX=e.pageX,this._lastPageY=e.pageY}},{key:"onMouseOver",value:function(e){this._modalBrushRadius&&this._startModalBrushRadius(e.pageX,e.pageY)}}])&&cs(t.prototype,r),e}();function fs(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const _s=function(){function e(t,r,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=t,this._addedMeshes=void 0!==r.length?r:[r],this._removedMeshes=void 0!==i.length?i:[i],this._selectMeshes=t.getSelectedMeshes().slice()}var t,r;return t=e,(r=[{key:"isNoop",value:function(){return 0===this._addedMeshes.length&&0===this._removedMeshes.length}},{key:"undo",value:function(){var e,t,r=this._main,i=r.getMeshes(),n=this._addedMeshes;for(e=0,t=n.length;e<t;++e)i.splice(r.getIndexMesh(n[e]),1);var a=this._removedMeshes;for(e=0,t=a.length;e<t;++e)i.push(a[e]);for(e=0,t=i.length;e<t;++e)i[e].initRender();var s=this._selectMeshes;r.setMesh(s[0]?s[0]:null);var o=r.getSelectedMeshes();for(o.length=0,e=0,t=s.length;e<t;++e)o.push(s[e])}},{key:"redo",value:function(){this.undo()}},{key:"createRedo",value:function(){return new e(this._main,this._removedMeshes,this._addedMeshes)}}])&&fs(t.prototype,r),e}();function ps(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const gs=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=t,this._mesh=r,this._idVertState=[],this._cArState=[],this._mArState=[]}var t,r;return t=e,(r=[{key:"isNoop",value:function(){return 0===this._idVertState.length}},{key:"undo",value:function(){this.pullVertices();var e=this._mesh;e.updateDuplicateColorsAndMaterials(),e.updateDrawArrays(),e.updateColorBuffer(),e.updateMaterialBuffer(),this._main.setMesh(e)}},{key:"redo",value:function(){this.undo()}},{key:"createRedo",value:function(){var t=new e(this._main,this._mesh);return this.pushRedoVertices(t),t}},{key:"pushVertices",value:function(e){for(var t=this._idVertState,r=this._cArState,i=this._mArState,n=this._mesh,a=n.getColors(),s=n.getMaterials(),l=n.getVerticesStateFlags(),u=o.Z.STATE_FLAG,c=e.length,h=0;h<c;++h){var d=e[h];l[d]!==u&&(l[d]=u,t.push(d),d*=3,r.push(a[d],a[d+1],a[d+2]),i.push(s[d],s[d+1],s[d+2]))}}},{key:"pushRedoVertices",value:function(e){for(var t=e._mesh,r=t.getColors(),i=t.getMaterials(),n=this._idVertState,a=n.length,s=e._cArState=new Float32Array(3*a),o=e._mArState=new Float32Array(3*a),l=e._idVertState=new Uint32Array(a),u=0;u<a;++u){var c=l[u]=n[u];c*=3;var h=3*u;s[h]=r[c],s[h+1]=r[c+1],s[h+2]=r[c+2],o[h]=i[c],o[h+1]=i[c+1],o[h+2]=i[c+2]}}},{key:"pullVertices",value:function(){for(var e=this._cArState,t=this._mArState,r=this._idVertState,i=r.length,n=this._mesh,a=n.getColors(),s=n.getMaterials(),o=0;o<i;++o){var l=3*r[o],u=3*o;a[l]=e[u],a[l+1]=e[u+1],a[l+2]=e[u+2],s[l]=t[u],s[l+1]=t[u+1],s[l+2]=t[u+2]}}}])&&ps(t.prototype,r),e}();function ms(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const vs=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=t,this._mesh=r,this._center=i.JG([0,0,0],r.getCenter()),this._idVertState=[],this._vArState=[]}var t,r;return t=e,(r=[{key:"isNoop",value:function(){return 0===this._idVertState.length}},{key:"undo",value:function(){this.pullVertices();var e=this._mesh;e.updateGeometry(e.getFacesFromVertices(this._idVertState),this._idVertState),e.updateGeometryBuffers(),i.JG(e.getCenter(),this._center),this._main.setMesh(e)}},{key:"redo",value:function(){this.undo()}},{key:"createRedo",value:function(){var t=new e(this._main,this._mesh);return this.pushRedoVertices(t),t}},{key:"pushVertices",value:function(e){for(var t=this._idVertState,r=this._vArState,i=this._mesh,n=i.getVertices(),a=i.getVerticesStateFlags(),s=o.Z.STATE_FLAG,l=e.length,u=0;u<l;++u){var c=e[u];a[c]!==s&&(a[c]=s,t.push(c),c*=3,r.push(n[c],n[c+1],n[c+2]))}}},{key:"pushRedoVertices",value:function(e){for(var t=e._mesh.getVertices(),r=this._idVertState,i=r.length,n=e._vArState=new Float32Array(3*i),a=e._idVertState=new Uint32Array(i),s=0;s<i;++s){var o=a[s]=r[s];o*=3;var l=3*s;n[l]=t[o],n[l+1]=t[o+1],n[l+2]=t[o+2]}}},{key:"pullVertices",value:function(){for(var e=this._vArState,t=this._idVertState,r=t.length,i=this._mesh.getVertices(),n=0;n<r;++n){var a=3*t[n],s=3*n;i[a]=e[s],i[a+1]=e[s+1],i[a+2]=e[s+2]}}}])&&ms(t.prototype,r),e}();function ys(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const bs=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=t,this._mesh=r,this._center=i.JG([0,0,0],r.getCenter()),this._nbFacesState=r.getNbFaces(),this._nbVerticesState=r.getNbVertices(),this._idVertState=[],this._fRingState=[],this._vRingState=[],this._vArState=[],this._cArState=[],this._mArState=[],this._idFaceState=[],this._fArState=[]}var t,r;return t=e,(r=[{key:"isNoop",value:function(){return 0===this._idVertState.length&&0===this._idFaceState.length}},{key:"undo",value:function(){this.pullVertices(),this.pullFaces();var e=this._mesh;e.setNbVertices(this._nbVerticesState),e.setNbFaces(this._nbFacesState),e.updateTopology(),e.updateGeometry(),e.updateDuplicateColorsAndMaterials(),e.updateDrawArrays(),e.updateColorBuffer(),e.updateMaterialBuffer(),e.updateBuffers(),i.JG(e.getCenter(),this._center),this._main.setMesh(e)}},{key:"redo",value:function(){this.undo()}},{key:"createRedo",value:function(){var t=new e(this._main,this._mesh);return this.pushRedoVertices(t),this.pushRedoFaces(t),t}},{key:"pushVertices",value:function(e){for(var t=this._idVertState,r=this._fRingState,i=this._vRingState,n=this._vArState,a=this._cArState,s=this._mArState,l=this._mesh,u=l.getVerticesRingFace(),c=l.getVerticesRingVert(),h=l.getVertices(),d=l.getColors(),f=l.getMaterials(),_=l.getVerticesStateFlags(),p=o.Z.STATE_FLAG,g=e.length,m=0;m<g;++m){var v=e[m];_[v]!==p&&(_[v]=p,r.push(u[v].slice()),i.push(c[v].slice()),t.push(v),v*=3,n.push(h[v],h[v+1],h[v+2]),a.push(d[v],d[v+1],d[v+2]),s.push(f[v],f[v+1],f[v+2]))}}},{key:"pushFaces",value:function(e){for(var t=this._idFaceState,r=this._fArState,i=this._mesh,n=i.getFaces(),a=i.getFacesStateFlags(),s=o.Z.STATE_FLAG,l=e.length,u=0;u<l;++u){var c=e[u];a[c]!==s&&(a[c]=s,t.push(c),c*=4,r.push(n[c],n[c+1],n[c+2],n[c+3]))}}},{key:"pushRedoVertices",value:function(e){var t=e._mesh,r=t.getNbVertices(),i=t.getVerticesRingFace(),n=t.getVerticesRingVert(),a=t.getVertices(),s=t.getColors(),l=t.getMaterials(),u=0,c=0,h=0,d=this._idVertState,f=d.length,_=this._nbVerticesState,p=Math.min(_,r),g=new Uint32Array(o.Z.getMemory(4*r),0,r);for(u=0;u<f;++u)(c=d[u])<p&&(g[h++]=c);for(u=_;u<r;++u)g[h++]=u;f=h,g=e._idVertState=new Uint32Array(g.subarray(0,f));var m=e._fRingState=new Array(f),v=e._vRingState=new Array(f),y=e._vArState=new Float32Array(3*f),b=e._cArState=new Float32Array(3*f),T=e._mArState=new Float32Array(3*f);for(u=0;u<f;++u){c=g[u],m[u]=i[c].slice(),v[u]=n[c].slice(),c*=3;var M=3*u;y[M]=a[c],y[M+1]=a[c+1],y[M+2]=a[c+2],b[M]=s[c],b[M+1]=s[c+1],b[M+2]=s[c+2],T[M]=l[c],T[M+1]=l[c+1],T[M+2]=l[c+2]}}},{key:"pushRedoFaces",value:function(e){var t=e._mesh,r=t.getNbFaces(),i=t.getFaces(),n=0,a=0,s=0,l=this._idFaceState,u=l.length,c=this._nbFacesState,h=Math.min(c,r),d=new Uint32Array(o.Z.getMemory(4*r),0,r);for(n=0;n<u;++n)(a=l[n])<h&&(d[s++]=a);for(n=c;n<r;++n)d[s++]=n;u=s,d=e._idFaceState=new Uint32Array(d.subarray(0,u));var f=e._fArState=new Int32Array(4*u);for(n=0;n<u;++n){a=d[n],a*=4;var _=4*n;f[_]=i[a],f[_+1]=i[a+1],f[_+2]=i[a+2],f[_+3]=i[a+3]}}},{key:"pullVertices",value:function(){for(var e=this._nbVerticesState,t=this._fRingState,r=this._vRingState,i=this._vArState,n=this._cArState,a=this._mArState,s=this._idVertState,o=s.length,l=this._mesh,u=l.getVerticesRingFace(),c=l.getVerticesRingVert(),h=l.getVertices(),d=l.getColors(),f=l.getMaterials(),_=0;_<o;++_){var p=s[_];if(!(p>=e)){u[p]=t[_].slice(),c[p]=r[_].slice();var g=3*_;h[p*=3]=i[g],h[p+1]=i[g+1],h[p+2]=i[g+2],d[p]=n[g],d[p+1]=n[g+1],d[p+2]=n[g+2],f[p]=a[g],f[p+1]=a[g+1],f[p+2]=a[g+2]}}}},{key:"pullFaces",value:function(){for(var e=this._nbFacesState,t=this._fArState,r=this._idFaceState,i=r.length,n=this._mesh.getFaces(),a=0;a<i;++a){var s=r[a];if(!(s>=e)){var o=4*a;n[s*=4]=t[o],n[s+1]=t[o+1],n[s+2]=t[o+2],n[s+3]=t[o+3]}}}}])&&ys(t.prototype,r),e}();function Ts(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Ms=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._undocb=t,this._redocb=r||t}var t,r;return t=e,(r=[{key:"isNoop",value:function(){return!this._undocb}},{key:"undo",value:function(){this._undocb()}},{key:"redo",value:function(){this._redocb()}},{key:"createRedo",value:function(){return new e(this._undocb,this._redocb)}}])&&Ts(t.prototype,r),e}();function Ss(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var ks=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=t,this._undos=[],this._redos=[],this._curUndoIndex=-1}var t,r;return t=e,(r=[{key:"pushStateCustom",value:function(e,t,r){var i=new Ms(e,t);i.squash=r,this.pushState(i)}},{key:"pushStateAddRemove",value:function(e,t,r){var i=new _s(this._main,e,t);i.squash=r,this.pushState(i)}},{key:"pushStateRemove",value:function(e){this.pushState(new _s(this._main,[],e))}},{key:"pushStateAdd",value:function(e){this.pushState(new _s(this._main,e,[]))}},{key:"pushStateColorAndMaterial",value:function(e){e.isDynamic?this.pushState(new bs(this._main,e)):this.pushState(new gs(this._main,e))}},{key:"pushStateGeometry",value:function(e){e.isDynamic?this.pushState(new bs(this._main,e)):this.pushState(new vs(this._main,e))}},{key:"pushStateMultiresolution",value:function(e,t){this.pushState(new Za(this._main,e,t))}},{key:"setNewMaxStack",value:function(t){e.STACK_LENGTH=t;for(var r=this._undos,i=this._redos;this._curUndoIndex>=t;)r.shift(),--this._curUndoIndex;for(;r.length>t;)r.pop(),i.shift()}},{key:"pushState",value:function(t){++o.Z.STATE_FLAG;var r=this._undos;-1===this._curUndoIndex?r.length=0:r.length>=e.STACK_LENGTH&&(r.shift(),--this._curUndoIndex),this._redos.length=0,++this._curUndoIndex,r.length>0&&(r.length=this._curUndoIndex),r.push(t)}},{key:"getCurrentState",value:function(){return this._undos[this._curUndoIndex]}},{key:"pushVertices",value:function(e){e&&e.length>0&&this.getCurrentState().pushVertices(e)}},{key:"pushFaces",value:function(e){e&&e.length>0&&this.getCurrentState().pushFaces(e)}},{key:"undo",value:function(){if(this._undos.length&&!(this._curUndoIndex<0)){var e=this.getCurrentState(),t=e.createRedo();t.squash=e.squash,this._redos.push(t),e.undo(),this._curUndoIndex--,!0===e.squash&&this.undo()}}},{key:"redo",value:function(){this._redos.length&&(this._redos[this._redos.length-1].redo(),this._curUndoIndex++,this._redos.pop(),this._redos.length&&!0===this._redos[this._redos.length-1].squash&&this.redo())}},{key:"reset",value:function(){this._undos.length=0,this._redos.length=0,this._curUndoIndex=-1}},{key:"cleanNoop",value:function(){for(;this._curUndoIndex>=0&&this.getCurrentState().isNoop();)this._undos.length--,this._curUndoIndex--,this._redos.length=0}}])&&Ss(t.prototype,r),e}();ks.STACK_LENGTH=15;const Es=ks;function As(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Cs=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._ctrlGui=r,this._main=r._main,this._menu=null,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){var t=this._menu=e.addMenu((0,V.Z)("stateTitle"));t.addButton((0,V.Z)("stateUndo"),this,"onUndo","CTRL+Z"),t.addButton((0,V.Z)("stateRedo"),this,"onRedo","CTRL+Y"),t.addTitle((0,V.Z)("stateMaxStack"));var r=this._main.getStateManager();t.addSlider("",Es.STACK_LENGTH,r.setNewMaxStack.bind(r),3,50,1)}},{key:"onUndo",value:function(){this._main._action=s.Z.Action.NOTHING,this._main.getSculptManager().end(),this._main.getStateManager().undo(),this._main.render(),this._ctrlGui.updateMesh()}},{key:"onRedo",value:function(){this._main.getStateManager().redo(),this._main.render(),this._ctrlGui.updateMesh()}},{key:"onKeyDown",value:function(e){if(!0!==e.handled){e.stopPropagation(),this._main._focusGui||e.preventDefault();var t=e.which;e.ctrlKey&&90===t?(this.onUndo(),e.handled=!0):e.ctrlKey&&89===t&&(this.onRedo(),e.handled=!0)}}}])&&As(t.prototype,r),e}();function ws(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Rs=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._menu=null,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){var t=this._menu=e.addMenu((0,V.Z)("pressureTitle"));t.addTitle((0,V.Z)("pressureRadius")),t.addSlider("",a.Z,"radiusFactor",0,1,.01),t.addTitle((0,V.Z)("pressureIntensity")),t.addSlider("",a.Z,"intensityFactor",0,1,.01),t.domContainer&&(t.domContainer.style.display="none")}}])&&ws(t.prototype,r),e}();function xs(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Ps=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=r._main,this._ctrlGui=r,this._menu=null,this._parent=t,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){var t=this._menu=e.addMenu("Comparison Image");this._opacitySlider=t.addSlider("Opacity",.8,this.onOpacityChange.bind(this),0,1,.01),this._depthCheckbox=t.addCheckbox("Respect Depth",!1,this.onDepthChange.bind(this)),t.addTitle("Size"),this._widthSlider=t.addSlider("Width",10,this.onWidthChange.bind(this),.1,100,.1),this._heightSlider=t.addSlider("Height",10,this.onHeightChange.bind(this),.1,100,.1),this._aspectRatioCheckbox=t.addCheckbox("Lock Aspect Ratio",!0,this.onAspectRatioChange.bind(this)),this._aspectRatioLocked=!0,t.addTitle("Position"),this._posXSlider=t.addSlider("X",0,this.onPositionXChange.bind(this),-100,100,.1),this._posYSlider=t.addSlider("Y",0,this.onPositionYChange.bind(this),-100,100,.1),this._posZSlider=t.addSlider("Z",0,this.onPositionZChange.bind(this),-100,100,.1),t.addTitle("Images"),this._deleteButton=t.addButton("Delete Selected",this,"deleteSelectedImage"),t.addButton("Select Next Image",this,"selectNextImage"),t.addButton("Select Previous Image",this,"selectPreviousImage"),this.updateVisibility(),this.updateImageList()}},{key:"updateVisibility",value:function(){var e=this._main.getSelectedComparisonImage();if(this._menu&&this._menu.domContainer&&(this._menu.domContainer.style.display=e?"block":"none"),e){this._opacitySlider.setValue(e.getOpacity(),!0),this._depthCheckbox.setValue(e.getUseDepth());var t=e.getSize();this._widthSlider.setValue(t.width,!0),this._heightSlider.setValue(t.height,!0);var r=e.getPosition();this._posXSlider.setValue(r[0],!0),this._posYSlider.setValue(r[1],!0),this._posZSlider.setValue(r[2],!0)}this.updateImageList()}},{key:"updateImageList",value:function(){this._main.getComparisonImages()}},{key:"selectNextImage",value:function(){var e=this._main.getComparisonImages();if(0!==e.length){var t=this._main.getSelectedComparisonImage(),r=((t?e.indexOf(t):-1)+1)%e.length;this._main.setSelectedComparisonImage(e[r]),this.updateVisibility()}}},{key:"selectPreviousImage",value:function(){var e=this._main.getComparisonImages();if(0!==e.length){var t=this._main.getSelectedComparisonImage(),r=t?e.indexOf(t):-1,i=r<=0?e.length-1:r-1;this._main.setSelectedComparisonImage(e[i]),this.updateVisibility()}}},{key:"onOpacityChange",value:function(e){var t=this._main.getSelectedComparisonImage();t&&(t.setOpacity(e),this._main.render())}},{key:"onDepthChange",value:function(e){var t=this._main.getSelectedComparisonImage();t&&(t.setUseDepth(e),this._main.render())}},{key:"onWidthChange",value:function(e){var t=this._main.getSelectedComparisonImage();if(t){var r=t.getSize();if(t.setSizeMaintainAspect(e,r.height,this._aspectRatioLocked),this._aspectRatioLocked){var i=t.getSize();this._heightSlider.setValue(i.height,!0)}this._main.render()}}},{key:"onHeightChange",value:function(e){var t=this._main.getSelectedComparisonImage();if(t){var r=t.getSize();if(t.setSizeMaintainAspect(r.width,e,this._aspectRatioLocked),this._aspectRatioLocked){var i=t.getSize();this._widthSlider.setValue(i.width,!0)}this._main.render()}}},{key:"onAspectRatioChange",value:function(e){this._aspectRatioLocked=e}},{key:"onPositionXChange",value:function(e){var t=this._main.getSelectedComparisonImage();if(t){var r=t.getPosition();t.setPosition(e,r[1],r[2]),this._main.render()}}},{key:"onPositionYChange",value:function(e){var t=this._main.getSelectedComparisonImage();if(t){var r=t.getPosition();t.setPosition(r[0],e,r[2]),this._main.render()}}},{key:"onPositionZChange",value:function(e){var t=this._main.getSelectedComparisonImage();if(t){var r=t.getPosition();t.setPosition(r[0],r[1],e),this._main.render()}}},{key:"deleteSelectedImage",value:function(){var e=this._main.getSelectedComparisonImage();e&&window.confirm("Delete this comparison image?")&&(this._main.removeComparisonImage(e),this.updateVisibility())}}])&&xs(t.prototype,r),e}();function Ds(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Is=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=r._main,this._ctrlGui=r,this._sculptManager=r._main.getSculptManager(),this._menu=null,this._ctrlEnable=null,this._ctrlMode=null,this._ctrlCloseLoop=null,this._ctrlSpacing=null,this._ctrlClear=null,this._ctrlNewSet=null,this._ctrlFinishSet=null,this._featureListEmpty=null,this._featureListCtrls=[],this._prevToolIndex=-1,this._tool=null,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){this._tool=this._sculptManager.getTool(s.Z.Tools.PEN);var t=this._menu=e.addMenu((0,V.Z)("penTitle"));t.close(),this._ctrlEnable=t.addCheckbox((0,V.Z)("penEnable"),!1,this.onEnable.bind(this));var r={};r[0]=(0,V.Z)("penModePoints"),r[1]=(0,V.Z)("penModeStroke"),this._ctrlMode=t.addCombobox((0,V.Z)("penMode"),this._tool._mode,this.onModeChange.bind(this),r),this._ctrlCloseLoop=t.addCheckbox((0,V.Z)("penCloseLoop"),this._tool._closeLoop,this.onCloseLoop.bind(this)),this._ctrlSpacing=t.addSlider((0,V.Z)("penSpacing"),1e3*this._tool._spacing,this.onSpacingChange.bind(this),1,50,1),this._ctrlClear=t.addButton((0,V.Z)("penClear"),this._tool,"clearStroke"),this._ctrlNewSet=t.addButton((0,V.Z)("penNewSet"),this,"createNewSet"),this._ctrlFinishSet=t.addButton((0,V.Z)("penFinishSet"),this,"finishSet"),t.addTitle((0,V.Z)("penFeatureList")),this._featureListEmpty=t.addButton((0,V.Z)("penNoFeatures"),(function(){})),this._featureListEmpty.domButton&&(this._featureListEmpty.domButton.style.pointerEvents="none",this._featureListEmpty.domButton.style.opacity="0.6"),this._tool.setOnFeaturesChanged(this.updateFeatureList.bind(this)),this.updateFeatureList(),this.updatePenControls()}},{key:"updateMesh",value:function(){this._menu.setVisibility(!!this._main.getMesh())}},{key:"onEnable",value:function(e){if(e)this._prevToolIndex=this._sculptManager.getToolIndex(),this._ctrlGui._ctrlSculpting&&this._ctrlGui._ctrlSculpting._ctrlSculpt?this._ctrlGui._ctrlSculpting._ctrlSculpt.setValue(s.Z.Tools.PEN):this._sculptManager.setToolIndex(s.Z.Tools.PEN);else{var t=this._prevToolIndex>=0?this._prevToolIndex:s.Z.Tools.BRUSH;this._ctrlGui._ctrlSculpting&&this._ctrlGui._ctrlSculpting._ctrlSculpt?this._ctrlGui._ctrlSculpting._ctrlSculpt.setValue(t):this._sculptManager.setToolIndex(t),this._prevToolIndex=-1}this.updatePenControls(),this.updateFeatureList(),this._main.renderSelectOverRtt()}},{key:"onModeChange",value:function(e){this._tool._mode=0|e,this._main.render()}},{key:"onCloseLoop",value:function(e){this._tool.setCloseLoop(e)}},{key:"onSpacingChange",value:function(e){this._tool._spacing=e/1e3}},{key:"createNewSet",value:function(){this.onEnable(!0),this._tool.startNewFeature(),this.updateFeatureList()}},{key:"finishSet",value:function(){this._tool.finishActiveFeature(),this.updateFeatureList(),this._main.renderSelectOverRtt()}},{key:"updateFeatureList",value:function(){var e=this._tool.getFeatures(),t=this._tool.getSelectedFeatureIds();if(this._ctrlCloseLoop&&this._ctrlCloseLoop.setValue(this._tool._closeLoop,!0),e.length){this._featureListEmpty&&this._featureListEmpty.setVisibility(!1);for(var r=0,i=e.length;r<i;++r){var n=e[r],a=this._featureListCtrls[r];if(!a){a=this._menu.addButton("",(function(){})),this._featureListCtrls[r]=a;var s=a.domButton||a.domContainer;s&&s.addEventListener("mousedown",this.onFeatureItemClick.bind(this))}a.setVisibility(!0);var o=n.name+(n.closed?" ("+(0,V.Z)("penClosed")+")":""),l=a.domButton||a.domContainer;l&&(l.textContent=o,l.dataset.featureId=n.id,l.style.background=t.indexOf(n.id)>=0?"rgba(255, 200, 50, 0.2)":"")}for(var u=e.length;u<this._featureListCtrls.length;++u)this._featureListCtrls[u].setVisibility(!1)}else{this._featureListEmpty&&this._featureListEmpty.setVisibility(!0);for(var c=0;c<this._featureListCtrls.length;++c)this._featureListCtrls[c].setVisibility(!1)}}},{key:"onFeatureItemClick",value:function(e){var t=parseInt(e.currentTarget.dataset.featureId,10);if(t){var r=!!(e.shiftKey||e.ctrlKey||e.metaKey);this._tool.selectFeature(t,r),this.updateFeatureList()}}},{key:"updatePenControls",value:function(){var e=this._sculptManager.getToolIndex()===s.Z.Tools.PEN;this._ctrlMode.setVisibility(e),this._ctrlCloseLoop.setVisibility(e),this._ctrlSpacing.setVisibility(e),this._ctrlClear.setVisibility(e),this._ctrlNewSet.setVisibility(!0),this._ctrlFinishSet.setVisibility(e),this._ctrlEnable.getValue()!==e&&this._ctrlEnable.setValue(e,!0),this.updateFeatureList()}}])&&Ds(t.prototype,r),e}();function Fs(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Os=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=r._main,this._ctrlGui=r,this._sculptManager=r._main.getSculptManager(),this._menu=null,this._penTool=null,this._ctrlCreatePad=null,this._ctrlCreateTrim=null,this._ctrlPadHeight=null,this._ctrlTrimDepth=null,this._ctrlPadDirection=null,this._ctrlTrimDirection=null,this._ctrlSourceTitle=null,this._ctrlSolidTitle=null,this._sourceListCtrls=[],this._solidListCtrls=[],this._expandedSourceId=null,this._padHeight=5,this._trimDepth=5,this._padDirection=1,this._trimDirection=0,this.init(t)}var t,r;return t=e,(r=[{key:"init",value:function(e){this._penTool=this._sculptManager.getTool(s.Z.Tools.PEN);var t=this._menu=e.addMenu((0,V.Z)("padsTrimsTitle"));t.close(),this._ctrlSourceTitle=t.addTitle((0,V.Z)("padsTrimsSourceSets")),this._ctrlSolidTitle=t.addTitle((0,V.Z)("padsTrimsFeatureSets")),this._ctrlPadHeight=t.addSlider((0,V.Z)("padsTrimsPadHeight"),this._padHeight,this.onPadHeight.bind(this),0,50,.1),this._ctrlTrimDepth=t.addSlider((0,V.Z)("padsTrimsTrimDepth"),this._trimDepth,this.onTrimDepth.bind(this),0,50,.1);var r={};r[0]=(0,V.Z)("padsTrimsDirIn"),r[1]=(0,V.Z)("padsTrimsDirOut"),r[2]=(0,V.Z)("padsTrimsDirBoth"),this._ctrlPadDirection=t.addCombobox((0,V.Z)("padsTrimsPadDirection"),this._padDirection,this.onPadDirection.bind(this),r),this._ctrlTrimDirection=t.addCombobox((0,V.Z)("padsTrimsTrimDirection"),this._trimDirection,this.onTrimDirection.bind(this),r),this._ctrlPadHeight.setVisibility(!1),this._ctrlTrimDepth.setVisibility(!1),this._ctrlPadDirection.setVisibility(!1),this._ctrlTrimDirection.setVisibility(!1),this._penTool.setOnFeaturesChanged(this.updateLists.bind(this)),this.updateLists()}},{key:"updateMesh",value:function(){this._menu.setVisibility(!!this._main.getMesh()),this.updateLists()}},{key:"createPad",value:function(){this._createSolidFeature("Pad")}},{key:"createTrim",value:function(){this._createSolidFeature("Trim")}},{key:"_createSolidFeature",value:function(e){var t=this._penTool.getSelectedFeatureIds();t.length&&(this._penTool.createSolidFeature(e,t,{height:this._padHeight,depth:this._trimDepth,direction:"Pad"===e?this._padDirection:this._trimDirection}),this.updateLists())}},{key:"onPadHeight",value:function(e){this._padHeight=e}},{key:"onTrimDepth",value:function(e){this._trimDepth=e}},{key:"onPadDirection",value:function(e){this._padDirection=0|e}},{key:"onTrimDirection",value:function(e){this._trimDirection=0|e}},{key:"updateLists",value:function(){this._updateSourceList(),this._updateSolidFeatureList()}},{key:"_updateSourceList",value:function(){for(var e=this._penTool.getFeatures(),t=this._penTool.getSelectedFeatureIds(),r=this,i=3*e.length;this._sourceListCtrls.length<i;){var n=this._menu.addButton("",(function(){}));this._sourceListCtrls.push(n),this._moveCtrlAfterTitle(n,this._ctrlSourceTitle)}for(var a=0;a<e.length;++a){var s=e[a],o=3*a,l=this._sourceListCtrls[o],u=this._sourceListCtrls[o+1],c=this._sourceListCtrls[o+2],h=s.name+(s.closed?" ("+(0,V.Z)("penClosed")+")":""),d=l.domButton||l.domContainer;d&&(d.textContent=h,d.dataset.featureId=s.id,d.style.background=t.indexOf(s.id)>=0?"rgba(255, 200, 50, 0.2)":"",d.onclick=function(e){return function(t){var i=!!(t.shiftKey||t.ctrlKey||t.metaKey);r._penTool.selectFeature(e,i),r._expandedSourceId=r._expandedSourceId===e?null:e,r.updateLists()}}(s.id)),l.setVisibility(!0);var f=this._expandedSourceId===s.id,_=u.domButton||u.domContainer;_&&(_.textContent=" + "+(0,V.Z)("padsTrimsCreatePad"),_.dataset.featureId=s.id,_.onclick=function(e){return function(){r._penTool.selectFeature(e,!1),r._penTool.createSolidFeature("Pad",[e],{height:r._padHeight,depth:r._trimDepth,direction:r._padDirection}),r.updateLists()}}(s.id)),u.setVisibility(f);var p=c.domButton||c.domContainer;p&&(p.textContent=" + "+(0,V.Z)("padsTrimsCreateTrim"),p.dataset.featureId=s.id,p.onclick=function(e){return function(){r._penTool.selectFeature(e,!1),r._penTool.createSolidFeature("Trim",[e],{height:r._padHeight,depth:r._trimDepth,direction:r._trimDirection}),r.updateLists()}}(s.id)),c.setVisibility(f)}for(var g=3*e.length;g<this._sourceListCtrls.length;++g)this._sourceListCtrls[g].setVisibility(!1)}},{key:"_updateSolidFeatureList",value:function(){for(var e=this._penTool.getSolidFeatures();this._solidListCtrls.length<e.length;){var t=this._menu.addButton("",(function(){}));this._solidListCtrls.push(t),this._moveCtrlAfterTitle(t,this._ctrlSolidTitle)}for(var r=0;r<e.length;++r){var i=e[r],n=(t=this._solidListCtrls[r],"Pad"===i.type?(0,V.Z)("padsTrimsPadLabel"):(0,V.Z)("padsTrimsTrimLabel")),a=i.name+" - "+n+" "+(0,V.Z)("padsTrimsFrom")+" "+i.sourceIds.join(","),s=t.domButton||t.domContainer;s&&(s.textContent=a),t.setVisibility(!0)}for(var o=e.length;o<this._solidListCtrls.length;++o)this._solidListCtrls[o].setVisibility(!1)}},{key:"_moveCtrlAfterTitle",value:function(e,t){if(e&&e.domContainer&&t&&t.domContainer){var r=this._menu.domContainer;if(r){var i=t.domContainer,n=e.domContainer,a=i.nextSibling;a&&a!==n&&r.insertBefore(n,a)}}}},{key:"_directionLabel",value:function(e){return 0===e?(0,V.Z)("padsTrimsDirIn"):2===e?(0,V.Z)("padsTrimsDirBoth"):(0,V.Z)("padsTrimsDirOut")}},{key:"_debugLog",value:function(e,t){"undefined"!=typeof window&&void 0===window.DEBUG_PADS_TRIMS&&(window.DEBUG_PADS_TRIMS=!0),"undefined"!=typeof console&&console.log("[PadsTrims]",e,t)}}])&&Fs(t.prototype,r),e}();function Ls(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Vs=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=t,this._guiMain=null,this._sidebar=null,this._topbar=null,this._ctrlTablet=null,this._ctrlFiles=null,this._ctrlScene=null,this._ctrlStates=null,this._ctrlCamera=null,this._ctrlBackground=null,this._ctrlSculpting=null,this._ctrlTopology=null,this._ctrlRendering=null,this._ctrlPen=null,this._ctrlPadsTrims=null,this._ctrlComparisonImage=null,this._ctrlNotification=null,this._ctrls=[],this._notifications={},this._xhrs={}}var t,r;return t=e,(r=[{key:"initGui",value:function(){this.deleteGui(),this._guiMain=new(un().GuiMain)(this._main.getViewport(),this._main.onCanvasResize.bind(this._main));var e=this._ctrls;e.length=0;var t=0;this._topbar=this._guiMain.addTopbar(),this.addLogo(),e[t++]=this._ctrlFiles=new zn(this._topbar,this),e[t++]=this._ctrlScene=new Ja(this._topbar,this),e[t++]=this._ctrlStates=new Cs(this._topbar,this),e[t++]=this._ctrlBackground=new hn(this._topbar,this),e[t++]=this._ctrlCamera=new fn(this._topbar,this),e[t++]=this._ctrlTablet=new Rs(this._topbar,this),e[t++]=this._ctrlConfig=new pn(this._topbar,this),e[t++]=this._ctrlMesh=new Kn(this._topbar,this),this._sidebar=this._guiMain.addRightSidebar(),e[t++]=this._ctrlRendering=new Ya(this._sidebar,this),e[t++]=this._ctrlTopology=new Wa(this._sidebar,this),e[t++]=this._ctrlSculpting=new ds(this._sidebar,this),e[t++]=this._ctrlPen=new Is(this._sidebar,this),e[t++]=this._ctrlPadsTrims=new Os(this._sidebar,this),e[t++]=this._ctrlComparisonImage=new Ps(this._sidebar,this);var r=this._topbar.addExtra();r.addTitle((0,V.Z)("contour")),r.addColor((0,V.Z)("contourColor"),ne.color,this.onContourColor.bind(this)),r.addTitle((0,V.Z)("resolution")),r.addSlider("",this._main._pixelRatio,this.onPixelRatio.bind(this),.5,2,.02),r.domContainer&&(r.domContainer.style.display="none"),this.addAboutButton(),this.updateMesh(),this.setVisibility(!0),window.postprocessGui&&window.postprocessGui()}},{key:"getNotification",value:function(e){var t=this._notifications[e];return t?this._xhrs[e]&&t.isVisible()?void(window.confirm("Abort "+e+" previous upload?")&&(this._xhrs[e].abort(),this._xhrs[e].isAborted=!0,t.setMessage(null))):t:((t=this._topbar.addMenu()).isVisible=function(){return!this.domContainer.hidden},t.setMessage=function(e){this.domContainer.innerHTML=e,this.setVisibility(!!e)},t.domContainer.style.color="red",t.setMessage(""),this._notifications[e]=t,t)}},{key:"initPrint",value:function(e){e.addMenu("Print it!").addButton("Go to Materialise!",this,"exportMaterialise")}},{key:"exportSculpteo",value:function(){this._export("sculpteo")}},{key:"exportMaterialise",value:function(){window.confirm("A new webpage will be opened. Start upload?")&&this._export("materialise")}},{key:"exportSketchfab",value:function(){this._export("sketchfab")}},{key:"_export",value:function(e){if(this._main.getMesh()){var t=this.getNotification(e);if(t){var r="export"+e.charAt(0).toUpperCase()+e.slice(1);this._xhrs[e]=Vn[r](this._main,t)}}}},{key:"onPixelRatio",value:function(e){this._main._pixelRatio=e,this._main.onCanvasResize()}},{key:"onContourColor",value:function(e){ne.color[0]=e[0],ne.color[1]=e[1],ne.color[2]=e[2],ne.color[3]=e[3],this._main.render()}},{key:"addAboutButton",value:function(){var e=this._topbar.addMenu();e.domContainer.innerHTML=(0,V.Z)("about"),e.domContainer.addEventListener("mousedown",(function(){window.open("http://stephaneginier.com","_blank")})),e.domContainer.style.display="none"}},{key:"addLogo",value:function(){if(this._topbar&&this._topbar.domUl){var e=document.createElement("li");e.className="gui-logo";var t=document.createElement("img");t.src="resources/logo.png",t.alt="Logo",t.draggable=!1,e.appendChild(t),this._topbar.domUl.insertBefore(e,this._topbar.domUl.firstChild)}}},{key:"updateMesh",value:function(){this._ctrlRendering.updateMesh(),this._ctrlTopology.updateMesh(),this._ctrlSculpting.updateMesh(),this._ctrlPen.updateMesh(),this._ctrlPadsTrims.updateMesh(),this._ctrlScene.updateMesh(),this.updateMeshInfo()}},{key:"updateMeshInfo",value:function(){this._ctrlMesh.updateMeshInfo()}},{key:"getFlatShading",value:function(){return this._ctrlRendering.getFlatShading()}},{key:"getWireframe",value:function(){return this._ctrlRendering.getWireframe()}},{key:"getShaderType",value:function(){return this._ctrlRendering.getShaderType()}},{key:"addAlphaOptions",value:function(e){this._ctrlSculpting.addAlphaOptions(e)}},{key:"deleteGui",value:function(){this._guiMain&&this._guiMain.domMain.parentNode&&(this.callFunc("removeEvents"),this.setVisibility(!1),this._guiMain.domMain.parentNode.removeChild(this._guiMain.domMain))}},{key:"setVisibility",value:function(e){this._guiMain.setVisibility(e)}},{key:"callFunc",value:function(e,t){for(var r=0,i=this._ctrls,n=i.length;r<n;++r){var a=i[r];a&&a[e]&&a[e](t)}}}])&&Ls(t.prototype,r),e}();function Ns(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Bs=200,Us=200,Zs=[0,0],Gs=[0,0,0],Ws=[0,0,0],js=[0,1,0],zs=[0,0,0,1],Xs=l.Ue(),Ks=Math.SQRT1_2,Hs=.5,Ys=[Qe(1,0,0,0),Qe(0,1,0,0),Qe(0,0,1,0),Qe(0,0,0,1),Qe(Ks,Ks,0,0),Qe(Ks,-Ks,0,0),Qe(Ks,0,Ks,0),Qe(Ks,0,-Ks,0),Qe(Ks,0,0,Ks),Qe(Ks,0,0,-Ks),Qe(0,Ks,Ks,0),Qe(0,Ks,-Ks,0),Qe(0,Ks,0,Ks),Qe(0,Ks,0,-Ks),Qe(0,0,Ks,Ks),Qe(0,0,Ks,-Ks),Qe(Hs,Hs,Hs,Hs),Qe(Hs,Hs,Hs,-Hs),Qe(Hs,Hs,-Hs,Hs),Qe(Hs,Hs,-Hs,-Hs),Qe(Hs,-Hs,Hs,Hs),Qe(Hs,-Hs,Hs,-Hs),Qe(Hs,-Hs,-Hs,Hs),Qe(-Hs,Hs,Hs,Hs)];const qs=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=t;var r=(0,u.Z)();this._mode=r.cameramode||s.Z.CameraMode.ORBIT,this._projectionType=r.projection||s.Z.Projection.PERSPECTIVE,this._quatRot=[0,0,0,1],this._view=l.Ue(),this._proj=l.Ue(),this._viewport=l.Ue(),this._lastNormalizedMouseXY=[0,0],this._width=0,this._height=0,this._speed=0,this._fov=Math.min(r.fov,150),this._trans=[0,0,30],this._moveX=0,this._moveZ=0,this._usePivot=r.pivot,this._center=[0,0,0],this._offset=[0,0,0],this._rotX=0,this._rotY=0,this._near=.05,this._far=5e3,this._timers={},this.resetView()}var t,r;return t=e,(r=[{key:"setProjectionType",value:function(e){this._projectionType=e,this.updateProjection(),this.updateView()}},{key:"setMode",value:function(e){this._mode=e,e===s.Z.CameraMode.ORBIT&&this.resetViewFront()}},{key:"setFov",value:function(e){this._fov=e,this.updateView(),this.optimizeNearFar()}},{key:"setUsePivot",value:function(e){this._usePivot=e}},{key:"toggleUsePivot",value:function(){this._usePivot=!this._usePivot}},{key:"getView",value:function(){return this._view}},{key:"getProjection",value:function(){return this._proj}},{key:"getProjectionType",value:function(){return this._projectionType}},{key:"isOrthographic",value:function(){return this._projectionType===s.Z.Projection.ORTHOGRAPHIC}},{key:"getMode",value:function(){return this._mode}},{key:"getFov",value:function(){return this._fov}},{key:"getUsePivot",value:function(){return this._usePivot}},{key:"getConstantScreen",value:function(){var e=this._main.getCanvas().clientWidth;return this._projectionType===s.Z.Projection.ORTHOGRAPHIC?e/this.getOrthoZoom():e*this._proj[0]}},{key:"start",value:function(e,t){if(this._lastNormalizedMouseXY=tt.Z.normalizedMouse(e,t,this._width,this._height),this._usePivot){var r=this._main,n=r.getPicking();n.intersectionMouseMeshes(r.getMeshes(),e,t),n.getMesh()&&(i.fF(Gs,n.getIntersectionPoint(),n.getMesh().getMatrix()),this.setPivot(Gs))}}},{key:"setPivot",value:function(e){if(i.VC(this._offset,this._offset,function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=r*r+i*i+n*n+a*a,o=s?1/s:0;return e[0]=-r*o,e[1]=-i*o,e[2]=-n*o,e[3]=a*o,e}(zs,this._quatRot)),i.lu(this._offset,this._offset,this._center),i.JG(this._center,e),i.IH(this._offset,this._offset,this._center),i.VC(this._offset,this._offset,this._quatRot),this._projectionType===s.Z.Projection.PERSPECTIVE){var t=this.getTransZ();this._trans[2]=i.TK(this.computePosition(),this._center)*this._fov/45,this._offset[2]+=this.getTransZ()-t}else this._offset[2]=0}},{key:"rotate",value:function(e,t){var r=Gs,n=Zs,a=tt.Z.normalizedMouse(e,t,this._width,this._height);if(this._mode===s.Z.CameraMode.ORBIT)ze(n,a,this._lastNormalizedMouseXY),this.setOrbit(this._rotX-2*n[1],this._rotY+2*n[0]),this.rotateDelay([6*-n[1],6*n[0]],-1);else if(this._mode===s.Z.CameraMode.PLANE){var o=Xe(this._lastNormalizedMouseXY,a);ze(n,a,this._lastNormalizedMouseXY),i.Fv(r,i.t8(r,-n[1],n[0],0)),$e(this._quatRot,Ye(zs,r,2*o),this._quatRot),this.rotateDelay([r[0],r[1],r[2],6*o],-1)}else if(this._mode===s.Z.CameraMode.SPHERICAL){var l=tt.Z.mouseOnUnitSphere(this._lastNormalizedMouseXY),u=tt.Z.mouseOnUnitSphere(a),c=Math.acos(Math.min(1,i.AK(l,u)));i.Fv(r,i.kC(r,l,u)),$e(this._quatRot,Ye(zs,r,2*c),this._quatRot),this.rotateDelay([r[0],r[1],r[2],6*c],-1)}this._lastNormalizedMouseXY=a,this.updateView()}},{key:"setOrbit",value:function(e,t){var r=.49*Math.PI;this._rotX=Math.max(Math.min(e,r),-r),this._rotY=t;var i=this._quatRot;He(i),qe(i,i,this._rotX),Je(i,i,this._rotY)}},{key:"getTransZ",value:function(){return this._projectionType===s.Z.Projection.PERSPECTIVE?45*this._trans[2]/this._fov:1e3}},{key:"updateView",value:function(){var e=Gs,t=this._view,r=this._trans[0],n=this._trans[1],a=this._offset;i.t8(Ws,r-a[0],n-a[1],this.getTransZ()-a[2]),i.t8(e,r-a[0],n-a[1],-a[2]),l.zB(t,Ws,e,js),l.dC(t,t,l.en(Xs,this._quatRot)),l.Iu(t,t,i.tk(Gs,this._center))}},{key:"optimizeNearFar",value:function(e){if(e||(e=this._lastBBox),e){this._lastBBox=e;var t=this.computePosition(Ws),r=i.t8(Gs,.5*(e[0]+e[3]),.5*(e[1]+e[4]),.5*(e[2]+e[5])),n=i.TK(t,r),a=.5*i.TK(e,i.t8(Gs,e[3],e[4],e[5]));this._near=Math.max(.01,n-a),this._far=a+n,this.updateProjection()}}},{key:"updateProjection",value:function(){this._projectionType===s.Z.Projection.PERSPECTIVE?(l.G3(this._proj,this._fov*Math.PI/180,this._width/this._height,this._near,this._far),this._proj[10]=-1,this._proj[14]=-2*this._near):this.updateOrtho()}},{key:"updateTranslation",value:function(){var e=this._trans;e[0]+=this._moveX*this._speed*e[2]/50/400,e[2]=Math.max(1e-5,e[2]+this._moveZ*this._speed/400),this._projectionType===s.Z.Projection.ORTHOGRAPHIC&&this.updateOrtho(),this.updateView()}},{key:"translate",value:function(e,t){var r=this._speed*this._trans[2]/54,n=[-e*r,t*r,0];this.setTrans(i.IH(this._trans,this._trans,n)),i.bA(n,n,5),this.translateDelay(n,-1)}},{key:"zoom",value:function(e){var t=[0,0,0];i.lu(t,this._offset,this._trans),i.bA(t,t,e*this._speed/54),e<0&&(t[0]=t[1]=0),this.setTrans(i.IH(this._trans,this._trans,t)),i.bA(t,t,5),this.translateDelay(t,-1)}},{key:"setAndFocusOnPivot",value:function(e,t){this.setPivot(e),this.moveToDelay(this._offset[0],this._offset[1],this._offset[2]+t)}},{key:"moveToDelay",value:function(e,t,r){var n=[e,t,r];this.translateDelay(i.lu(n,n,this._trans),Us)}},{key:"setTrans",value:function(e){i.JG(this._trans,e),this._projectionType===s.Z.Projection.ORTHOGRAPHIC&&this.updateOrtho(),this.updateView()}},{key:"getOrthoZoom",value:function(){return 55e-5*Math.abs(this._trans[2])}},{key:"updateOrtho",value:function(){var e=this.getOrthoZoom(),t=this._width*e,r=this._height*e;l.M5(this._proj,-t,t,-r,r,-this._near,this._far)}},{key:"computePosition",value:function(e){e=e||[0,0,0];var t=this._view;return i.t8(e,-t[12],-t[13],-t[14]),d(Xs,t),f(Xs,Xs),i.kK(e,e,Xs)}},{key:"resetView",value:function(){this._speed=1.5*o.Z.SCALE,this.centerDelay([0,0,0],Us),this.offsetDelay([0,0,0],Us);var e=[0,0,30+this._speed/3];i.lu(e,e,this._trans),this.translateDelay(e,Us),this.quatDelay([0,0,0,1],Us)}},{key:"resetViewFront",value:function(){this.quatDelay([0,0,0,1],Bs)}},{key:"resetViewBack",value:function(){this.quatDelay([0,1,0,0],Bs)}},{key:"resetViewTop",value:function(){this.quatDelay([Math.SQRT1_2,0,0,Math.SQRT1_2],Bs)}},{key:"resetViewBottom",value:function(){this.quatDelay([-Math.SQRT1_2,0,0,Math.SQRT1_2],Bs)}},{key:"resetViewLeft",value:function(){this.quatDelay([0,-Math.SQRT1_2,0,Math.SQRT1_2],Bs)}},{key:"resetViewRight",value:function(){this.quatDelay([0,Math.SQRT1_2,0,Math.SQRT1_2],Bs)}},{key:"toggleViewFront",value:function(){Math.abs(this._quatRot[3])>.99?this.resetViewBack():this.resetViewFront()}},{key:"toggleViewTop",value:function(){var e=this._quatRot[0]*Math.SQRT1_2+this._quatRot[3]*Math.SQRT1_2;e*e>.99?this.resetViewBottom():this.resetViewTop()}},{key:"toggleViewLeft",value:function(){var e=-this._quatRot[1]*Math.SQRT1_2+this._quatRot[3]*Math.SQRT1_2;e*e>.99?this.resetViewRight():this.resetViewLeft()}},{key:"computeWorldToScreenMatrix",value:function(e){return e=e||l.Ue(),l.dC(e,l.dC(e,this._viewport,this._proj),this._view)}},{key:"unproject",value:function(e,t,r){var n=[0,0,0];return l.U_(Xs,this.computeWorldToScreenMatrix(Xs)),i.fF(n,i.t8(n,e,this._height-t,r),Xs)}},{key:"project",value:function(e){var t=[0,0,0];return i.fF(t,e,this.computeWorldToScreenMatrix(Xs)),t[1]=this._height-t[1],t}},{key:"onResize",value:function(e,t){this._width=e,this._height=t;var r=this._viewport;l.yR(r),l.bA(r,r,i.t8(Gs,.5*e,.5*t,.5)),l.Iu(r,r,i.t8(Gs,1,1,1)),this.updateProjection()}},{key:"snapClosestRotation",value:function(){for(var e=this._quatRot,t=1/0,r=0,i=Ys.length,n=0;n<i;++n){var a=(o=Ys[n],(s=e)[0]*o[0]+s[1]*o[1]+s[2]*o[2]+s[3]*o[3]);t<(a=1-a*a)||(t=a,r=n)}var s,o;this.quatDelay(Ys[r],Bs)}},{key:"clearTimerN",value:function(e){window.clearInterval(this._timers[e]),this._timers[e]=0}},{key:"delay",value:function(e,t,r){var i=r||"default";if(this._timers[i]&&this.clearTimerN(i),0===t)return e(1);if(!(t<0)){var n=0,a=(new Date).getTime();this._timers[i]=window.setInterval(function(){var r=((new Date).getTime()-a)/t;r=function(e){return-((e=Math.min(1,e)-1)*e*e*e-1)}(r),e(r-n,r),n=r,r>=1&&this.clearTimerN(i)}.bind(this),16.6)}}},{key:"_translateDelta",value:function(e,t){var r=this._trans;i.od(r,r,e,t),this.setTrans(r),this._main.render()}},{key:"translateDelay",value:function(e,t){var r=this._translateDelta.bind(this,e);this.delay(r,t,"translate")}},{key:"_rotDelta",value:function(e,t){if(this._mode===s.Z.CameraMode.ORBIT){var r=this._rotX+e[0]*t,i=this._rotY+e[1]*t;this.setOrbit(r,i)}else $e(this._quatRot,Ye(zs,e,e[3]*t),this._quatRot);this.updateView(),this._main.render()}},{key:"rotateDelay",value:function(e,t){var r=this._rotDelta.bind(this,e);this.delay(r,t,"rotate")}},{key:"_quatDelta",value:function(e,t){He(zs),function(e,t,r,i){var n,a,s,o,l,u=t[0],h=t[1],d=t[2],f=t[3],_=r[0],p=r[1],g=r[2],m=r[3];(a=u*_+h*p+d*g+f*m)<0&&(a=-a,_=-_,p=-p,g=-g,m=-m),1-a>c.Ib?(n=Math.acos(a),s=Math.sin(n),o=Math.sin((1-i)*n)/s,l=Math.sin(i*n)/s):(o=1-i,l=i),e[0]=o*u+l*_,e[1]=o*h+l*p,e[2]=o*d+l*g,e[3]=o*f+l*m}(zs,zs,e,t);var r=this._quatRot;if($e(this._quatRot,this._quatRot,zs),this._mode===s.Z.CameraMode.ORBIT){var i=r[0],n=r[1],a=r[2],o=r[3];this._rotY=Math.atan2(2*(o*n+a*i),1-2*(n*n+a*a)),this._rotX=Math.atan2(2*(o*i+n*a),1-2*(a*a+i*i))}this.updateView(),this._main.render()}},{key:"quatDelay",value:function(e,t){var r=[0,0,0,0];!function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(r,this._quatRot),$e(r,r,e),et(r,r);var i=this._quatDelta.bind(this,r);this.delay(i,t,"quat")}},{key:"_centerDelta",value:function(e,t){i.od(this._center,this._center,e,t),this.updateView(),this._main.render()}},{key:"centerDelay",value:function(e,t){var r=[0,0,0];i.lu(r,e,this._center);var n=this._centerDelta.bind(this,r);this.delay(n,t,"center")}},{key:"_offsetDelta",value:function(e,t){i.od(this._offset,this._offset,e,t),this.updateView(),this._main.render()}},{key:"offsetDelay",value:function(e,t){var r=[0,0,0];i.lu(r,e,this._offset);var n=this._offsetDelta.bind(this,r);this.delay(n,t,"offset")}},{key:"computeFrustumFit",value:function(){var e,t=this._near;if(this._projectionType===s.Z.Projection.ORTHOGRAPHIC)return e=Math.min(this._width,this._height)/t*.5,Math.sqrt(1+e*e)/e;var r=this._proj,i=t*(r[8]-1)/r[0],n=t*(1+r[8])/r[0],a=t*(1+r[9])/r[5],o=t*(r[9]-1)/r[5],l=Math.abs(n-i),u=Math.abs(a-o);return e=Math.min(u,l)/t*.5,this._fov/45*Math.sqrt(1+e*e)/e}}])&&Ns(t.prototype,r),e}();function Js(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}const Qs=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._main=r,this._gl=t,this._vertexBuffer=new g(t,t.ARRAY_BUFFER,t.STATIC_DRAW),this._texCoordBuffer=new g(t,t.ARRAY_BUFFER,t.STATIC_DRAW),this._fill=!0,this._monoTex=null,this._texture=null,this._texWidth=1,this._texHeight=1,this._type=0,this._blur=0,this.init()}var t,r;return t=e,(r=[{key:"init",value:function(){this.getTexCoordBuffer().update(new Float32Array([0,0,1,0,0,1,1,1])),this._monoTex=this.createOnePixelTexture(173,216,230,255),document.getElementById("backgroundopen").addEventListener("change",this.loadBackground.bind(this),!1)}},{key:"loadBackground",value:function(e){if(0!==e.target.files.length){var t=e.target.files[0];if(t.type.match("image.*")){var r=this,i=new FileReader;i.onload=function(e){var t=new Image;t.src=e.target.result,t.onload=function(){var e=r._main.getCanvas();r.loadBackgroundTexture(t),r.onResize(e.width,e.height),r._main.render()}},document.getElementById("backgroundopen").value="",i.readAsDataURL(t)}}}},{key:"getGL",value:function(){return this._gl}},{key:"getBlur",value:function(){return this._blur}},{key:"getVertexBuffer",value:function(){return this._vertexBuffer}},{key:"getTexCoordBuffer",value:function(){return this._texCoordBuffer}},{key:"release",value:function(){this.deleteTexture(),this.getVertexBuffer().release(),this.getTexCoordBuffer().release()}},{key:"getType",value:function(){return this._type}},{key:"setType",value:function(e){this._type=e}},{key:"onResize",value:function(e,t){var r=e/t/(this._texWidth/this._texHeight),i=this._fill||0!==this._type?1/r:r,n=i<1?1:1/r,a=i<1?r:1;this.getVertexBuffer().update(new Float32Array([-n,-a,n,-a,-n,a,n,a]))}},{key:"getTexture",value:function(){return this._texture?this._texture:this._monoTex}},{key:"createOnePixelTexture",value:function(e,t,r,i){var n=this._gl,a=n.createTexture();return n.bindTexture(n.TEXTURE_2D,a),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,new Uint8Array([e,t,r,i])),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.bindTexture(n.TEXTURE_2D,null),a}},{key:"loadBackgroundTexture",value:function(e){var t=this._gl;this.deleteTexture(),this._texWidth=e.width,this._texHeight=e.height,this._texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this._texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindTexture(t.TEXTURE_2D,null)}},{key:"deleteTexture",value:function(){this._texture&&(this._texWidth=this._texHeight=1,this._gl.deleteTexture(this._texture),this._texture=null)}},{key:"render",value:function(){de[s.Z.Shader.BACKGROUND].getOrCreate(this._gl).draw(this)}}])&&Js(t.prototype,r),e}();function $s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var eo=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._gl=t,this._main=r,this._texture=null,this._transformData=$t(),this._vertexBuffer=new g(t,t.ARRAY_BUFFER,t.STATIC_DRAW),this._texCoordBuffer=new g(t,t.ARRAY_BUFFER,t.STATIC_DRAW),this._indexBuffer=new g(t,t.ELEMENT_ARRAY_BUFFER,t.STATIC_DRAW),this._borderIndexBuffer=new g(t,t.ELEMENT_ARRAY_BUFFER,t.STATIC_DRAW),this.initBorderGeometry(),this._width=1,this._height=1,this._aspectRatio=1,this._opacity=.8,this._useDepth=!1,this._depthOffset=.01,this._isSelected=!1,this._id=e.ID++,this.initGeometry()}var t,r;return t=e,(r=[{key:"initGeometry",value:function(){var e=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),t=new Float32Array([0,0,1,0,0,1,1,1]),r=new Uint32Array([0,1,2,1,3,2]);this._vertexBuffer.update(e),this._texCoordBuffer.update(t),this._indexBuffer.update(r)}},{key:"initBorderGeometry",value:function(){var e=new Uint32Array([0,1,1,3,3,2,2,0]);this._borderIndexBuffer.update(e)}},{key:"loadImage",value:function(e){if(console.log("[ComparisonImage] loadImage called for file:",e?e.name:"null"),e){var t=this,r=new FileReader;r.onload=function(e){console.log("[ComparisonImage] FileReader loaded, creating Image object...");var r=new Image;r.src=e.target.result,r.onload=function(){console.log("[ComparisonImage] Image loaded, dimensions:",r.width,"x",r.height);var e=2048,i=document.createElement("canvas"),n=i.getContext("2d"),a=r.width,s=r.height;if(console.log("[ComparisonImage] Processing image, original size:",a,"x",s),a>e||s>e){var o=Math.min(e/a,e/s);a=Math.floor(a*o),s=Math.floor(s*o),console.log("[ComparisonImage] Resizing image to:",a,"x",s,"(scale:",o,")"),i.width=a,i.height=s,n.drawImage(r,0,0,a,s),t._aspectRatio=a/s,console.log("[ComparisonImage] Aspect ratio:",t._aspectRatio),t._createTexture(i)}else t._aspectRatio=r.width/r.height,console.log("[ComparisonImage] Using original size, aspect ratio:",t._aspectRatio),t._createTexture(r);t._width>0&&(t._height=t._width/t._aspectRatio,console.log("[ComparisonImage] Updating matrix with size:",t._width,"x",t._height),t._updateMatrix()),console.log("[ComparisonImage] Image loaded successfully, triggering render"),t._main.render()},r.onerror=function(){console.error("[ComparisonImage] Image.onerror: Failed to load image"),alert("Failed to load image. Please try a different file.")}},r.onerror=function(){console.error("[ComparisonImage] FileReader.onerror: Failed to read file"),alert("Failed to read file. Please try again.")},console.log("[ComparisonImage] Starting FileReader.readAsDataURL..."),r.readAsDataURL(e)}else console.error("[ComparisonImage] No image file provided")}},{key:"_createTexture",value:function(e){console.log("[ComparisonImage] _createTexture called, image type:",e instanceof HTMLCanvasElement?"Canvas":"Image");var t=this._gl;if(t)if(this.deleteTexture(),console.log("[ComparisonImage] Creating WebGL texture..."),this._texture=t.createTexture(),this._texture){t.bindTexture(t.TEXTURE_2D,this._texture);try{e instanceof HTMLCanvasElement?(console.log("[ComparisonImage] Loading texture from canvas, size:",e.width,"x",e.height),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e)):(console.log("[ComparisonImage] Loading texture from image, size:",e.width,"x",e.height),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindTexture(t.TEXTURE_2D,null);var r=t.getError();r!==t.NO_ERROR?console.error("[ComparisonImage] WebGL error after texture creation:",r):console.log("[ComparisonImage] Texture created successfully")}catch(e){console.error("[ComparisonImage] Error creating texture:",e),t.bindTexture(t.TEXTURE_2D,null)}}else console.error("[ComparisonImage] Failed to create WebGL texture");else console.error("[ComparisonImage] No WebGL context for texture creation")}},{key:"updateMatrices",value:function(e){if(e){var t=this._transformData._matrix,r=this._transformData._center;t&&16===t.length||(console.warn("[ComparisonImage] updateMatrices: Invalid transform matrix, initializing..."),this._updateMatrix()),l.dC(this._transformData._lastComputedMV,e.getView(),t),l.dC(this._transformData._lastComputedMVP,e.getProjection(),this._transformData._lastComputedMV);var i=this._transformData._lastComputedMVP;this._transformData._lastComputedDepth=i[2]*r[0]+i[6]*r[1]+i[10]*r[2]+i[14],console.log("[ComparisonImage] updateMatrices: Matrices updated, depth:",this._transformData._lastComputedDepth)}else console.warn("[ComparisonImage] updateMatrices: No camera provided")}},{key:"setPosition",value:function(e,t,r){i.t8(this._transformData._center,e,t,r),this._updateMatrix()}},{key:"getPosition",value:function(){return this._transformData._center.slice()}},{key:"setSize",value:function(e,t){this._width=Math.max(.1,e),this._height=t||this._width/this._aspectRatio,this._updateMatrix()}},{key:"setSizeMaintainAspect",value:function(e,t,r){if(r){var i,n=e/this._width,a=t/this._height;i=Math.abs(n-1)>Math.abs(a-1)?n:Math.abs(a-1)>Math.abs(n-1)?a:n,this._width=Math.max(.1,this._width*i),this._height=Math.max(.1,this._width/this._aspectRatio)}else this._width=Math.max(.1,e),this._height=Math.max(.1,t||this._width/this._aspectRatio);this._updateMatrix()}},{key:"getSize",value:function(){return{width:this._width,height:this._height}}},{key:"getAspectRatio",value:function(){return this._aspectRatio}},{key:"_updateMatrix",value:function(){var e=this._transformData._matrix,t=this._transformData._center;if(e&&t){var r=[t[0],t[1],t[2]];l.yR(e),l.Iu(e,e,r),l.bA(e,e,[this._width,this._height,1])}else console.error("ComparisonImage: Transform data not initialized")}},{key:"getDepth",value:function(){return this._transformData._lastComputedDepth}},{key:"getID",value:function(){return this._id}},{key:"getMatrix",value:function(){return this._transformData._matrix}},{key:"getCenter",value:function(){return this._transformData._center}},{key:"intersectRay",value:function(e,t){var r=l.Ue();l.U_(r,this._transformData._matrix);var n=i.Ue(),a=i.Ue();i.fF(n,e,r),i.fF(a,t,r);var s=i.Ue();if(i.lu(s,a,n),Math.abs(s[2])<1e-6)return null;var o=-n[2]/s[2];if(o<0||o>1)return null;var u=i.Ue();if(i.od(u,n,s,o),Math.abs(u[0])<=.5&&Math.abs(u[1])<=.5){var c=i.Ue();return i.fF(c,u,this._transformData._matrix),c}return null}},{key:"setOpacity",value:function(e){this._opacity=Math.max(0,Math.min(1,e))}},{key:"getOpacity",value:function(){return this._opacity}},{key:"setUseDepth",value:function(e){this._useDepth=e}},{key:"getUseDepth",value:function(){return this._useDepth}},{key:"isSelected",value:function(){return this._isSelected}},{key:"setSelected",value:function(e){this._isSelected=e}},{key:"render",value:function(){if(this._texture){if(!this._transformData._lastComputedMVP||16!==this._transformData._lastComputedMVP.length){if(console.warn("[ComparisonImage] render: Matrices not initialized, attempting to update..."),!this._main||!this._main.getCamera)return void console.warn("[ComparisonImage] render: No main or getCamera, skipping render");var e=this._main.getCamera();if(!e)return void console.warn("[ComparisonImage] render: No camera available, skipping render");if(this.updateMatrices(e),!this._transformData._lastComputedMVP||16!==this._transformData._lastComputedMVP.length)return void console.warn("[ComparisonImage] render: Still no valid matrices after update, skipping render")}var t=this._gl;if(t){var r=de[s.Z.Shader.COMPARISON_IMAGE];if(r)try{var i=r.getOrCreate(t);if(!i||!i.program)return void console.error("[ComparisonImage] render: Shader program not available");var n=t.getError();n!==t.NO_ERROR&&console.warn("[ComparisonImage] render: WebGL error before render:",n);var a=t.isEnabled(t.DEPTH_TEST),o=t.isEnabled(t.BLEND),l=t.getParameter(t.DEPTH_FUNC),u=t.getParameter(t.BLEND_SRC_ALPHA),c=t.getParameter(t.BLEND_DST_ALPHA);t.useProgram(i.program),this._useDepth?(t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL)):t.disable(t.DEPTH_TEST),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this._texture),i.uniforms&&void 0!==i.uniforms.uTexture&&t.uniform1i(i.uniforms.uTexture,0),i.uniforms&&void 0!==i.uniforms.uMVP&&t.uniformMatrix4fv(i.uniforms.uMVP,!1,this._transformData._lastComputedMVP),i.uniforms&&void 0!==i.uniforms.uOpacity&&t.uniform1f(i.uniforms.uOpacity,this._opacity),i.uniforms&&void 0!==i.uniforms.uIsBorder&&t.uniform1i(i.uniforms.uIsBorder,0),i.attributes&&i.attributes.aPosition&&i.attributes.aPosition.bindToBuffer(this._vertexBuffer),i.attributes&&i.attributes.aTexCoord&&i.attributes.aTexCoord.bindToBuffer(this._texCoordBuffer),this._indexBuffer.bind(),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_INT,0),this._isSelected&&this.renderBorder(t,i),i.attributes&&i.attributes.aPosition&&i.attributes.aPosition.unbind(),i.attributes&&i.attributes.aTexCoord&&i.attributes.aTexCoord.unbind(),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),o?t.enable(t.BLEND):t.disable(t.BLEND),t.blendFunc(u,c),a?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),t.depthFunc(l),(n=t.getError())!==t.NO_ERROR&&console.error("ComparisonImage: WebGL error after render:",n)}catch(e){console.error("ComparisonImage: Error during render:",e)}else console.error("[ComparisonImage] render: Shader not found in ShaderLib")}else console.error("[ComparisonImage] render: No WebGL context")}}},{key:"deleteTexture",value:function(){this._texture&&(this._gl.deleteTexture(this._texture),this._texture=null)}},{key:"renderBorder",value:function(e,t){var r=e.isEnabled(e.DEPTH_TEST),i=e.isEnabled(e.BLEND);e.disable(e.DEPTH_TEST),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.lineWidth(3),t.uniforms&&void 0!==t.uniforms.uBorderColor&&e.uniform3f(t.uniforms.uBorderColor,1,1,0),t.uniforms&&void 0!==t.uniforms.uIsBorder&&e.uniform1i(t.uniforms.uIsBorder,1),t.uniforms&&void 0!==t.uniforms.uOpacity&&e.uniform1f(t.uniforms.uOpacity,1),t.attributes&&t.attributes.aPosition&&t.attributes.aPosition.bindToBuffer(this._vertexBuffer),this._borderIndexBuffer.bind(),e.drawElements(e.LINES,8,e.UNSIGNED_INT,0),e.lineWidth(1),r&&e.enable(e.DEPTH_TEST),i||e.disable(e.BLEND),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)}},{key:"release",value:function(){this.deleteTexture(),this._vertexBuffer.release(),this._texCoordBuffer.release(),this._indexBuffer.release(),this._borderIndexBuffer.release()}}])&&$s(t.prototype,r),e}();eo.ID=0;const to=eo;function ro(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function io(e){return(io="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 no(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function ao(e,t){return(ao=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function so(e,t){return!t||"object"!==io(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function oo(e){return(oo=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const lo=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ao(e,t)}(h,e);var t,r,l,u,c=(l=h,u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=oo(l);if(u){var r=oo(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return so(this,e)});function h(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,h),(e=c.call(this))._mouseX=0,e._mouseY=0,e._lastMouseX=0,e._lastMouseY=0,e._lastScale=0,e._action=s.Z.Action.NOTHING,e._lastNbPointers=0,e._isWheelingIn=!1,e._maskX=0,e._maskY=0,e._hammer=new n.Manager(e._canvas),e._eventProxy={},e.initHammer(),e.addEvents(),e}return t=h,(r=[{key:"addEvents",value:function(){var e=this._canvas,t=this.onMouseWheel.bind(this),r=this.onPointer.bind(this);e.addEventListener("pointerdown",r,!1),e.addEventListener("pointermove",r,!1),e.addEventListener("mousedown",this.onMouseDown.bind(this),!1),e.addEventListener("mouseup",this.onMouseUp.bind(this),!1),e.addEventListener("mouseout",this.onMouseOut.bind(this),!1),e.addEventListener("mouseover",this.onMouseOver.bind(this),!1),e.addEventListener("mousemove",o.Z.throttle(this.onMouseMove.bind(this),16.66),!1),e.addEventListener("mousewheel",t,!1),e.addEventListener("DOMMouseScroll",t,!1),window.addEventListener("keydown",this.onKeyDown.bind(this),!1),window.addEventListener("keyup",this.onKeyUp.bind(this),!1);var i=this.loadFiles.bind(this),n=this.stopAndPrevent.bind(this);e.addEventListener("webglcontextlost",this.onContextLost.bind(this),!1),e.addEventListener("webglcontextrestored",this.onContextRestored.bind(this),!1),window.addEventListener("dragenter",n,!1),window.addEventListener("dragover",n,!1),window.addEventListener("drop",i,!1),document.getElementById("fileopen").addEventListener("change",i,!1)}},{key:"onPointer",value:function(e){a.Z.pressure=e.pressure}},{key:"initHammer",value:function(){this._hammer.options.enable=!0,this._initHammerRecognizers(),this._initHammerEvents()}},{key:"_initHammerRecognizers",value:function(){var e=this._hammer;e.add(new n.Tap({event:"doubletap",pointers:1,taps:2,time:250,interval:450,threshold:5,posThreshold:50})),e.add(new n.Tap({event:"doubletap2fingers",pointers:2,taps:2,time:250,interval:450,threshold:5,posThreshold:50})),e.add(new n.Pan({event:"pan",pointers:0,threshold:0})),e.add(new n.Pinch({event:"pinch",pointers:2,threshold:.1})),e.get("pinch").recognizeWith(e.get("pan"))}},{key:"_initHammerEvents",value:function(){var e=this._hammer;e.on("panstart",this.onPanStart.bind(this)),e.on("panmove",this.onPanMove.bind(this)),e.on("panend pancancel",this.onPanEnd.bind(this)),e.on("doubletap",this.onDoubleTap.bind(this)),e.on("doubletap2fingers",this.onDoubleTap2Fingers.bind(this)),e.on("pinchstart",this.onPinchStart.bind(this)),e.on("pinchin pinchout",this.onPinchInOut.bind(this))}},{key:"stopAndPrevent",value:function(e){e.stopPropagation(),e.preventDefault()}},{key:"onContextLost",value:function(){window.alert("Oops... WebGL context lost.")}},{key:"onContextRestored",value:function(){window.alert("Wow... Context is restored.")}},{key:"onKeyDown",value:function(e){this._gui.callFunc("onKeyDown",e)}},{key:"onKeyUp",value:function(e){this._gui.callFunc("onKeyUp",e)}},{key:"onPanStart",value:function(e){if("mouse"!==e.pointerType){this._focusGui=!1;var t=this._eventProxy;t.pageX=e.center.x,t.pageY=e.center.y,this.onPanUpdateNbPointers(Math.min(3,e.pointers.length))}}},{key:"onPanMove",value:function(e){if("mouse"!==e.pointerType){var t=this._eventProxy;t.pageX=e.center.x,t.pageY=e.center.y;var r=Math.min(3,e.pointers.length);r!==this._lastNbPointers&&(this.onDeviceUp(),this.onPanUpdateNbPointers(r)),this.onDeviceMove(t),this._isIOS()&&(window.clearTimeout(this._timerResetPointer),this._timerResetPointer=window.setTimeout(function(){this._lastNbPointers=0}.bind(this),60))}}},{key:"_isIOS",value:function(){return void 0!==this._isIOS||(this._isIOS=/iPad|iPhone|iPod/.test(navigator.userAgent)),this._isIOS}},{key:"onPanUpdateNbPointers",value:function(e){var t=this._eventProxy;t.which=1===e&&this._lastNbPointers>=1?3:e,this._lastNbPointers=e,this.onDeviceDown(t)}},{key:"onPanEnd",value:function(e){"mouse"!==e.pointerType&&(this.onDeviceUp(),window.setTimeout(function(){e.pointers.length||(this._lastNbPointers=0)}.bind(this),60))}},{key:"onDoubleTap",value:function(e){if(!this._focusGui){var t=this._eventProxy;t.pageX=e.center.x,t.pageY=e.center.y,this.setMousePosition(t);var r=this._picking,n=r.intersectionMouseMeshes(),a=this._camera,s=[0,0,0];if(!n)return this.resetCameraMeshes();i.fF(s,r.getIntersectionPoint(),r.getMesh().getMatrix());var o=a._trans[2];a.isOrthographic()||(o=Math.min(o,i.TK(s,a.computePosition()))),a.setAndFocusOnPivot(s,o),this.render()}}},{key:"onDoubleTap2Fingers",value:function(){this._focusGui||this.resetCameraMeshes()}},{key:"onPinchStart",value:function(e){this._focusGui=!1,this._lastScale=e.scale}},{key:"onPinchInOut",value:function(e){var t=25*(e.scale-this._lastScale);this._lastScale=e.scale,this.onDeviceWheel(t)}},{key:"resetCameraMeshes",value:function(e){if(e||(e=this._meshes),e.length>0){var t=[0,0,0],r=this.computeBoundingBoxMeshes(e),n=.8*this.computeRadiusFromBoundingBox(r);n*=this._camera.computeFrustumFit(),i.t8(t,.5*(r[0]+r[3]),.5*(r[1]+r[4]),.5*(r[2]+r[5])),this._camera.setAndFocusOnPivot(t,n)}else this._camera.resetView();this.render()}},{key:"getFileType",value:function(e){var t=e.toLowerCase();return t.endsWith(".obj")?"obj":t.endsWith(".sgl")?"sgl":t.endsWith(".stl")?"stl":t.endsWith(".ply")?"ply":void 0}},{key:"loadFiles",value:function(e){e.stopPropagation(),e.preventDefault();for(var t=e.dataTransfer?e.dataTransfer.files:e.target.files,r=0,i=t.length;r<i;++r){var n=t[r],a=this.getFileType(n.name);this.readFile(n,a)}}},{key:"readFile",value:function(e,t){var r=t||this.getFileType(e.name);if(r){var i=new FileReader,n=this;i.onload=function(e){n.loadScene(e.target.result,r),document.getElementById("fileopen").value=""},"obj"===r?i.readAsText(e):i.readAsArrayBuffer(e)}}},{key:"onMouseDown",value:function(e){e.stopPropagation(),e.preventDefault(),this._gui.callFunc("onMouseDown",e),this.onDeviceDown(e)}},{key:"onMouseMove",value:function(e){e.stopPropagation(),e.preventDefault(),this._gui.callFunc("onMouseMove",e),this.onDeviceMove(e)}},{key:"onMouseOver",value:function(e){this._focusGui=!1,this._gui.callFunc("onMouseOver",e)}},{key:"onMouseOut",value:function(e){this._focusGui=!0,this._gui.callFunc("onMouseOut",e),this.onMouseUp(e)}},{key:"onMouseUp",value:function(e){e.preventDefault(),this._gui.callFunc("onMouseUp",e),this.onDeviceUp()}},{key:"onMouseWheel",value:function(e){e.stopPropagation(),e.preventDefault(),this._gui.callFunc("onMouseWheel",e);var t=void 0===e.wheelDelta?-e.detail:e.wheelDelta;this.onDeviceWheel(t>0?1:-1)}},{key:"onDeviceUp",value:function(){if(this._transformingComparisonImage)return this._transformingComparisonImage=!1,this._transformStartX=null,this._transformStartY=null,this._transformStartPos=null,this._transformStartSize=null,void this.render();this.setCanvasCursor("default"),ca.RENDER_HINT=ca.NONE,this._sculptManager.end(),this._action===s.Z.Action.MASK_EDIT&&this._mesh&&(this._lastMouseX===this._maskX&&this._lastMouseY===this._maskY?this.getSculptManager().getTool(s.Z.Tools.MASKING).invert():this.getSculptManager().getTool(s.Z.Tools.MASKING).clear()),this._action=s.Z.Action.NOTHING,this.render(),this._stateManager.cleanNoop()}},{key:"onDeviceWheel",value:function(e){e>0&&!this._isWheelingIn&&(this._isWheelingIn=!0,this._camera.start(this._mouseX,this._mouseY)),this._camera.zoom(.02*e),ca.RENDER_HINT=ca.CAMERA,this.render(),this._timerEndWheel&&window.clearTimeout(this._timerEndWheel),this._timerEndWheel=window.setTimeout(this._endWheel.bind(this),300)}},{key:"_endWheel",value:function(){ca.RENDER_HINT=ca.NONE,this._isWheelingIn=!1,this.render()}},{key:"setMousePosition",value:function(e){this._mouseX=this._pixelRatio*(e.pageX-this._canvasOffsetLeft),this._mouseY=this._pixelRatio*(e.pageY-this._canvasOffsetTop)}},{key:"onDeviceDown",value:function(e){if(!this._focusGui){this.setMousePosition(e);var t=this._mouseX,r=this._mouseY,i=e.which;if(1===i&&!e.shiftKey&&!e.ctrlKey&&!e.altKey){var n=this.pickComparisonImage(t,r);if(n)return this.setSelectedComparisonImage(n),this._transformingComparisonImage=!0,this._transformStartX=t,this._transformStartY=r,this._transformStartPos=n.getPosition().slice(),this._transformStartSize=n.getSize(),void(this._action=s.Z.Action.NOTHING)}var a=!1;1===i&&(a=this._sculptManager.start(e.shiftKey)),1===i&&a&&this.setCanvasCursor("none"),3===i&&e.ctrlKey?this._action=s.Z.Action.CAMERA_ZOOM:2===i?this._action=s.Z.Action.CAMERA_PAN:!a&&e.ctrlKey?(this._maskX=t,this._maskY=r,this._action=s.Z.Action.MASK_EDIT):a&&3!==i||!e.altKey?this._action=3===i||1===i&&!a?s.Z.Action.CAMERA_ROTATE:s.Z.Action.SCULPT_EDIT:this._action=s.Z.Action.CAMERA_PAN_ZOOM_ALT,this._action!==s.Z.Action.CAMERA_ROTATE&&this._action!==s.Z.Action.CAMERA_ZOOM||this._camera.start(t,r),this._lastMouseX=t,this._lastMouseY=r}}},{key:"getSpeedFactor",value:function(){return this._cameraSpeed/(this._canvasHeight*this.getPixelRatio())}},{key:"onDeviceMove",value:function(e){if(!this._focusGui){this.setMousePosition(e);var t=this._mouseX,r=this._mouseY,n=this._action,a=this.getSpeedFactor();if(this._transformingComparisonImage&&this._selectedComparisonImage){var o=this._selectedComparisonImage,l=this._picking,u=l.unproject(t,r,0),c=l.unproject(t,r,.1),h=l.unproject(this._transformStartX,this._transformStartY,0),d=l.unproject(this._transformStartX,this._transformStartY,.1),f=o.intersectRay(h,d),_=o.intersectRay(u,c);if(f&&_){if(e.shiftKey){var p=i.TK(h,f),g=i.TK(u,_);if(p>.001){var m=g/p,v=this._transformStartSize.width*m,y=this._transformStartSize.height*m,b=!e.ctrlKey&&!e.metaKey;o.setSizeMaintainAspect(v,y,b),o.setPosition(this._transformStartPos[0],this._transformStartPos[1],this._transformStartPos[2])}}else{var T=i.Ue();i.lu(T,_,f);var M=i.Ue();i.IH(M,this._transformStartPos,T),o.setPosition(M[0],M[1],M[2])}this.render()}return this._lastMouseX=t,void(this._lastMouseY=r)}n===s.Z.Action.CAMERA_ZOOM||n===s.Z.Action.CAMERA_PAN_ZOOM_ALT&&!e.altKey?(ca.RENDER_HINT=ca.CAMERA,this._camera.zoom((t-this._lastMouseX+r-this._lastMouseY)*a),this.render()):n===s.Z.Action.CAMERA_PAN_ZOOM_ALT||n===s.Z.Action.CAMERA_PAN?(ca.RENDER_HINT=ca.CAMERA,this._camera.translate((t-this._lastMouseX)*a,(r-this._lastMouseY)*a),this.render()):n===s.Z.Action.CAMERA_ROTATE?(ca.RENDER_HINT=ca.CAMERA,e.shiftKey||this._camera.rotate(t,r),this.render()):(ca.RENDER_HINT=ca.PICKING,this._sculptManager.preUpdate(),n===s.Z.Action.SCULPT_EDIT&&(ca.RENDER_HINT=ca.SCULPT,this._sculptManager.update(this),this.getMesh().isDynamic&&this._gui.updateMeshInfo())),this._lastMouseX=t,this._lastMouseY=r,this.renderSelectOverRtt()}}}])&&no(t.prototype,r),h}(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._gl=null,this._cameraSpeed=.25,this._pixelRatio=1,this._viewport=document.getElementById("viewport"),this._canvas=document.getElementById("canvas"),this._canvasWidth=0,this._canvasHeight=0,this._canvasOffsetLeft=0,this._canvasOffsetTop=0,this._stateManager=new Es(this),this._sculptManager=null,this._camera=new qs(this),this._picking=new Qa.Z(this),this._pickingSym=new Qa.Z(this,!0),this._meshPreview=null,this._torusLength=.5,this._torusWidth=.1,this._torusRadius=2*Math.PI,this._torusRadial=32,this._torusTubular=128;var t=(0,u.Z)();this._showContour=t.outline,this._showGrid=t.grid,this._grid=null,this._background=null,this._meshes=[],this._selectMeshes=[],this._mesh=null,this._comparisonImages=[],this._selectedComparisonImage=null,this._rttContour=null,this._rttMerge=null,this._rttOpaque=null,this._rttTransparent=null,this._focusGui=!1,this._gui=new Vs(this),this._preventRender=!1,this._drawFullScene=!1,this._autoMatrix=t.scalecenter,this._vertexSRGB=!0}var t,r;return t=e,(r=[{key:"start",value:function(){if(this.initWebGL(),this._gl){this._sculptManager=new Fi(this),this._background=new Qs(this._gl,this),console.log("[Scene] Setting up comparison image file input listener...");var e=document.getElementById("comparisonimageopen");e||(console.warn("[Scene] comparisonimageopen input not found, creating it..."),(e=document.createElement("input")).type="file",e.id="comparisonimageopen",e.accept="image/*",e.style.display="none",document.body.appendChild(e)),e?(console.log("[Scene] Found comparison image input, adding event listener"),e.addEventListener("change",function(e){console.log("[Scene] Comparison image file selected:",e.target.files.length,"file(s)"),e.target.files.length>0&&(console.log("[Scene] Adding comparison image:",e.target.files[0].name),this.addComparisonImage(e.target.files[0]),e.target.value="")}.bind(this),!1)):console.error("[Scene] Failed to create comparison image input element!"),this._rttContour=new Wn(this._gl,s.Z.Shader.CONTOUR,null),this._rttMerge=new Wn(this._gl,s.Z.Shader.MERGE,null),this._rttOpaque=new Wn(this._gl,s.Z.Shader.FXAA),this._rttTransparent=new Wn(this._gl,null,this._rttOpaque.getDepth(),!0),this._grid=Jr.createGrid(this._gl),this.initGrid(),this.loadTextures(),this._gui.initGui(),this.onCanvasResize();var t=(0,u.Z)();t.modelurl?this.addModelURL(t.modelurl):t.nosphere||this.addSphere()}}},{key:"addModelURL",value:function(e){var t=this.getFileType(e);if(t){var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="obj"===t?"text":"arraybuffer",r.onload=function(){200===r.status&&this.loadScene(r.response,t)}.bind(this),r.send(null)}}},{key:"getBackground",value:function(){return this._background}},{key:"getViewport",value:function(){return this._viewport}},{key:"getCanvas",value:function(){return this._canvas}},{key:"getPixelRatio",value:function(){return this._pixelRatio}},{key:"getCanvasWidth",value:function(){return this._canvasWidth}},{key:"getCanvasHeight",value:function(){return this._canvasHeight}},{key:"getCamera",value:function(){return this._camera}},{key:"getGui",value:function(){return this._gui}},{key:"getMeshes",value:function(){return this._meshes}},{key:"getMesh",value:function(){return this._mesh}},{key:"getSelectedMeshes",value:function(){return this._selectMeshes}},{key:"getComparisonImages",value:function(){return this._comparisonImages}},{key:"getSelectedComparisonImage",value:function(){return this._selectedComparisonImage}},{key:"addComparisonImage",value:function(e){console.log("[Scene] addComparisonImage called with file:",e?e.name:"null");var t=this._gl;if(!t)return console.error("[Scene] WebGL not initialized"),null;if(this._comparisonImages.length>=10)return console.warn("[Scene] Maximum comparison images reached"),alert("Maximum of 10 comparison images allowed. Please remove some before adding more."),null;console.log("[Scene] Creating new ComparisonImage instance...");var r=new to(t,this);return console.log("[Scene] ComparisonImage created, loading image..."),r.loadImage(e),console.log("[Scene] Setting initial position and size (defaultSize:",10,")"),r.setPosition(0,0,0),r.setSize(10,10/r._aspectRatio),console.log("[Scene] Adding comparison image to array, current count:",this._comparisonImages.length),this._comparisonImages.push(r),this._selectedComparisonImage=r,console.log("[Scene] Initializing matrices for comparison image..."),r.updateMatrices(this._camera),console.log("[Scene] Comparison image added, triggering render..."),this.render(),r}},{key:"removeComparisonImage",value:function(e){var t=this._comparisonImages.indexOf(e);-1!==t&&(e.release(),this._comparisonImages.splice(t,1),this._selectedComparisonImage===e&&(this._selectedComparisonImage=null),this.render())}},{key:"setSelectedComparisonImage",value:function(e){this._selectedComparisonImage&&this._selectedComparisonImage.setSelected(!1),this._selectedComparisonImage=e,e&&e.setSelected(!0),this._gui&&this._gui._ctrlComparisonImage&&this._gui._ctrlComparisonImage.updateVisibility(),this.render()}},{key:"pickComparisonImage",value:function(e,t){for(var r=this._picking,n=r.unproject(e,t,0),a=r.unproject(e,t,.1),s=this._comparisonImages,o=null,l=1/0,u=0;u<s.length;u++){var c=s[u];if(c._texture){var h=c.intersectRay(n,a);if(h){var d=i.x9(i.lu([],h,n));d<l&&(l=d,o=c)}}}return o}},{key:"getPicking",value:function(){return this._picking}},{key:"getPickingSymmetry",value:function(){return this._pickingSym}},{key:"getSculptManager",value:function(){return this._sculptManager}},{key:"getStateManager",value:function(){return this._stateManager}},{key:"setMesh",value:function(e){return this.setOrUnsetMesh(e)}},{key:"setCanvasCursor",value:function(e){this._canvas.style.cursor=e}},{key:"initGrid",value:function(){var e=this._grid;e.normalizeSize();var t=e.getMatrix();l.Iu(t,t,[0,-.45,0]),l.bA(t,t,[10,10,10]),this._grid.setShaderType(s.Z.Shader.FLAT),e.setFlatColor([.04,.04,.04]),e.setClipDisabled(!0)}},{key:"setOrUnsetMesh",value:function(e,t){if(e)if(t){var r=this.getIndexSelectMesh(e);r>=0?this._selectMeshes.length>1&&(this._selectMeshes.splice(r,1),e=this._selectMeshes[0]):this._selectMeshes.push(e)}else this._selectMeshes.length=0,this._selectMeshes.push(e);else this._selectMeshes.length=0;return this._mesh=e,this.getGui().updateMesh(),this.render(),e}},{key:"renderSelectOverRtt",value:function(){this._requestRender()&&(this._drawFullScene=!1)}},{key:"_requestRender",value:function(){return!0!==this._preventRender&&(window.requestAnimationFrame(this.applyRender.bind(this)),this._preventRender=!0,!0)}},{key:"render",value:function(){this._drawFullScene=!0,this._requestRender()}},{key:"applyRender",value:function(){this._preventRender=!1,this.updateMatricesAndSort();var e=this._gl;e&&(this._drawFullScene&&this._drawScene(),e.disable(e.DEPTH_TEST),e.bindFramebuffer(e.FRAMEBUFFER,this._rttMerge.getFramebuffer()),this._rttMerge.render(this),e.bindFramebuffer(e.FRAMEBUFFER,null),this._rttOpaque.render(this),e.enable(e.DEPTH_TEST),this._sculptManager.postRender())}},{key:"_drawScene",value:function(){var e=this._gl,t=0,r=this._meshes,i=r.length;e.disable(e.DEPTH_TEST);var n=this._selectMeshes.length>0&&this._showContour&&de[s.Z.Shader.CONTOUR].color[3]>0;if(n){e.bindFramebuffer(e.FRAMEBUFFER,this._rttContour.getFramebuffer()),e.clear(e.COLOR_BUFFER_BIT);for(var a=0,o=this._selectMeshes,l=o.length;a<l;++a)o[a].renderFlatColor(this)}for(e.enable(e.DEPTH_TEST),e.bindFramebuffer(e.FRAMEBUFFER,this._rttOpaque.getFramebuffer()),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),this._showGrid&&this._grid.render(this),t=0;t<i&&!r[t].isTransparent();++t)r[t].render(this);for(var u=0,c=(h=this._comparisonImages).length;u<c;++u)h[u].updateMatrices(this._camera);for(h.sort((function(e,t){return t.getDepth()-e.getDepth()})),u=0;u<c;++u)h[u].render();var h,d=t;for(this._meshPreview&&this._meshPreview.render(this),this._background.render(),e.bindFramebuffer(e.FRAMEBUFFER,this._rttTransparent.getFramebuffer()),e.clear(e.COLOR_BUFFER_BIT),e.enable(e.BLEND),e.depthFunc(e.LESS),t=0;t<i;++t)r[t].getShowWireframe()&&r[t].renderWireframe(this);for(e.depthFunc(e.LEQUAL),e.depthMask(!1),e.enable(e.CULL_FACE),t=d;t<i;++t)e.cullFace(e.FRONT),r[t].render(this),e.cullFace(e.BACK),r[t].render(this);for(u=0,c=(h=this._comparisonImages).length;u<c;++u)h[u].updateMatrices(this._camera);for(h.sort((function(e,t){return t.getDepth()-e.getDepth()})),u=0;u<c;++u)h[u].render();e.disable(e.CULL_FACE),n&&this._rttContour.render(this),e.depthMask(!0),e.disable(e.BLEND)}},{key:"updateMatricesAndSort",value:function(){var e=this._meshes,t=this._camera;e.length>0&&t.optimizeNearFar(this.computeBoundingBoxScene());for(var r=0,i=e.length;r<i;++r)e[r].updateMatrices(t);e.sort(Qt.sortFunction),this._meshPreview&&this._meshPreview.updateMatrices(t),this._grid&&this._grid.updateMatrices(t)}},{key:"initWebGL",value:function(){var e={antialias:!1,stencil:!0},t=document.getElementById("canvas"),r=this._gl=t.getContext("webgl",e)||t.getContext("experimental-webgl",e);r?(Bn.initWebGLExtensions(r),Bn.getWebGLExtension("OES_element_index_uint")||(Yt.ONLY_DRAW_ARRAYS=!0),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.disable(r.CULL_FACE),r.frontFace(r.CCW),r.cullFace(r.BACK),r.disable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.disable(r.DEPTH_TEST),r.depthFunc(r.LEQUAL),r.depthMask(!0),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)):window.alert("Could not initialise WebGL. No WebGL, no SculptGL. Sorry.")}},{key:"loadTextures",value:function(){for(var e=this,t=this._gl,r=de[s.Z.Shader.MATCAP],i=function(i,n){var a=new Image;a.src=i,a.onload=function(){r.createTexture(t,a,n),e.render()}},n=0,a=r.matcaps,o=a.length;n<o;++n)i(a[n].path,n);this.initAlphaTextures()}},{key:"initAlphaTextures",value:function(){for(var e=Qa.Z.INIT_ALPHAS_PATHS,t=Qa.Z.INIT_ALPHAS_NAMES,r=0,i=e.length;r<i;++r){var n=new Image;n.src="resources/alpha/"+e[r],n.onload=this.onLoadAlphaImage.bind(this,n,t[r])}}},{key:"onCanvasResize",value:function(){var e=this._viewport,t=e.clientWidth*this._pixelRatio,r=e.clientHeight*this._pixelRatio;this._canvasOffsetLeft=e.offsetLeft,this._canvasOffsetTop=e.offsetTop,this._canvasWidth=t,this._canvasHeight=r,this._canvas.width=t,this._canvas.height=r,this._gl.viewport(0,0,t,r),this._camera.onResize(t,r),this._background.onResize(t,r),this._rttContour.onResize(t,r),this._rttMerge.onResize(t,r),this._rttOpaque.onResize(t,r),this._rttTransparent.onResize(t,r),this.render()}},{key:"computeRadiusFromBoundingBox",value:function(e){var t=e[3]-e[0],r=e[4]-e[1],i=e[5]-e[2];return.5*Math.sqrt(t*t+r*r+i*i)}},{key:"computeBoundingBoxMeshes",value:function(e){for(var t=[1/0,1/0,1/0,-1/0,-1/0,-1/0],r=0,i=e.length;r<i;++r)if(e[r].isVisible()){var n=e[r].computeWorldBound();n[0]<t[0]&&(t[0]=n[0]),n[1]<t[1]&&(t[1]=n[1]),n[2]<t[2]&&(t[2]=n[2]),n[3]>t[3]&&(t[3]=n[3]),n[4]>t[4]&&(t[4]=n[4]),n[5]>t[5]&&(t[5]=n[5])}return t}},{key:"computeBoundingBoxScene",value:function(){var e=this._meshes.slice();return e.push(this._grid),this._sculptManager.addSculptToScene(e),this.computeBoundingBoxMeshes(e)}},{key:"normalizeAndCenterMeshes",value:function(e){var t=this.computeBoundingBoxMeshes(e),r=o.Z.SCALE/i.TK([t[0],t[1],t[2]],[t[3],t[4],t[5]]),n=l.Ue();l.bA(n,n,[r,r,r]),l.Iu(n,n,[.5*-(t[0]+t[3]),.5*-(t[1]+t[4]),.5*-(t[2]+t[5])]);for(var a=0,s=e.length;a<s;++a){var u=e[a].getMatrix();l.dC(u,n,u)}}},{key:"addSphere",value:function(){var e=new ca(Jr.createCube(this._gl));return e.normalizeSize(),this.subdivideClamp(e),this.addNewMesh(e)}},{key:"addCube",value:function(){var e=new ca(Jr.createCube(this._gl));return e.normalizeSize(),l.bA(e.getMatrix(),e.getMatrix(),[.7,.7,.7]),this.subdivideClamp(e,!0),this.addNewMesh(e)}},{key:"addCylinder",value:function(){var e=new ca(Jr.createCylinder(this._gl));return e.normalizeSize(),l.bA(e.getMatrix(),e.getMatrix(),[.7,.7,.7]),this.subdivideClamp(e),this.addNewMesh(e)}},{key:"addTorus",value:function(e){var t=new ca(Jr.createTorus(this._gl,this._torusLength,this._torusWidth,this._torusRadius,this._torusRadial,this._torusTubular));if(e){t.setShowWireframe(!0);var r=.3*o.Z.SCALE;return l.bA(t.getMatrix(),t.getMatrix(),[r,r,r]),void(this._meshPreview=t)}t.normalizeSize(),this.subdivideClamp(t),this.addNewMesh(t)}},{key:"subdivideClamp",value:function(e,t){for(Ui.LINEAR=!!t;e.getNbFaces()<5e4;)e.addLevel();e._meshes.splice(0,Math.min(e._meshes.length-4,4)),e._sel=e._meshes.length-1,Ui.LINEAR=!1}},{key:"addNewMesh",value:function(e){return this._meshes.push(e),this._stateManager.pushStateAdd(e),this.setMesh(e),e}},{key:"loadScene",value:function(e,t){var r;"obj"===t?r=on.importOBJ(e,this._gl):"sgl"===t?r=on.importSGL(e,this._gl,this):"stl"===t?r=on.importSTL(e,this._gl):"ply"===t&&(r=on.importPLY(e,this._gl));var i=r.length;if(0!==i){for(var n=this._meshes,a=0;a<i;++a){var s=r[a]=new ca(r[a]);!this._vertexSRGB&&s.getColors()&&o.Z.convertArrayVec3toSRGB(s.getColors()),s.init(),s.initRender(),n.push(s)}return this._autoMatrix&&this.normalizeAndCenterMeshes(r),this._stateManager.pushStateAdd(r),this.setMesh(n[n.length-1]),this.resetCameraMeshes(r),r}}},{key:"clearScene",value:function(){this.getStateManager().reset(),this.getMeshes().length=0,this.getCamera().resetView(),this.setMesh(null),this._action=s.Z.Action.NOTHING}},{key:"deleteCurrentSelection",value:function(){this._mesh&&(this.removeMeshes(this._selectMeshes),this._stateManager.pushStateRemove(this._selectMeshes.slice()),this._selectMeshes.length=0,this.setMesh(null))}},{key:"removeMeshes",value:function(e){for(var t=this._meshes,r=0;r<e.length;++r)t.splice(this.getIndexMesh(e[r]),1)}},{key:"getIndexMesh",value:function(e,t){for(var r=t?this._selectMeshes:this._meshes,i=e.getID(),n=0,a=r.length;n<a;++n){var s=r[n];if(s===e||s.getID()===i)return n}return-1}},{key:"getIndexSelectMesh",value:function(e){return this.getIndexMesh(e,!0)}},{key:"replaceMesh",value:function(e,t){var r=this.getIndexMesh(e);r>=0&&(this._meshes[r]=t),this._mesh===e&&this.setMesh(t)}},{key:"duplicateSelection",value:function(){for(var e=this._selectMeshes.slice(),t=null,r=0;r<e.length;++r){t=e[r];var i=new sr(t.getGL());i.copyData(t),this.addNewMesh(i)}this.setMesh(t)}},{key:"onLoadAlphaImage",value:function(e,t,r){var i=document.createElement("canvas");i.width=e.width,i.height=e.height;var n=i.getContext("2d");n.drawImage(e,0,0);for(var a=n.getImageData(0,0,e.width,e.height).data,s=a.subarray(0,a.length/4),o=0,l=0,u=s.length;o<u;++o,l+=4)s[o]=Math.round((a[l]+a[l+1]+a[l+2])/3);var c={};c[t=Qa.Z.addAlpha(s,e.width,e.height,t)._name]=t,this.getGui().addAlphaOptions(c),r&&r._ctrlAlpha&&r._ctrlAlpha.setValue(t)}}])&&ro(t.prototype,r),e}());window.SculptGL=lo},652:function(e,t,r){var i,n;function a(e){return(a="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)}void 0===(n="function"==typeof(i=function(){"use strict";function t(e,t,r){var i=new XMLHttpRequest;i.open("GET",e),i.responseType="blob",i.onload=function(){l(i.response,t,r)},i.onerror=function(){console.error("could not download file")},i.send()}function i(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function n(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(r){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var s="object"==("undefined"==typeof window?"undefined":a(window))&&window.window===window?window:"object"==("undefined"==typeof self?"undefined":a(self))&&self.self===self?self:"object"==(void 0===r.g?"undefined":a(r.g))&&r.g.global===r.g?r.g:void 0,o=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=s.saveAs||("object"!=("undefined"==typeof window?"undefined":a(window))||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!o?function(e,r,a){var o=s.URL||s.webkitURL,l=document.createElement("a");r=r||e.name||"download",l.download=r,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?n(l):i(l.href)?t(e,r,a):n(l,l.target="_blank")):(l.href=o.createObjectURL(e),setTimeout((function(){o.revokeObjectURL(l.href)}),4e4),setTimeout((function(){n(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,r,s){if(r=r||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=a(t)&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,s),r);else if(i(e))t(e,r,s);else{var o=document.createElement("a");o.href=e,o.target="_blank",setTimeout((function(){n(o)}))}}:function(e,r,i,n){if((n=n||open("","_blank"))&&(n.document.title=n.document.body.innerText="downloading..."),"string"==typeof e)return t(e,r,i);var a="application/octet-stream"===e.type,l=/constructor/i.test(s.HTMLElement)||s.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||a&&l||o)&&"undefined"!=typeof FileReader){var c=new FileReader;c.onloadend=function(){var e=c.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=e:location=e,n=null},c.readAsDataURL(e)}else{var h=s.URL||s.webkitURL,d=h.createObjectURL(e);n?n.location=d:location.href=d,n=null,setTimeout((function(){h.revokeObjectURL(d)}),4e4)}});s.saveAs=l.saveAs=l,e.exports=l})?i.apply(t,[]):i)||(e.exports=n)},663:(e,t,r)=>{"use strict";r.d(t,{Ib:()=>i,WT:()=>n});var i=1e-6,n="undefined"!=typeof Float32Array?Float32Array:Array;Math.random,Math.PI,Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)})},89:(e,t,r)=>{"use strict";r.d(t,{Ue:()=>n,JG:()=>a,yR:()=>s,U_:()=>o,Iu:()=>l,bA:()=>u,U1:()=>c,lM:()=>h,uD:()=>d,jI:()=>f,en:()=>_,G3:()=>p,M5:()=>g,zB:()=>m,dC:()=>v});var i=r(663);function n(){var e=new i.WT(16);return i.WT!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function a(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function s(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function o(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],f=t[11],_=t[12],p=t[13],g=t[14],m=t[15],v=r*o-i*s,y=r*l-n*s,b=r*u-a*s,T=i*l-n*o,M=i*u-a*o,S=n*u-a*l,k=c*p-h*_,E=c*g-d*_,A=c*m-f*_,C=h*g-d*p,w=h*m-f*p,R=d*m-f*g,x=v*R-y*w+b*C+T*A-M*E+S*k;return x?(x=1/x,e[0]=(o*R-l*w+u*C)*x,e[1]=(n*w-i*R-a*C)*x,e[2]=(p*S-g*M+m*T)*x,e[3]=(d*M-h*S-f*T)*x,e[4]=(l*A-s*R-u*E)*x,e[5]=(r*R-n*A+a*E)*x,e[6]=(g*b-_*S-m*y)*x,e[7]=(c*S-d*b+f*y)*x,e[8]=(s*w-o*A+u*k)*x,e[9]=(i*A-r*w-a*k)*x,e[10]=(_*M-p*b+m*v)*x,e[11]=(h*b-c*M-f*v)*x,e[12]=(o*E-s*C-l*k)*x,e[13]=(r*C-i*E+n*k)*x,e[14]=(p*y-_*T-g*v)*x,e[15]=(c*T-h*y+d*v)*x,e):null}function l(e,t,r){var i,n,a,s,o,l,u,c,h,d,f,_,p=r[0],g=r[1],m=r[2];return t===e?(e[12]=t[0]*p+t[4]*g+t[8]*m+t[12],e[13]=t[1]*p+t[5]*g+t[9]*m+t[13],e[14]=t[2]*p+t[6]*g+t[10]*m+t[14],e[15]=t[3]*p+t[7]*g+t[11]*m+t[15]):(i=t[0],n=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],_=t[11],e[0]=i,e[1]=n,e[2]=a,e[3]=s,e[4]=o,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=f,e[11]=_,e[12]=i*p+o*g+h*m+t[12],e[13]=n*p+l*g+d*m+t[13],e[14]=a*p+u*g+f*m+t[14],e[15]=s*p+c*g+_*m+t[15]),e}function u(e,t,r){var i=r[0],n=r[1],a=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function c(e,t,r,n){var a,s,o,l,u,c,h,d,f,_,p,g,m,v,y,b,T,M,S,k,E,A,C,w,R=n[0],x=n[1],P=n[2],D=Math.hypot(R,x,P);return D<i.Ib?null:(R*=D=1/D,x*=D,P*=D,a=Math.sin(r),o=1-(s=Math.cos(r)),l=t[0],u=t[1],c=t[2],h=t[3],d=t[4],f=t[5],_=t[6],p=t[7],g=t[8],m=t[9],v=t[10],y=t[11],b=R*R*o+s,T=x*R*o+P*a,M=P*R*o-x*a,S=R*x*o-P*a,k=x*x*o+s,E=P*x*o+R*a,A=R*P*o+x*a,C=x*P*o-R*a,w=P*P*o+s,e[0]=l*b+d*T+g*M,e[1]=u*b+f*T+m*M,e[2]=c*b+_*T+v*M,e[3]=h*b+p*T+y*M,e[4]=l*S+d*k+g*E,e[5]=u*S+f*k+m*E,e[6]=c*S+_*k+v*E,e[7]=h*S+p*k+y*E,e[8]=l*A+d*C+g*w,e[9]=u*A+f*C+m*w,e[10]=c*A+_*C+v*w,e[11]=h*A+p*C+y*w,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function h(e,t,r){var i=Math.sin(r),n=Math.cos(r),a=t[4],s=t[5],o=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=a*n+u*i,e[5]=s*n+c*i,e[6]=o*n+h*i,e[7]=l*n+d*i,e[8]=u*n-a*i,e[9]=c*n-s*i,e[10]=h*n-o*i,e[11]=d*n-l*i,e}function d(e,t,r){var i=Math.sin(r),n=Math.cos(r),a=t[0],s=t[1],o=t[2],l=t[3],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*n-u*i,e[1]=s*n-c*i,e[2]=o*n-h*i,e[3]=l*n-d*i,e[8]=a*i+u*n,e[9]=s*i+c*n,e[10]=o*i+h*n,e[11]=l*i+d*n,e}function f(e,t,r){var i=Math.sin(r),n=Math.cos(r),a=t[0],s=t[1],o=t[2],l=t[3],u=t[4],c=t[5],h=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*n+u*i,e[1]=s*n+c*i,e[2]=o*n+h*i,e[3]=l*n+d*i,e[4]=u*n-a*i,e[5]=c*n-s*i,e[6]=h*n-o*i,e[7]=d*n-l*i,e}function _(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=r+r,o=i+i,l=n+n,u=r*s,c=i*s,h=i*o,d=n*s,f=n*o,_=n*l,p=a*s,g=a*o,m=a*l;return e[0]=1-h-_,e[1]=c+m,e[2]=d-g,e[3]=0,e[4]=c-m,e[5]=1-u-_,e[6]=f+p,e[7]=0,e[8]=d+g,e[9]=f-p,e[10]=1-u-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function p(e,t,r,i,n){var a,s=1/Math.tan(t/2);return e[0]=s/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(a=1/(i-n),e[10]=(n+i)*a,e[14]=2*n*i*a):(e[10]=-1,e[14]=-2*i),e}function g(e,t,r,i,n,a,s){var o=1/(t-r),l=1/(i-n),u=1/(a-s);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*o,e[13]=(n+i)*l,e[14]=(s+a)*u,e[15]=1,e}function m(e,t,r,n){var a,o,l,u,c,h,d,f,_,p,g=t[0],m=t[1],v=t[2],y=n[0],b=n[1],T=n[2],M=r[0],S=r[1],k=r[2];return Math.abs(g-M)<i.Ib&&Math.abs(m-S)<i.Ib&&Math.abs(v-k)<i.Ib?s(e):(d=g-M,f=m-S,_=v-k,a=b*(_*=p=1/Math.hypot(d,f,_))-T*(f*=p),o=T*(d*=p)-y*_,l=y*f-b*d,(p=Math.hypot(a,o,l))?(a*=p=1/p,o*=p,l*=p):(a=0,o=0,l=0),u=f*l-_*o,c=_*a-d*l,h=d*o-f*a,(p=Math.hypot(u,c,h))?(u*=p=1/p,c*=p,h*=p):(u=0,c=0,h=0),e[0]=a,e[1]=u,e[2]=d,e[3]=0,e[4]=o,e[5]=c,e[6]=f,e[7]=0,e[8]=l,e[9]=h,e[10]=_,e[11]=0,e[12]=-(a*g+o*m+l*v),e[13]=-(u*g+c*m+h*v),e[14]=-(d*g+f*m+_*v),e[15]=1,e)}var v=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],_=t[11],p=t[12],g=t[13],m=t[14],v=t[15],y=r[0],b=r[1],T=r[2],M=r[3];return e[0]=y*i+b*o+T*h+M*p,e[1]=y*n+b*l+T*d+M*g,e[2]=y*a+b*u+T*f+M*m,e[3]=y*s+b*c+T*_+M*v,y=r[4],b=r[5],T=r[6],M=r[7],e[4]=y*i+b*o+T*h+M*p,e[5]=y*n+b*l+T*d+M*g,e[6]=y*a+b*u+T*f+M*m,e[7]=y*s+b*c+T*_+M*v,y=r[8],b=r[9],T=r[10],M=r[11],e[8]=y*i+b*o+T*h+M*p,e[9]=y*n+b*l+T*d+M*g,e[10]=y*a+b*u+T*f+M*m,e[11]=y*s+b*c+T*_+M*v,y=r[12],b=r[13],T=r[14],M=r[15],e[12]=y*i+b*o+T*h+M*p,e[13]=y*n+b*l+T*d+M*g,e[14]=y*a+b*u+T*f+M*m,e[15]=y*s+b*c+T*_+M*v,e}},928:(e,t,r)=>{"use strict";r.d(t,{Ue:()=>n,al:()=>a,JG:()=>s,t8:()=>o,IH:()=>l,bA:()=>u,od:()=>c,tk:()=>h,Fv:()=>d,AK:()=>f,kC:()=>_,fF:()=>p,kK:()=>g,VC:()=>m,lu:()=>v,TK:()=>y,nI:()=>b,Zh:()=>T,x9:()=>M});var i=r(663);function n(){var e=new i.WT(3);return i.WT!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function a(e,t,r){var n=new i.WT(3);return n[0]=e,n[1]=t,n[2]=r,n}function s(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function o(e,t,r,i){return e[0]=t,e[1]=r,e[2]=i,e}function l(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function u(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function c(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e}function h(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function d(e,t){var r=t[0],i=t[1],n=t[2],a=r*r+i*i+n*n;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function f(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function _(e,t,r){var i=t[0],n=t[1],a=t[2],s=r[0],o=r[1],l=r[2];return e[0]=n*l-a*o,e[1]=a*s-i*l,e[2]=i*o-n*s,e}function p(e,t,r){var i=t[0],n=t[1],a=t[2],s=r[3]*i+r[7]*n+r[11]*a+r[15];return s=s||1,e[0]=(r[0]*i+r[4]*n+r[8]*a+r[12])/s,e[1]=(r[1]*i+r[5]*n+r[9]*a+r[13])/s,e[2]=(r[2]*i+r[6]*n+r[10]*a+r[14])/s,e}function g(e,t,r){var i=t[0],n=t[1],a=t[2];return e[0]=i*r[0]+n*r[3]+a*r[6],e[1]=i*r[1]+n*r[4]+a*r[7],e[2]=i*r[2]+n*r[5]+a*r[8],e}function m(e,t,r){var i=r[0],n=r[1],a=r[2],s=r[3],o=t[0],l=t[1],u=t[2],c=n*u-a*l,h=a*o-i*u,d=i*l-n*o,f=n*d-a*h,_=a*c-i*d,p=i*h-n*c,g=2*s;return c*=g,h*=g,d*=g,f*=2,_*=2,p*=2,e[0]=o+c+f,e[1]=l+h+_,e[2]=u+d+p,e}var v=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e},y=function(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return Math.hypot(r,i,n)},b=function(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return r*r+i*i+n*n},T=function(e){var t=e[0],r=e[1],i=e[2];return Math.hypot(t,r,i)},M=function(e){var t=e[0],r=e[1],i=e[2];return t*t+r*r+i*i};n()},297:(e,t,r)=>{var i;function n(e){return(n="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(a,s,o,l){"use strict";var u,c=["","webkit","Moz","MS","ms","o"],h=s.createElement("div"),d=Math.round,f=Math.abs,_=Date.now;function p(e,t,r){return setTimeout(M(e,r),t)}function g(e,t,r){return!!Array.isArray(e)&&(m(e,r[t],r),!0)}function m(e,t,r){var i;if(e)if(e.forEach)e.forEach(t,r);else if(e.length!==l)for(i=0;i<e.length;)t.call(r,e[i],i,e),i++;else for(i in e)e.hasOwnProperty(i)&&t.call(r,e[i],i,e)}function v(e,t,r){var i="DEPRECATED METHOD: "+t+"\n"+r+" AT \n";return function(){var t=new Error("get-stack-trace"),r=t&&t.stack?t.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",n=a.console&&(a.console.warn||a.console.log);return n&&n.call(a.console,i,r),e.apply(this,arguments)}}u="function"!=typeof Object.assign?function(e){if(e===l||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),r=1;r<arguments.length;r++){var i=arguments[r];if(i!==l&&null!==i)for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])}return t}:Object.assign;var y=v((function(e,t,r){for(var i=Object.keys(t),n=0;n<i.length;)(!r||r&&e[i[n]]===l)&&(e[i[n]]=t[i[n]]),n++;return e}),"extend","Use `assign`."),b=v((function(e,t){return y(e,t,!0)}),"merge","Use `assign`.");function T(e,t,r){var i,n=t.prototype;(i=e.prototype=Object.create(n)).constructor=e,i._super=n,r&&u(i,r)}function M(e,t){return function(){return e.apply(t,arguments)}}function S(e,t){return"function"==n(e)?e.apply(t&&t[0]||l,t):e}function k(e,t){return e===l?t:e}function E(e,t,r){m(R(t),(function(t){e.addEventListener(t,r,!1)}))}function A(e,t,r){m(R(t),(function(t){e.removeEventListener(t,r,!1)}))}function C(e,t){for(;e;){if(e==t)return!0;e=e.parentNode}return!1}function w(e,t){return e.indexOf(t)>-1}function R(e){return e.trim().split(/\s+/g)}function x(e,t,r){if(e.indexOf&&!r)return e.indexOf(t);for(var i=0;i<e.length;){if(r&&e[i][r]==t||!r&&e[i]===t)return i;i++}return-1}function P(e){return Array.prototype.slice.call(e,0)}function D(e,t,r){for(var i=[],n=[],a=0;a<e.length;){var s=t?e[a][t]:e[a];x(n,s)<0&&i.push(e[a]),n[a]=s,a++}return r&&(i=t?i.sort((function(e,r){return e[t]>r[t]})):i.sort()),i}function I(e,t){for(var r,i,n=t[0].toUpperCase()+t.slice(1),a=0;a<c.length;){if((i=(r=c[a])?r+n:t)in e)return i;a++}return l}var F=1;function O(e){var t=e.ownerDocument||e;return t.defaultView||t.parentWindow||a}var L="ontouchstart"in a,V=I(a,"PointerEvent")!==l,N=L&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),B="touch",U="mouse",Z=["x","y"],G=["clientX","clientY"];function W(e,t){var r=this;this.manager=e,this.callback=t,this.element=e.element,this.target=e.options.inputTarget,this.domHandler=function(t){S(e.options.enable,[e])&&r.handler(t)},this.init()}function j(e,t,r){var i=r.pointers.length,n=r.changedPointers.length,a=1&t&&i-n==0,s=12&t&&i-n==0;r.isFirst=!!a,r.isFinal=!!s,a&&(e.session={}),r.eventType=t,function(e,t){var r=e.session,i=t.pointers,n=i.length;r.firstInput||(r.firstInput=z(t)),n>1&&!r.firstMultiple?r.firstMultiple=z(t):1===n&&(r.firstMultiple=!1);var a=r.firstInput,s=r.firstMultiple,o=s?s.center:a.center,u=t.center=X(i);t.timeStamp=_(),t.deltaTime=t.timeStamp-a.timeStamp,t.angle=q(o,u),t.distance=Y(o,u),function(e,t){var r=t.center,i=e.offsetDelta||{},n=e.prevDelta||{},a=e.prevInput||{};1!==t.eventType&&4!==a.eventType||(n=e.prevDelta={x:a.deltaX||0,y:a.deltaY||0},i=e.offsetDelta={x:r.x,y:r.y}),t.deltaX=n.x+(r.x-i.x),t.deltaY=n.y+(r.y-i.y)}(r,t),t.offsetDirection=H(t.deltaX,t.deltaY);var c,h,d=K(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=d.x,t.overallVelocityY=d.y,t.overallVelocity=f(d.x)>f(d.y)?d.x:d.y,t.scale=s?(c=s.pointers,Y((h=i)[0],h[1],G)/Y(c[0],c[1],G)):1,t.rotation=s?function(e,t){return q(t[1],t[0],G)+q(e[1],e[0],G)}(s.pointers,i):0,t.maxPointers=r.prevInput?t.pointers.length>r.prevInput.maxPointers?t.pointers.length:r.prevInput.maxPointers:t.pointers.length,function(e,t){var r,i,n,a,s=e.lastInterval||t,o=t.timeStamp-s.timeStamp;if(8!=t.eventType&&(o>25||s.velocity===l)){var u=t.deltaX-s.deltaX,c=t.deltaY-s.deltaY,h=K(o,u,c);i=h.x,n=h.y,r=f(h.x)>f(h.y)?h.x:h.y,a=H(u,c),e.lastInterval=t}else r=s.velocity,i=s.velocityX,n=s.velocityY,a=s.direction;t.velocity=r,t.velocityX=i,t.velocityY=n,t.direction=a}(r,t);var p=e.element;C(t.srcEvent.target,p)&&(p=t.srcEvent.target),t.target=p}(e,r),e.emit("hammer.input",r),e.recognize(r),e.session.prevInput=r}function z(e){for(var t=[],r=0;r<e.pointers.length;)t[r]={clientX:d(e.pointers[r].clientX),clientY:d(e.pointers[r].clientY)},r++;return{timeStamp:_(),pointers:t,center:X(t),deltaX:e.deltaX,deltaY:e.deltaY}}function X(e){var t=e.length;if(1===t)return{x:d(e[0].clientX),y:d(e[0].clientY)};for(var r=0,i=0,n=0;n<t;)r+=e[n].clientX,i+=e[n].clientY,n++;return{x:d(r/t),y:d(i/t)}}function K(e,t,r){return{x:t/e||0,y:r/e||0}}function H(e,t){return e===t?1:f(e)>=f(t)?e<0?2:4:t<0?8:16}function Y(e,t,r){r||(r=Z);var i=t[r[0]]-e[r[0]],n=t[r[1]]-e[r[1]];return Math.sqrt(i*i+n*n)}function q(e,t,r){r||(r=Z);var i=t[r[0]]-e[r[0]],n=t[r[1]]-e[r[1]];return 180*Math.atan2(n,i)/Math.PI}W.prototype={handler:function(){},init:function(){this.evEl&&E(this.element,this.evEl,this.domHandler),this.evTarget&&E(this.target,this.evTarget,this.domHandler),this.evWin&&E(O(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&A(this.element,this.evEl,this.domHandler),this.evTarget&&A(this.target,this.evTarget,this.domHandler),this.evWin&&A(O(this.element),this.evWin,this.domHandler)}};var J={mousedown:1,mousemove:2,mouseup:4},Q="mousedown",$="mousemove mouseup";function ee(){this.evEl=Q,this.evWin=$,this.pressed=!1,W.apply(this,arguments)}T(ee,W,{handler:function(e){var t=J[e.type];1&t&&0===e.button&&(this.pressed=!0),2&t&&1!==e.which&&(t=4),this.pressed&&(4&t&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:U,srcEvent:e}))}});var te={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},re={2:B,3:"pen",4:U,5:"kinect"},ie="pointerdown",ne="pointermove pointerup pointercancel";function ae(){this.evEl=ie,this.evWin=ne,W.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}a.MSPointerEvent&&!a.PointerEvent&&(ie="MSPointerDown",ne="MSPointerMove MSPointerUp MSPointerCancel"),T(ae,W,{handler:function(e){var t=this.store,r=!1,i=e.type.toLowerCase().replace("ms",""),n=te[i],a=re[e.pointerType]||e.pointerType,s=a==B,o=x(t,e.pointerId,"pointerId");1&n&&(0===e.button||s)?o<0&&(t.push(e),o=t.length-1):12&n&&(r=!0),o<0||(t[o]=e,this.callback(this.manager,n,{pointers:t,changedPointers:[e],pointerType:a,srcEvent:e}),r&&t.splice(o,1))}});var se={touchstart:1,touchmove:2,touchend:4,touchcancel:8},oe="touchstart",le="touchstart touchmove touchend touchcancel";function ue(){this.evTarget=oe,this.evWin=le,this.started=!1,W.apply(this,arguments)}function ce(e,t){var r=P(e.touches),i=P(e.changedTouches);return 12&t&&(r=D(r.concat(i),"identifier",!0)),[r,i]}T(ue,W,{handler:function(e){var t=se[e.type];if(1===t&&(this.started=!0),this.started){var r=ce.call(this,e,t);12&t&&r[0].length-r[1].length==0&&(this.started=!1),this.callback(this.manager,t,{pointers:r[0],changedPointers:r[1],pointerType:B,srcEvent:e})}}});var he={touchstart:1,touchmove:2,touchend:4,touchcancel:8},de="touchstart touchmove touchend touchcancel";function fe(){this.evTarget=de,this.targetIds={},W.apply(this,arguments)}function _e(e,t){var r=P(e.touches),i=this.targetIds;if(3&t&&1===r.length)return i[r[0].identifier]=!0,[r,r];var n,a,s=P(e.changedTouches),o=[],l=this.target;if(a=r.filter((function(e){return C(e.target,l)})),1===t)for(n=0;n<a.length;)i[a[n].identifier]=!0,n++;for(n=0;n<s.length;)i[s[n].identifier]&&o.push(s[n]),12&t&&delete i[s[n].identifier],n++;return o.length?[D(a.concat(o),"identifier",!0),o]:void 0}function pe(){W.apply(this,arguments);var e=M(this.handler,this);this.touch=new fe(this.manager,e),this.mouse=new ee(this.manager,e),this.primaryTouch=null,this.lastTouches=[]}function ge(e,t){1&e?(this.primaryTouch=t.changedPointers[0].identifier,me.call(this,t)):12&e&&me.call(this,t)}function me(e){var t=e.changedPointers[0];if(t.identifier===this.primaryTouch){var r={x:t.clientX,y:t.clientY};this.lastTouches.push(r);var i=this.lastTouches;setTimeout((function(){var e=i.indexOf(r);e>-1&&i.splice(e,1)}),2500)}}function ve(e){for(var t=e.srcEvent.clientX,r=e.srcEvent.clientY,i=0;i<this.lastTouches.length;i++){var n=this.lastTouches[i],a=Math.abs(t-n.x),s=Math.abs(r-n.y);if(a<=25&&s<=25)return!0}return!1}T(fe,W,{handler:function(e){var t=he[e.type],r=_e.call(this,e,t);r&&this.callback(this.manager,t,{pointers:r[0],changedPointers:r[1],pointerType:B,srcEvent:e})}}),T(pe,W,{handler:function(e,t,r){var i=r.pointerType==B,n=r.pointerType==U;if(!(n&&r.sourceCapabilities&&r.sourceCapabilities.firesTouchEvents)){if(i)ge.call(this,t,r);else if(n&&ve.call(this,r))return;this.callback(e,t,r)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var ye=I(h.style,"touchAction"),be=ye!==l,Te="compute",Me="auto",Se="manipulation",ke="none",Ee="pan-x",Ae="pan-y",Ce=function(){if(!be)return!1;var e={},t=a.CSS&&a.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach((function(r){e[r]=!t||a.CSS.supports("touch-action",r)})),e}();function we(e,t){this.manager=e,this.set(t)}we.prototype={set:function(e){e==Te&&(e=this.compute()),be&&this.manager.element.style&&Ce[e]&&(this.manager.element.style[ye]=e),this.actions=e.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var e=[];return m(this.manager.recognizers,(function(t){S(t.options.enable,[t])&&(e=e.concat(t.getTouchAction()))})),function(e){if(w(e,ke))return ke;var t=w(e,Ee),r=w(e,Ae);return t&&r?ke:t||r?t?Ee:Ae:w(e,Se)?Se:Me}(e.join(" "))},preventDefaults:function(e){var t=e.srcEvent,r=e.offsetDirection;if(this.manager.session.prevented)t.preventDefault();else{var i=this.actions,n=w(i,ke)&&!Ce.none,a=w(i,Ae)&&!Ce["pan-y"],s=w(i,Ee)&&!Ce["pan-x"];if(n){var o=1===e.pointers.length,l=e.distance<2,u=e.deltaTime<250;if(o&&l&&u)return}if(!s||!a)return n||a&&6&r||s&&24&r?this.preventSrc(t):void 0}},preventSrc:function(e){this.manager.session.prevented=!0,e.preventDefault()}};var Re=32;function xe(e){this.options=u({},this.defaults,e||{}),this.id=F++,this.manager=null,this.options.enable=k(this.options.enable,!0),this.state=1,this.simultaneous={},this.requireFail=[]}function Pe(e){return 16&e?"cancel":8&e?"end":4&e?"move":2&e?"start":""}function De(e){return 16==e?"down":8==e?"up":2==e?"left":4==e?"right":""}function Ie(e,t){var r=t.manager;return r?r.get(e):e}function Fe(){xe.apply(this,arguments)}function Oe(){Fe.apply(this,arguments),this.pX=null,this.pY=null}function Le(){Fe.apply(this,arguments)}function Ve(){xe.apply(this,arguments),this._timer=null,this._input=null}function Ne(){Fe.apply(this,arguments)}function Be(){Fe.apply(this,arguments)}function Ue(){xe.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function Ze(e,t){return(t=t||{}).recognizers=k(t.recognizers,Ze.defaults.preset),new Ge(e,t)}function Ge(e,t){this.options=u({},Ze.defaults,t||{}),this.options.inputTarget=this.options.inputTarget||e,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new(this.options.inputClass||(V?ae:N?fe:L?pe:ee))(this,j),this.touchAction=new we(this,this.options.touchAction),We(this,!0),m(this.options.recognizers,(function(e){var t=this.add(new e[0](e[1]));e[2]&&t.recognizeWith(e[2]),e[3]&&t.requireFailure(e[3])}),this)}function We(e,t){var r,i=e.element;i.style&&(m(e.options.cssProps,(function(n,a){r=I(i.style,a),t?(e.oldCssProps[r]=i.style[r],i.style[r]=n):i.style[r]=e.oldCssProps[r]||""})),t||(e.oldCssProps={}))}xe.prototype={defaults:{},set:function(e){return u(this.options,e),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(e){if(g(e,"recognizeWith",this))return this;var t=this.simultaneous;return t[(e=Ie(e,this)).id]||(t[e.id]=e,e.recognizeWith(this)),this},dropRecognizeWith:function(e){return g(e,"dropRecognizeWith",this)||(e=Ie(e,this),delete this.simultaneous[e.id]),this},requireFailure:function(e){if(g(e,"requireFailure",this))return this;var t=this.requireFail;return-1===x(t,e=Ie(e,this))&&(t.push(e),e.requireFailure(this)),this},dropRequireFailure:function(e){if(g(e,"dropRequireFailure",this))return this;e=Ie(e,this);var t=x(this.requireFail,e);return t>-1&&this.requireFail.splice(t,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(e){return!!this.simultaneous[e.id]},emit:function(e){var t=this,r=this.state;function i(r){t.manager.emit(r,e)}r<8&&i(t.options.event+Pe(r)),i(t.options.event),e.additionalEvent&&i(e.additionalEvent),r>=8&&i(t.options.event+Pe(r))},tryEmit:function(e){if(this.canEmit())return this.emit(e);this.state=Re},canEmit:function(){for(var e=0;e<this.requireFail.length;){if(!(33&this.requireFail[e].state))return!1;e++}return!0},recognize:function(e){var t=u({},e);if(!S(this.options.enable,[this,t]))return this.reset(),void(this.state=Re);56&this.state&&(this.state=1),this.state=this.process(t),30&this.state&&this.tryEmit(t)},process:function(e){},getTouchAction:function(){},reset:function(){}},T(Fe,xe,{defaults:{pointers:1},attrTest:function(e){var t=this.options.pointers;return 0===t||e.pointers.length===t},process:function(e){var t=this.state,r=e.eventType,i=6&t,n=this.attrTest(e);return i&&(8&r||!n)?16|t:i||n?4&r?8|t:2&t?4|t:2:Re}}),T(Oe,Fe,{defaults:{event:"pan",threshold:10,pointers:1,direction:30},getTouchAction:function(){var e=this.options.direction,t=[];return 6&e&&t.push(Ae),24&e&&t.push(Ee),t},directionTest:function(e){var t=this.options,r=!0,i=e.distance,n=e.direction,a=e.deltaX,s=e.deltaY;return n&t.direction||(6&t.direction?(n=0===a?1:a<0?2:4,r=a!=this.pX,i=Math.abs(e.deltaX)):(n=0===s?1:s<0?8:16,r=s!=this.pY,i=Math.abs(e.deltaY))),e.direction=n,r&&i>t.threshold&&n&t.direction},attrTest:function(e){return Fe.prototype.attrTest.call(this,e)&&(2&this.state||!(2&this.state)&&this.directionTest(e))},emit:function(e){this.pX=e.deltaX,this.pY=e.deltaY;var t=De(e.direction);t&&(e.additionalEvent=this.options.event+t),this._super.emit.call(this,e)}}),T(Le,Fe,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[ke]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.scale-1)>this.options.threshold||2&this.state)},emit:function(e){if(1!==e.scale){var t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}this._super.emit.call(this,e)}}),T(Ve,xe,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[Me]},process:function(e){var t=this.options,r=e.pointers.length===t.pointers,i=e.distance<t.threshold,n=e.deltaTime>t.time;if(this._input=e,!i||!r||12&e.eventType&&!n)this.reset();else if(1&e.eventType)this.reset(),this._timer=p((function(){this.state=8,this.tryEmit()}),t.time,this);else if(4&e.eventType)return 8;return Re},reset:function(){clearTimeout(this._timer)},emit:function(e){8===this.state&&(e&&4&e.eventType?this.manager.emit(this.options.event+"up",e):(this._input.timeStamp=_(),this.manager.emit(this.options.event,this._input)))}}),T(Ne,Fe,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[ke]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.rotation)>this.options.threshold||2&this.state)}}),T(Be,Fe,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return Oe.prototype.getTouchAction.call(this)},attrTest:function(e){var t,r=this.options.direction;return 30&r?t=e.overallVelocity:6&r?t=e.overallVelocityX:24&r&&(t=e.overallVelocityY),this._super.attrTest.call(this,e)&&r&e.offsetDirection&&e.distance>this.options.threshold&&e.maxPointers==this.options.pointers&&f(t)>this.options.velocity&&4&e.eventType},emit:function(e){var t=De(e.offsetDirection);t&&this.manager.emit(this.options.event+t,e),this.manager.emit(this.options.event,e)}}),T(Ue,xe,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Se]},process:function(e){var t=this.options,r=e.pointers.length===t.pointers,i=e.distance<t.threshold,n=e.deltaTime<t.time;if(this.reset(),1&e.eventType&&0===this.count)return this.failTimeout();if(i&&n&&r){if(4!=e.eventType)return this.failTimeout();var a=!this.pTime||e.timeStamp-this.pTime<t.interval,s=!this.pCenter||Y(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,s&&a?this.count+=1:this.count=1,this._input=e,0==this.count%t.taps)return this.hasRequireFailures()?(this._timer=p((function(){this.state=8,this.tryEmit()}),t.interval,this),2):8}return Re},failTimeout:function(){return this._timer=p((function(){this.state=Re}),this.options.interval,this),Re},reset:function(){clearTimeout(this._timer)},emit:function(){8==this.state&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),Ze.VERSION="2.0.7",Ze.defaults={domEvents:!1,touchAction:Te,enable:!0,inputTarget:null,inputClass:null,preset:[[Ne,{enable:!1}],[Le,{enable:!1},["rotate"]],[Be,{direction:6}],[Oe,{direction:6},["swipe"]],[Ue],[Ue,{event:"doubletap",taps:2},["tap"]],[Ve]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}},Ge.prototype={set:function(e){return u(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this},stop:function(e){this.session.stopped=e?2:1},recognize:function(e){var t=this.session;if(!t.stopped){var r;this.touchAction.preventDefaults(e);var i=this.recognizers,n=t.curRecognizer;(!n||n&&8&n.state)&&(n=t.curRecognizer=null);for(var a=0;a<i.length;)r=i[a],2===t.stopped||n&&r!=n&&!r.canRecognizeWith(n)?r.reset():r.recognize(e),!n&&14&r.state&&(n=t.curRecognizer=r),a++}},get:function(e){if(e instanceof xe)return e;for(var t=this.recognizers,r=0;r<t.length;r++)if(t[r].options.event==e)return t[r];return null},add:function(e){if(g(e,"add",this))return this;var t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e},remove:function(e){if(g(e,"remove",this))return this;if(e=this.get(e)){var t=this.recognizers,r=x(t,e);-1!==r&&(t.splice(r,1),this.touchAction.update())}return this},on:function(e,t){if(e!==l&&t!==l){var r=this.handlers;return m(R(e),(function(e){r[e]=r[e]||[],r[e].push(t)})),this}},off:function(e,t){if(e!==l){var r=this.handlers;return m(R(e),(function(e){t?r[e]&&r[e].splice(x(r[e],t),1):delete r[e]})),this}},emit:function(e,t){this.options.domEvents&&function(e,t){var r=s.createEvent("Event");r.initEvent(e,!0,!0),r.gesture=t,t.target.dispatchEvent(r)}(e,t);var r=this.handlers[e]&&this.handlers[e].slice();if(r&&r.length){t.type=e,t.preventDefault=function(){t.srcEvent.preventDefault()};for(var i=0;i<r.length;)r[i](t),i++}},destroy:function(){this.element&&We(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},u(Ze,{INPUT_START:1,INPUT_MOVE:2,INPUT_END:4,INPUT_CANCEL:8,STATE_POSSIBLE:1,STATE_BEGAN:2,STATE_CHANGED:4,STATE_ENDED:8,STATE_RECOGNIZED:8,STATE_CANCELLED:16,STATE_FAILED:Re,DIRECTION_NONE:1,DIRECTION_LEFT:2,DIRECTION_RIGHT:4,DIRECTION_UP:8,DIRECTION_DOWN:16,DIRECTION_HORIZONTAL:6,DIRECTION_VERTICAL:24,DIRECTION_ALL:30,Manager:Ge,Input:W,TouchAction:we,TouchInput:fe,MouseInput:ee,PointerEventInput:ae,TouchMouseInput:pe,SingleTouchInput:ue,Recognizer:xe,AttrRecognizer:Fe,Tap:Ue,Pan:Oe,Swipe:Be,Pinch:Le,Rotate:Ne,Press:Ve,on:E,off:A,each:m,merge:b,extend:y,assign:u,inherit:T,bindFn:M,prefixed:I}),(void 0!==a?a:"undefined"!=typeof self?self:{}).Hammer=Ze,(i=function(){return Ze}.call(t,r,t,e))===l||(e.exports=i)}(window,document)},88:(module,exports,__webpack_require__)=>{var __WEBPACK_AMD_DEFINE_FACTORY__,__WEBPACK_AMD_DEFINE_ARRAY__,__WEBPACK_AMD_DEFINE_RESULT__,factory;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)}module=__webpack_require__.nmd(module),window,factory=function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===_typeof(e)&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="./src/yagui.js")}({"./src/GuiMain.js":function srcGuiMainJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var containers_Sidebar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! containers/Sidebar */ \"./src/containers/Sidebar.js\");\n/* harmony import */ var containers_Topbar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! containers/Topbar */ \"./src/containers/Topbar.js\");\n\n\n\nclass GuiMain {\n\n constructor(viewport, callbackResize) {\n this.domMain = document.createElement('div');\n this.viewport = viewport;\n\n this.callbackResize = callbackResize;\n if (this.viewport) {\n this.viewport.style.width = document.documentElement.clientWidth + 'px';\n this.viewport.style.height = document.documentElement.clientHeight + 'px';\n }\n this.cbResize_ = this._onWindowResize.bind(this);\n\n document.body.appendChild(this.domMain);\n this.leftSidebar = undefined;\n this.rightSidebar = undefined;\n this.topbar = undefined;\n\n window.addEventListener('resize', this._onWindowResize.bind(this), false);\n }\n\n _onWindowResize() {\n if (this.viewport) {\n this.viewport.style.width = document.documentElement.clientWidth + 'px';\n this.viewport.style.height = document.documentElement.clientHeight + 'px';\n this.viewport.style.left = '0px';\n this.viewport.style.top = '0px';\n if (this.leftSidebar)\n this.leftSidebar._updateViewportPosition(this.viewport);\n if (this.rightSidebar)\n this.rightSidebar._updateViewportPosition(this.viewport);\n if (this.topbar)\n this.topbar._updateViewportPosition(this.viewport);\n }\n this._updateSidebarsPosition();\n if (this.callbackResize)\n this.callbackResize();\n }\n\n _updateSidebarsPosition() {\n if (!this.topbar) return;\n var off = this.topbar.domTopbar.offsetHeight;\n if (this.leftSidebar)\n this.leftSidebar._setTop(off);\n if (this.rightSidebar)\n this.rightSidebar._setTop(off);\n }\n\n addLeftSidebar() {\n this.leftSidebar = new containers_Sidebar__WEBPACK_IMPORTED_MODULE_0__[\"default\"](this.cbResize_);\n var domSide = this.leftSidebar.domSidebar;\n this.domMain.appendChild(domSide);\n this.domMain.appendChild(this.leftSidebar.domResize);\n\n this._updateSidebarsPosition();\n this.leftSidebar._updateViewportPosition(this.viewport);\n return this.leftSidebar;\n }\n\n addRightSidebar() {\n this.rightSidebar = new containers_Sidebar__WEBPACK_IMPORTED_MODULE_0__[\"default\"](this.cbResize_);\n var domSide = this.rightSidebar.domSidebar;\n this.domMain.appendChild(domSide);\n this.domMain.appendChild(this.rightSidebar.domResize);\n\n this.rightSidebar._onTheRight();\n this._updateSidebarsPosition();\n this.rightSidebar._updateViewportPosition(this.viewport);\n return this.rightSidebar;\n }\n\n addTopbar() {\n this.topbar = new containers_Topbar__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this.cbResize_);\n this.domMain.appendChild(this.topbar.domTopbar);\n\n this._updateSidebarsPosition();\n this.topbar._updateViewportPosition(this.viewport);\n return this.topbar;\n }\n\n setVisibility(visible) {\n this.domMain.hidden = !visible;\n this._onWindowResize();\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (GuiMain);\n\n\n//# sourceURL=webpack://yagui/./src/GuiMain.js?")},"./src/containers/BaseContainer.js":function srcContainersBaseContainerJs(module,__webpack_exports__,__webpack_require__){"use strict";eval('__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var widgets_Button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! widgets/Button */ "./src/widgets/Button.js");\n/* harmony import */ var widgets_Checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! widgets/Checkbox */ "./src/widgets/Checkbox.js");\n/* harmony import */ var widgets_Color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! widgets/Color */ "./src/widgets/Color.js");\n/* harmony import */ var widgets_Combobox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! widgets/Combobox */ "./src/widgets/Combobox.js");\n/* harmony import */ var widgets_Slider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! widgets/Slider */ "./src/widgets/Slider.js");\n/* harmony import */ var widgets_Title__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! widgets/Title */ "./src/widgets/Title.js");\n\n\n\n\n\n\n\n// label : 36%\n// slider : bar 52% + margin 2% + input 10%\n// combobox : 64%\n// color : 64%\nclass BaseContainer {\n\n constructor() {}\n\n _addLine(name) {\n var domLine = document.createElement(\'li\');\n domLine.innerHTML = name || \'\';\n this.domUl.appendChild(domLine);\n return domLine;\n }\n\n _createLabel(name) {\n var domLabel = document.createElement(\'label\');\n domLabel.className = \'gui-label-side\';\n domLabel.innerHTML = name || \'\';\n return domLabel;\n }\n\n _setDomContainer(container) {\n this.domContainer = container;\n }\n\n addTitle(name) {\n var widget = new widgets_Title__WEBPACK_IMPORTED_MODULE_5__["default"](name);\n this.domUl.appendChild(widget.domText);\n return widget;\n }\n\n addCheckbox(name, valOrObject, callbackOrKey) {\n var widget = new widgets_Checkbox__WEBPACK_IMPORTED_MODULE_1__["default"](valOrObject, callbackOrKey);\n var domLine = this._addLine();\n domLine.className += \' gui-pointerOnHover gui-glowOnHover\';\n var domLabel = this._createLabel(name);\n domLabel.style.overflow = \'visible\';\n domLabel.className += \' gui-pointerOnHover\';\n domLine.appendChild(domLabel);\n domLine.appendChild(widget.domCheckbox);\n domLine.appendChild(widget.domLabelCheckbox);\n domLine.addEventListener(\'mousedown\', widget._onMouseDown.bind(widget));\n widget._setDomContainer(domLine);\n return widget;\n }\n\n addCombobox(name, valOrObject, callbackOrKey, options) {\n var widget = new widgets_Combobox__WEBPACK_IMPORTED_MODULE_3__["default"](valOrObject, callbackOrKey, options);\n var domLine = this._addLine();\n if (name) domLine.appendChild(this._createLabel(name));\n else widget.domSelect.style.width = \'100%\';\n domLine.appendChild(widget.domSelect);\n widget._setDomContainer(domLine);\n return widget;\n }\n\n addSlider(name, valOrObject, callbackOrKey, min, max, step) {\n var widget = new widgets_Slider__WEBPACK_IMPORTED_MODULE_4__["default"](valOrObject, callbackOrKey, min, max, step);\n var domLine = this._addLine();\n if (name) domLine.appendChild(this._createLabel(name));\n domLine.appendChild(widget.domInputText);\n domLine.appendChild(widget.domSlider);\n widget._setDomContainer(domLine);\n return widget;\n }\n\n addColor(name, valOrObject, callbackOrKey) {\n var widget = new widgets_Color__WEBPACK_IMPORTED_MODULE_2__["default"](valOrObject, callbackOrKey);\n var domLine = this._addLine();\n if (name) domLine.appendChild(this._createLabel(name));\n else widget.domColor.style.width = \'100%\';\n domLine.appendChild(widget.domColor);\n widget._setDomContainer(domLine);\n return widget;\n }\n\n addButton(name, callbackOrObject, key) {\n var widget = new widgets_Button__WEBPACK_IMPORTED_MODULE_0__["default"](name, callbackOrObject, key);\n var domLine = this._addLine();\n domLine.appendChild(widget.domButton);\n widget._setDomContainer(domLine);\n return widget;\n }\n\n addDualButton(name1, name2, callbackOrObject1, callbackOrObject2, key1, key2) {\n var widget1 = new widgets_Button__WEBPACK_IMPORTED_MODULE_0__["default"](name1, callbackOrObject1, key1);\n var widget2 = new widgets_Button__WEBPACK_IMPORTED_MODULE_0__["default"](name2, callbackOrObject2, key2);\n var domLine = this._addLine();\n domLine.appendChild(widget2.domButton);\n domLine.appendChild(widget1.domButton);\n var style1 = widget1.domButton.style;\n var style2 = widget2.domButton.style;\n style1.width = style2.width = \'49%\';\n style1.marginRight = style2.marginLeft = \'1%\';\n widget1._setDomContainer(domLine);\n widget2._setDomContainer(domLine);\n return [widget1, widget2];\n }\n\n setVisibility(visible) {\n if (!this.domContainer) return;\n this.domContainer.hidden = !visible;\n }\n}\n\n/* harmony default export */ __webpack_exports__["default"] = (BaseContainer);\n\n\n//# sourceURL=webpack://yagui/./src/containers/BaseContainer.js?')},"./src/containers/Folder.js":function srcContainersFolderJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var containers_BaseContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! containers/BaseContainer */ \"./src/containers/BaseContainer.js\");\n\n\nclass Folder extends containers_BaseContainer__WEBPACK_IMPORTED_MODULE_0__[\"default\"] {\n\n constructor(name) {\n super();\n\n this.domUl = document.createElement('ul');\n this.domUl.setAttribute('opened', true);\n\n var domTitle = document.createElement('label');\n domTitle.innerHTML = name || '';\n\n domTitle.addEventListener('mousedown', this._onMouseDown.bind(this));\n\n this.domUl.appendChild(domTitle);\n this.isOpen = true;\n }\n\n _onMouseDown() {\n this.isOpen = !this.isOpen;\n this.domUl.setAttribute('opened', this.isOpen);\n }\n\n open() {\n this.isOpen = true;\n this.domUl.setAttribute('opened', true);\n }\n\n close() {\n this.isOpen = false;\n this.domUl.setAttribute('opened', false);\n }\n\n setVisibility(visible) {\n if (!visible) this.domUl.setAttribute('opened', false);\n else if (this.isOpen) this.domUl.setAttribute('opened', true);\n this.domUl.style.height = visible ? 'auto' : '0px';\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Folder);\n\n\n//# sourceURL=webpack://yagui/./src/containers/Folder.js?")},"./src/containers/Menu.js":function srcContainersMenuJs(module,__webpack_exports__,__webpack_require__){"use strict";eval('__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var containers_BaseContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! containers/BaseContainer */ "./src/containers/BaseContainer.js");\n/* harmony import */ var widgets_MenuButton__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! widgets/MenuButton */ "./src/widgets/MenuButton.js");\n\n\n\nclass Menu extends containers_BaseContainer__WEBPACK_IMPORTED_MODULE_0__["default"] {\n\n constructor() {\n super();\n\n this.domUl = document.createElement(\'ul\');\n }\n\n addButton(name, callbackOrObject, shortcutOrKey, shortcut) {\n var widget = new widgets_MenuButton__WEBPACK_IMPORTED_MODULE_1__["default"](callbackOrObject, shortcutOrKey, shortcut);\n var domLine = this._addLine(name);\n domLine.appendChild(widget.domSpan);\n widget._setDomContainer(domLine);\n return widget;\n }\n\n addSlider(name, valOrObject, callbackOrKey, min, max, step) {\n var wid = super.addSlider(name, valOrObject, callbackOrKey, min, max, step);\n // label 36% + slider ?% + 2% + input 18%\n wid.domInputText.style.width = \'18%\';\n wid.domSlider.style.width = name ? \'44%\' : \'80%\';\n return wid;\n }\n}\n\n/* harmony default export */ __webpack_exports__["default"] = (Menu);\n\n\n//# sourceURL=webpack://yagui/./src/containers/Menu.js?')},"./src/containers/Sidebar.js":function srcContainersSidebarJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var containers_Folder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! containers/Folder */ \"./src/containers/Folder.js\");\n\n\nclass Sidebar {\n\n constructor(callbackResize) {\n this.domSidebar = document.createElement('div');\n this.domSidebar.className = 'gui-sidebar';\n\n this.domResize = document.createElement('div');\n this.domResize.className = 'gui-resize';\n\n this.isDragging = false;\n this.mouseX = 0;\n this.domResize.addEventListener('mousedown', this._onMouseDown.bind(this));\n window.addEventListener('mousemove', this._onMouseMove.bind(this));\n window.addEventListener('mouseup', this._onMouseUp.bind(this));\n\n this.callbackResize = callbackResize;\n this.isOnTheRight = false;\n }\n\n _setTop(nb) {\n this.domSidebar.style.top = this.domResize.style.top = nb + 'px';\n }\n\n _onTheRight() {\n this.isOnTheRight = true;\n this.domSidebar.style.right = 0;\n this.domSidebar.style.borderRight = 0;\n this.domSidebar.style.borderLeft = 'double';\n this.domSidebar.style.borderColor = 'rgba(255,255,255,0.3)';\n this.domResize.style.left = 'auto';\n this.domResize.style.right = this.domSidebar.offsetWidth + 'px';\n this.domResize.style.marginRight = '-3px';\n }\n\n _onMouseDown(ev) {\n this.isDragging = true;\n this.mouseX = ev.clientX;\n }\n\n _updateViewportPosition(viewport) {\n var w = this.domSidebar.hidden ? 0 : this.domSidebar.offsetWidth;\n if (this.isOnTheRight) {\n viewport.style.width = (viewport.clientWidth - w) + 'px';\n } else {\n viewport.style.left = (this.domSidebar.offsetLeft + w) + 'px';\n viewport.style.width = (viewport.clientWidth - w) + 'px';\n }\n }\n\n _onMouseMove(ev) {\n if (this.isDragging === false) return;\n var mouseX = ev.clientX;\n var delta = mouseX - this.mouseX;\n if (this.isOnTheRight) delta = -delta;\n var widthBar = Math.max(50, this.domSidebar.offsetWidth + delta);\n\n var val = widthBar + 'px';\n this.domSidebar.style.width = val;\n if (this.isOnTheRight) this.domResize.style.right = this.domSidebar.offsetWidth + 'px';\n else this.domResize.style.left = val;\n\n this.mouseX = mouseX;\n this.callbackResize();\n }\n\n _onMouseUp() {\n this.isDragging = false;\n }\n\n addMenu(name) {\n var folder = new containers_Folder__WEBPACK_IMPORTED_MODULE_0__[\"default\"](name);\n this.domSidebar.appendChild(folder.domUl);\n return folder;\n }\n\n setVisibility(visible) {\n this.domSidebar.hidden = !visible;\n this.domResize.hidden = !visible;\n this.callbackResize();\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Sidebar);\n\n\n//# sourceURL=webpack://yagui/./src/containers/Sidebar.js?")},"./src/containers/Topbar.js":function srcContainersTopbarJs(module,__webpack_exports__,__webpack_require__){"use strict";eval('__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var containers_Menu__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! containers/Menu */ "./src/containers/Menu.js");\n/* harmony import */ var utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! utils/EditStyle */ "./src/utils/EditStyle.js");\n\n\n\nclass Topbar {\n\n constructor(callbackResize) {\n this.domTopbar = document.createElement(\'div\');\n this.domTopbar.className = \'gui-topbar\';\n\n this.domUl = document.createElement(\'ul\');\n this.domTopbar.appendChild(this.domUl);\n\n this.callbackResize = callbackResize;\n this.uiExtra = {};\n }\n\n _updateViewportPosition(viewport) {\n var h = this.domTopbar.hidden ? 0 : this.domTopbar.offsetHeight;\n viewport.style.top = h + \'px\';\n viewport.style.height = (viewport.clientHeight - h) + \'px\';\n }\n\n _onChangeColor(callback, color) {\n callback(color);\n this.uiExtra.overallColor.setValue(utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"]._curWidgetColor, true);\n this.uiExtra.widgetColor.setValue(utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"]._curWidgetColor, true);\n this.uiExtra.backColor.setValue(utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"]._curBackgroundColor, true);\n this.uiExtra.textColor.setValue(utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"]._curTextColor, true);\n }\n\n addMenu(name) {\n var menu = new containers_Menu__WEBPACK_IMPORTED_MODULE_0__["default"]();\n var li = document.createElement(\'li\');\n li.setAttribute(\'onclick\', \'void(0)\'); // iOS trick to trigger click on hover\n li.innerHTML = name || \'\';\n this.domUl.appendChild(li);\n li.appendChild(menu.domUl);\n menu._setDomContainer(li);\n return menu;\n }\n\n addExtra() {\n var cb = this._onChangeColor;\n var menu = this.addMenu(\'Extra UI\');\n var ext = this.uiExtra;\n menu.addTitle(\'Overall\');\n ext.overallColor = menu.addColor(\'\', utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"]._curWidgetColor, cb.bind(this, utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"].changeOverallColor));\n\n menu.addTitle(\'Advanced\');\n ext.widgetColor = menu.addColor(\'Widget\', utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"]._curWidgetColor, cb.bind(this, utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"].changeWidgetsColor));\n ext.backColor = menu.addColor(\'Back\', utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"]._curBackgroundColor, cb.bind(this, utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"].changeBackgroundColor));\n ext.textColor = menu.addColor(\'Text\', utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"]._curTextColor, cb.bind(this, utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"].changeTextColor));\n ext.showBorder = menu.addCheckbox(\'Border\', utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"]._curShowBorder, utils_EditStyle__WEBPACK_IMPORTED_MODULE_1__["default"].changeDisplayBoorder);\n return menu;\n }\n\n setVisibility(visible) {\n this.domTopbar.hidden = !visible;\n this.callbackResize();\n }\n}\n\n/* harmony default export */ __webpack_exports__["default"] = (Topbar);\n\n\n//# sourceURL=webpack://yagui/./src/containers/Topbar.js?')},"./src/utils/EditStyle.js":function srcUtilsEditStyleJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! utils/GuiUtils */ \"./src/utils/GuiUtils.js\");\n\n\nvar EditStyle = {};\n\nEditStyle.refRules = {};\n\nvar yaguiSheet;\nvar findSheet = function () {\n if (yaguiSheet) return yaguiSheet;\n var sheets = document.styleSheets;\n for (var i = 0, nb = sheets.length; i < nb; ++i) {\n var href = sheets[i].href;\n if (href && href.indexOf('yagui.css') !== -1) {\n yaguiSheet = sheets[i];\n return yaguiSheet;\n }\n }\n return;\n};\n\nvar editStyle = function (selector, key, value) {\n var sheet = findSheet();\n if (!sheet)\n return;\n var rules = sheet.cssRules || sheet.rules;\n var rule = EditStyle.refRules[selector];\n if (!rule) {\n var i = 0;\n var len = rules.length;\n for (i = 0; i < len; ++i) {\n if (rules[i].selectorText === selector) break;\n }\n if (i === len) return false;\n rule = EditStyle.refRules[selector] = rules[i];\n }\n if (rule)\n rule.style[key] = value;\n};\n\nEditStyle.changeWidgetsColor = function (color) {\n var str = utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getStrColor(color);\n // button\n editStyle('.gui-button', 'background', str);\n // select\n editStyle('.gui-select', 'background', str);\n // slider\n editStyle('.gui-slider > div', 'background', str);\n EditStyle._curWidgetColor = color;\n};\n\nEditStyle.changeDisplayBoorder = function (bool) {\n var str = bool ? '1px solid #000' : '0';\n editStyle('.gui-button', 'border', str);\n // select\n editStyle('.gui-select', 'border', str);\n // slider\n editStyle('.gui-slider', 'border', str);\n editStyle('.gui-input-number', 'border', str);\n // folder\n editStyle('.gui-sidebar > ul > label', 'borderTop', str);\n editStyle('.gui-sidebar > ul > label', 'borderBottom', str);\n // side bar\n editStyle('.gui-sidebar', 'borderLeft', str);\n editStyle('.gui-sidebar', 'borderRight', str);\n // top bar\n editStyle('.gui-topbar', 'borderBottom', str);\n EditStyle._curShowBorder = bool;\n};\n\nEditStyle.changeBackgroundColor = function (color) {\n // side bar\n editStyle('.gui-sidebar', 'background', utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getStrColor(color));\n // top bar\n var colTop = utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getStrColor(utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getColorMult(color, 0.5));\n editStyle('.gui-topbar', 'background', colTop);\n editStyle('.gui-topbar ul > li > ul', 'background', colTop);\n EditStyle._curBackgroundColor = color;\n};\n\nEditStyle.changeTextColor = function (color) {\n var strColor = utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getStrColor(color);\n editStyle('*', 'color', strColor);\n editStyle('.gui-sidebar > ul > label', 'color', strColor);\n EditStyle._curTextColor = color;\n};\n\nEditStyle.changeOverallColor = function (color) {\n EditStyle.changeWidgetsColor(color);\n var bgCol = utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getColorMult(color, 0.5);\n bgCol.length = 3;\n EditStyle.changeBackgroundColor(bgCol);\n\n var texCol = utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getColorAdd(color, 0.5);\n for (var i = 0; i < 3; ++i) texCol[i] = Math.min(0.8, texCol[i]);\n EditStyle.changeTextColor(texCol);\n\n EditStyle._curWidgetColor = color;\n EditStyle._curBackgroundColor = bgCol;\n EditStyle._curTextColor = texCol;\n};\n\n// init value\nEditStyle._curTextColor = [0.73, 0.73, 0.73, 1.0];\nEditStyle._curWidgetColor = [0.32, 0.37, 0.39, 1.0];\nEditStyle._curBackgroundColor = [0.24, 0.24, 0.24];\nEditStyle._curShowBorder = false;\n\nEditStyle.changeOverallColor([0.3, 0.34, 0.4, 1.0]);\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (EditStyle);\n\n\n//# sourceURL=webpack://yagui/./src/utils/EditStyle.js?")},"./src/utils/GuiUtils.js":function srcUtilsGuiUtilsJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\nvar GuiUtils = {};\n\nGuiUtils.rgbToHsv = function (rgb) {\n var r = rgb[0];\n var g = rgb[1];\n var b = rgb[2];\n var maxRGB = Math.max(r, g, b);\n var minRGB = Math.min(r, g, b);\n if (minRGB === maxRGB) return [0, 0, minRGB];\n var d = (r === minRGB) ? g - b : ((b === minRGB) ? r - g : b - r);\n var h = (r === minRGB) ? 3 : ((b === minRGB) ? 1 : 5);\n return [(h - d / (maxRGB - minRGB)) / 6, (maxRGB - minRGB) / maxRGB, maxRGB];\n};\n\nGuiUtils.hsvToRgb = function (hsv) {\n var h = hsv[0] * 6;\n var s = hsv[1];\n var v = hsv[2];\n var i = Math.floor(h);\n var f = h - i;\n var p = v * (1.0 - s);\n var q = v * (1.0 - f * s);\n var t = v * (1.0 - (1.0 - f) * s);\n var mod = i % 6;\n if (mod === 0) return [v, t, p];\n else if (mod === 1) return [q, v, p];\n else if (mod === 2) return [p, v, t];\n else if (mod === 3) return [p, q, v];\n else if (mod === 4) return [t, p, v];\n else return [v, p, q];\n};\n\nGuiUtils.getValidColor = function (color) {\n for (var i = 0, len = color.length; i < len; ++i) color[i] = Math.max(0.0, Math.min(1.0, color[i]));\n return color;\n};\n\nGuiUtils.getStrColor = function (color) {\n if (color.length === 3) return GuiUtils.rgbToHex(color);\n return 'rgba(' + Math.round(color[0] * 255) + ',' + Math.round(color[1] * 255) + ',' + Math.round(color[2] * 255) + ',' + color[3] + ')';\n};\n\nGuiUtils.getColorMult = function (color, fac) {\n var out = [color[0] * fac, color[1] * fac, color[2] * fac];\n if (color.length === 4) out.push(color[3]);\n return GuiUtils.getValidColor(out);\n};\n\nGuiUtils.getColorAdd = function (color, add) {\n var out = [color[0] + add, color[1] + add, color[2] + add];\n if (color.length === 4) out.push(color[3]);\n return GuiUtils.getValidColor(out);\n};\n\nGuiUtils.rgbToHex = function (rgb) {\n var h = '#';\n for (var i = 0; i < 3; ++i) {\n var c = Math.round(rgb[i] * 255).toString(16);\n h += c.length === 1 ? '0' + c : c;\n }\n return h;\n};\n\nGuiUtils.hexToRgb = function (hex) {\n var i = 0;\n if (hex[0] === '#') hex = hex.slice(1);\n var h = hex;\n if (hex.length > 6) h = hex.slice(0, 6);\n else if (hex.length < 6) {\n h = '';\n for (i = 0; i < 3; ++i)\n h += hex[i] ? hex[i] + hex[i] : '00';\n }\n var col = [0, 0, 0];\n for (i = 0; i < 3; ++i) {\n var c = parseInt(h[i * 2] + h[i * 2 + 1], 16);\n col[i] = (c !== c ? 0 : c) / 255;\n }\n return col;\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (GuiUtils);\n\n\n//# sourceURL=webpack://yagui/./src/utils/GuiUtils.js?")},"./src/widgets/BaseWidget.js":function srcWidgetsBaseWidgetJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\nclass BaseWidget {\n\n constructor() {}\n\n _getInitialValue(valOrObject, callbackOrKey) {\n if (typeof callbackOrKey !== 'string') return valOrObject;\n return valOrObject[callbackOrKey];\n }\n\n _getCheckCallback(valOrObject, callbackOrKey) {\n if (typeof callbackOrKey !== 'string') return callbackOrKey;\n return function (val) {\n valOrObject[callbackOrKey] = val;\n };\n }\n\n _setDomContainer(container) {\n this.domContainer = container;\n }\n\n setCallback(callback) {\n this.callback = callback;\n }\n\n setVisibility(visible) {\n if (!this.domContainer) return;\n this.domContainer.hidden = !visible;\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (BaseWidget);\n\n\n//# sourceURL=webpack://yagui/./src/widgets/BaseWidget.js?")},"./src/widgets/Button.js":function srcWidgetsButtonJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! widgets/BaseWidget */ \"./src/widgets/BaseWidget.js\");\n\n\nclass Button extends widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__[\"default\"] {\n\n constructor(name, callbackOrObject, key) {\n super();\n\n var callback = key ? callbackOrObject[key].bind(callbackOrObject) : callbackOrObject;\n\n this.domButton = document.createElement('button');\n this.domButton.className = 'gui-button';\n this.domButton.innerHTML = name || '';\n this.domButton.addEventListener('click', this._onClick.bind(this));\n\n this.setCallback(callback);\n }\n\n setEnable(bool) {\n this.domButton.disabled = bool === undefined ? false : !bool;\n }\n\n _onClick() {\n if (this.callback) this.callback();\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Button);\n\n\n//# sourceURL=webpack://yagui/./src/widgets/Button.js?")},"./src/widgets/Checkbox.js":function srcWidgetsCheckboxJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! widgets/BaseWidget */ \"./src/widgets/BaseWidget.js\");\n\n\nclass Checkbox extends widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__[\"default\"] {\n\n constructor(valOrObject, callbackOrKey) {\n super();\n\n var value = this._getInitialValue(valOrObject, callbackOrKey);\n var callback = this._getCheckCallback(valOrObject, callbackOrKey);\n this.domCheckbox = document.createElement('input');\n this.domCheckbox.className = 'gui-input-checkbox';\n this.domCheckbox.type = 'checkbox';\n\n this.domLabelCheckbox = document.createElement('label');\n\n this.setValue(value === undefined ? true : value);\n this.setCallback(callback);\n }\n\n _onMouseDown() {\n this.setValue(!this.domCheckbox.checked);\n }\n\n setValue(val, ignoreCB) {\n this.domCheckbox.checked = val;\n if (!ignoreCB && this.callback) this.callback(val);\n }\n\n getValue() {\n return this.domCheckbox.checked;\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Checkbox);\n\n\n//# sourceURL=webpack://yagui/./src/widgets/Checkbox.js?")},"./src/widgets/Color.js":function srcWidgetsColorJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! utils/GuiUtils */ \"./src/utils/GuiUtils.js\");\n/* harmony import */ var widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! widgets/BaseWidget */ \"./src/widgets/BaseWidget.js\");\n\n\n\nvar vendors = ['-moz-', '-o-', '-webkit-', '-ms-', ''];\nvar urlAlpha = 'url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAChJREFUeNpiPHPmDAMMGBsbw9lMDDgA6RKM%2F%2F%2F%2Fh3POnj1LCzsAAgwAQtYIcFfEyzkAAAAASUVORK5CYII%3D\")';\n\nclass Color extends widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_1__[\"default\"] {\n\n constructor(valOrObject, callbackOrKey) {\n super();\n\n var value = this._getInitialValue(valOrObject, callbackOrKey);\n var callback = this._getCheckCallback(valOrObject, callbackOrKey);\n if (value) this.color = utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getValidColor(value.slice());\n else this.color = [1.0, 0.0, 0.0];\n\n // container\n this.domColor = document.createElement('div');\n this.domColor.className = 'gui-widget-color';\n\n // input text\n this.domInputColor = document.createElement('input');\n this.domPopup = document.createElement('div');\n\n // hue picker\n this.domHue = document.createElement('div');\n this.domHue.className = 'gui-color-hue';\n this.domHueKnob = document.createElement('div');\n this.domHueKnob.className = 'gui-knob-hue';\n\n // saturation picker\n this.domSaturation = document.createElement('div');\n this.domSaturation.className = 'gui-color-saturation';\n var zAlphaSat = document.createElement('div');\n this.domSaturation.appendChild(zAlphaSat);\n this.domSaturationKnob = document.createElement('div');\n this.domSaturationKnob.className = 'gui-knob-saturation';\n\n this.domHue.appendChild(this.domHueKnob);\n this.domPopup.appendChild(this.domSaturationKnob);\n this.domPopup.appendChild(this.domSaturation);\n this.domPopup.appendChild(this.domHue);\n this.domColor.appendChild(this.domInputColor);\n this.domColor.appendChild(this.domPopup);\n\n this._hueGradient(this.domHue);\n this._linearGradient(zAlphaSat, 'top', 'rgba(0,0,0,0)', '#000');\n\n this.domColor.addEventListener('keydown', this._onInputDown.bind(this));\n this.domSaturation.addEventListener('mousedown', this._onSaturationDown.bind(this));\n this.domHue.addEventListener('mousedown', this._onHueDown.bind(this));\n window.addEventListener('mouseup', this._onMouseUp.bind(this));\n window.addEventListener('mouseout', this._onMouseUp.bind(this));\n window.addEventListener('mousemove', this._onMouseMove.bind(this));\n\n // alpha picker\n this.hasAlpha = this.color.length === 4;\n this.alpha = 1.0;\n if (this.hasAlpha) {\n this.domPopup.style.width = '142px';\n this.domAlpha = document.createElement('div');\n this.domAlpha.className = 'gui-color-alpha';\n this.domAlphaKnob = document.createElement('div');\n this.domAlphaKnob.className = 'gui-knob-alpha';\n\n this._alphaGradient(this.domAlpha, 'top', 'rgba(0,0,0,1.0)', 'rgba(0,0,0,0.0)');\n\n this.domAlpha.addEventListener('mousedown', this._onAlphaDown.bind(this));\n this.domAlpha.appendChild(this.domAlphaKnob);\n this.domPopup.appendChild(this.domAlpha);\n }\n\n this.editHue = this.editSaturation = this.editAlpha = false;\n this.widgetHeight = this.widgetWidth = 100;\n this.setValue(this.color);\n this.setCallback(callback);\n }\n\n _onInputDown(ev) {\n ev.stopPropagation();\n if (ev.keyCode === 13)\n this.setValue(utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].hexToRgb(ev.target.value));\n }\n\n _onUpdateSaturation(ev) {\n var rect = this.domSaturation.getBoundingClientRect();\n var hsv = utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].rgbToHsv(this.getValue());\n hsv[1] = Math.min(1.0, Math.max(0.0, (ev.clientX - rect.left) / rect.width));\n hsv[2] = Math.min(1.0, Math.max(0.0, 1.0 - (ev.clientY - rect.top) / rect.width));\n this.setValue(utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].hsvToRgb(hsv), false, true);\n this._updateGui();\n }\n\n _onUpdateHue(ev) {\n var rect = this.domHue.getBoundingClientRect();\n var hsv = utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].rgbToHsv(this.getValue());\n hsv[0] = Math.min(1.0, Math.max(0.0, 1.0 - (ev.clientY - rect.top) / rect.height));\n this.setValue(utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].hsvToRgb(hsv), false, true);\n this._updateGui();\n }\n\n _onUpdateAlpha(ev) {\n var rect = this.domAlpha.getBoundingClientRect();\n var col = this.getValue();\n col[3] = this.alpha = Math.min(1.0, Math.max(0.0, 1.0 - (ev.clientY - rect.top) / rect.height));\n this.setValue(col, false, true);\n this._updateGui();\n }\n\n _updateGui() {\n var color = this.getValue();\n var hsv = utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].rgbToHsv(color);\n\n this.domSaturationKnob.style.marginLeft = this.widgetWidth * hsv[1] - 7 + 'px';\n this.domSaturationKnob.style.marginTop = this.widgetHeight * (1.0 - hsv[2]) - 7 + 'px';\n\n hsv[1] = hsv[2] = 1.0;\n this._linearGradient(this.domSaturation, 'left', '#fff', utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getStrColor(utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].hsvToRgb(hsv)));\n\n this.domHueKnob.style.marginTop = (1.0 - hsv[0]) * this.widgetHeight + 'px';\n\n if (this.hasAlpha && color[3] !== undefined)\n this.domAlphaKnob.style.marginTop = (1.0 - this.alpha) * this.widgetHeight + 'px';\n }\n\n _onMouseMove(ev) {\n if (!this.editSaturation && !this.editHue && !this.editAlpha) return;\n if (this.editSaturation) return this._onUpdateSaturation(ev);\n if (this.editHue) return this._onUpdateHue(ev);\n if (this.editAlpha) return this._onUpdateAlpha(ev);\n }\n\n _onSaturationDown(ev) {\n this.editSaturation = true;\n this._onMouseMove(ev);\n }\n\n _onHueDown(ev) {\n this.editHue = true;\n this._onMouseMove(ev);\n }\n\n _onAlphaDown(ev) {\n this.editAlpha = true;\n this._onMouseMove(ev);\n }\n\n _onMouseUp() {\n this.editHue = this.editSaturation = this.editAlpha = false;\n }\n\n _hueGradient(dom) {\n dom.style.background = '';\n for (var i = 0, l = vendors.length; i < l; ++i)\n dom.style.cssText += 'background: ' + vendors[i] + 'linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);';\n }\n\n _alphaGradient(dom, dir, col1, col2) {\n dom.style.background = '';\n for (var i = 0, l = vendors.length; i < l; ++i)\n dom.style.cssText += 'background: ' + vendors[i] + 'linear-gradient(' + dir + ', ' + col1 + ',' + col2 + '),' + urlAlpha + ';';\n }\n\n _linearGradient(dom, dir, col1, col2) {\n dom.style.background = '';\n for (var i = 0, l = vendors.length; i < l; ++i)\n dom.style.cssText += 'background: ' + vendors[i] + 'linear-gradient(' + dir + ', ' + col1 + ' 0%, ' + col2 + ' 100%);';\n }\n\n setValue(color, ignoreCB, ignoreUI) {\n var c = this.color;\n for (var i = 0, nbC = color.length; i < nbC; ++i)\n c[i] = color[i];\n\n var hex = utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].rgbToHex(color);\n this.domInputColor.value = hex;\n if (this.hasAlpha) {\n if (color.length >= 4) this.alpha = color[3];\n else color.push(this.alpha);\n var col = 'rgba(' + parseInt(color[0] * 255, 10) + ',' + parseInt(color[1] * 255, 10) + ',' + parseInt(color[2] * 255, 10) + ',' + this.alpha + ')';\n this._alphaGradient(this.domInputColor, '0deg', col, col);\n } else {\n this.domInputColor.style.background = hex;\n }\n\n // color of text\n var hsv = utils_GuiUtils__WEBPACK_IMPORTED_MODULE_0__[\"default\"].rgbToHsv(color);\n this.domSaturationKnob.style.borderColor = (hsv[2] < 0.5 || hsv[1] > 0.5) ? '#fff' : '#000';\n this.domInputColor.style.color = (this.alpha > 0.2 && (hsv[2] < 0.5 || hsv[1] > 0.5)) ? '#fff' : '#000';\n if (!ignoreUI) this._updateGui();\n if (!ignoreCB && this.callback) this.callback(color);\n }\n\n getValue() {\n return this.color;\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Color);\n\n\n//# sourceURL=webpack://yagui/./src/widgets/Color.js?")},"./src/widgets/Combobox.js":function srcWidgetsComboboxJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! widgets/BaseWidget */ \"./src/widgets/BaseWidget.js\");\n\n\nclass Combobox extends widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__[\"default\"] {\n\n constructor(valOrObject, callbackOrKey, options) {\n super();\n\n var value = this._getInitialValue(valOrObject, callbackOrKey);\n var callback = this._getCheckCallback(valOrObject, callbackOrKey);\n options = options || {};\n value = value !== undefined ? value : options[0];\n\n this.isArray = options.length !== undefined;\n\n this.domSelect = document.createElement('select');\n this.domSelect.className = 'gui-select';\n this.addOptions(options);\n\n this.domSelect.addEventListener('change', this._onChange.bind(this));\n this.setValue(value);\n this.setCallback(callback);\n }\n\n _parseValue(val) {\n return this.isArray ? parseInt(val, 10) : val;\n }\n\n _onChange(ev) {\n this.setValue(ev.target.value);\n }\n\n addOptions(options) {\n var keys = Object.keys(options);\n for (var i = 0; i < keys.length; ++i) {\n var opt = document.createElement('option');\n opt.innerHTML = options[keys[i]];\n opt.value = keys[i];\n this.domSelect.appendChild(opt);\n }\n }\n\n setValue(val, ignoreCB) {\n this.domSelect.value = val;\n if (!ignoreCB && this.callback) this.callback(this._parseValue(val));\n }\n\n getValue() {\n return this._parseValue(this.domSelect.value);\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Combobox);\n\n\n//# sourceURL=webpack://yagui/./src/widgets/Combobox.js?")},"./src/widgets/MenuButton.js":function srcWidgetsMenuButtonJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! widgets/BaseWidget */ \"./src/widgets/BaseWidget.js\");\n\n\nclass MenuButton extends widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__[\"default\"] {\n\n constructor(callbackOrObject, shortcutOrKey, shortcut) {\n super();\n\n var callback = callbackOrObject;\n if (callback && typeof callback !== 'function') callback = callbackOrObject[shortcutOrKey].bind(callbackOrObject);\n else shortcut = shortcutOrKey;\n\n this.domSpan = document.createElement('span');\n this.domSpan.className = 'shortcut';\n this.domSpan.innerHTML = shortcut || '';\n\n this.setCallback(callback);\n }\n\n _setDomContainer(container) {\n this.domContainer = container;\n container.addEventListener('click', this._onClick.bind(this));\n }\n\n _onClick() {\n if (this.callback) this.callback();\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (MenuButton);\n\n\n//# sourceURL=webpack://yagui/./src/widgets/MenuButton.js?")},"./src/widgets/Slider.js":function srcWidgetsSliderJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! widgets/BaseWidget */ \"./src/widgets/BaseWidget.js\");\n\n\nclass Slider extends widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__[\"default\"] {\n\n constructor(valOrObject, callbackOrKey, min, max, step) {\n super();\n\n var value = this._getInitialValue(valOrObject, callbackOrKey);\n var callback = this._getCheckCallback(valOrObject, callbackOrKey);\n value = value !== undefined ? value : 100;\n min = min !== undefined ? min : 0;\n max = max !== undefined ? max : 200;\n step = step !== undefined ? step : 1;\n\n // slider\n this.domSlider = document.createElement('div');\n this.domSlider.className = 'gui-slider';\n this.domSliderFill = document.createElement('div');\n this.domSlider.appendChild(this.domSliderFill);\n\n // text input\n this.domInputText = document.createElement('input');\n this.domInputText.className = 'gui-input-number';\n this.domInputText.type = 'number';\n this.min = this.domInputText.min = min;\n this.max = this.domInputText.max = max;\n this.step = this.domInputText.step = step;\n\n this.domInputText.addEventListener('keydown', this._onKeyDown.bind(this));\n this.domInputText.addEventListener('change', this._onInputText.bind(this));\n this.domInputText.addEventListener('blur', this._onInputText.bind(this));\n this.domSlider.addEventListener('mousedown', this._onMouseDown.bind(this));\n window.addEventListener('mouseup', this._onMouseUp.bind(this), true);\n window.addEventListener('mousemove', this._onMouseMove.bind(this));\n\n this.lastValue = value;\n this.isDown = false;\n this.setValue(value);\n this.setCallback(callback);\n }\n\n _onInputText(ev) {\n var val = parseFloat(ev.target.value);\n if (val !== val || val === this.lastValue) return;\n this.setValue(val);\n }\n\n _onKeyDown(ev) {\n ev.stopPropagation();\n if (ev.which === 13) // enter\n this.domInputText.blur();\n }\n\n _onMouseMove(ev) {\n ev.preventDefault();\n if (!this.isDown)\n return;\n var rect = this.domSlider.getBoundingClientRect();\n var val = this.min + (this.max - this.min) * ((ev.clientX - rect.left) / rect.width);\n this.setValue(val);\n }\n\n _onMouseDown(ev) {\n this.isDown = true;\n this._onMouseMove(ev);\n }\n\n _onMouseUp() {\n this.isDown = false;\n }\n\n _setDomContainer(container) {\n this.domContainer = container;\n }\n\n getValue() {\n return parseFloat(this.domInputText.value);\n }\n\n setValue(val, ignoreCB) {\n this.lastValue = val;\n val = Math.max(Math.min(val, this.max), this.min);\n val = Math.round(val / this.step) * this.step;\n this.domInputText.value = val;\n var per = this.min;\n if (this.max !== this.min) per = (val - this.min) / (this.max - this.min);\n this.domSliderFill.style.width = 100 * per + '%';\n if (!ignoreCB && this.callback) this.callback(val);\n }\n\n setMax(max) {\n this.domInputText.max = this.max = max;\n return this;\n }\n\n setMin(min) {\n this.min = min;\n return this;\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Slider);\n\n\n//# sourceURL=webpack://yagui/./src/widgets/Slider.js?")},"./src/widgets/Title.js":function srcWidgetsTitleJs(module,__webpack_exports__,__webpack_require__){"use strict";eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! widgets/BaseWidget */ \"./src/widgets/BaseWidget.js\");\n\n\nclass Title extends widgets_BaseWidget__WEBPACK_IMPORTED_MODULE_0__[\"default\"] {\n\n constructor(name) {\n super();\n\n this.domText = document.createElement('div');\n this.domText.innerHTML = name || '';\n this.domText.className = 'group-title';\n }\n\n setText(text) {\n this.domText.innerHTML = text;\n }\n\n setVisibility(visible) {\n this.domText.hidden = !visible;\n }\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Title);\n\n\n//# sourceURL=webpack://yagui/./src/widgets/Title.js?")},"./src/yagui.js":function srcYaguiJs(module,exports,__webpack_require__){eval('var GuiMain = __webpack_require__(/*! GuiMain */ "./src/GuiMain.js").default;\n\nvar yagui = {\n GuiMain: GuiMain\n};\n\nmodule.exports = yagui;\n\n\n//# sourceURL=webpack://yagui/./src/yagui.js?')}})},"object"===_typeof(exports)&&"object"===_typeof(module)?module.exports=factory():(__WEBPACK_AMD_DEFINE_ARRAY__=[],void 0===(__WEBPACK_AMD_DEFINE_RESULT__="function"==typeof(__WEBPACK_AMD_DEFINE_FACTORY__=factory)?__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports,__WEBPACK_AMD_DEFINE_ARRAY__):__WEBPACK_AMD_DEFINE_FACTORY__)||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__))},183:(e,t,r)=>{"use strict";r.d(t,{Z:()=>u});var i=r(52);var n;function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=(a(n={backgroundTitle:"背景",backgroundReset:"重設",backgroundImport:"匯入 (jpg, png...)",backgroundFill:"填充",cameraTitle:"鏡頭",cameraReset:"檢視",cameraCenter:"重設 (空白鍵)",cameraFront:"前視角 (F)",cameraLeft:"左視角 (L)",cameraTop:"俯視角 (T)",cameraMode:"模式",cameraOrbit:"軌道 (轉盤)",cameraSpherical:"球面 (軌跡球)",cameraPlane:"平面 (軌跡球)",cameraProjection:"投影",cameraPerspective:"透視角",cameraOrthographic:"等視角",cameraFov:"視野範圍",cameraPivot:"選擇軸心",fileTitle:"檔案 (匯入/匯出)",fileImportTitle:"匯入",fileAdd:"加入 (obj, sgl, ply, stl)",fileAutoMatrix:"縮放並置中",fileVertexSRGB:"sRGB 頂點色彩",fileExportSceneTitle:"匯出場景",fileExportAll:"匯出出口",fileExportSGL:"儲存 .sgl (SculptGL)",fileExportOBJ:"儲存 .obj",fileExportPLY:"儲存 .ply",fileExportSTL:"儲存 .stl",fileExportTextureTitle:null,fileExportTextureSize:null,fileExportColor:null,fileExportRoughness:null,fileExportMetalness:null,sceneTitle:"場景",sceneReset:"清除場景",sceneResetConfirm:"確認清除場景",sceneAddSphere:"加入球體",sceneAddCube:"加入立方體",sceneAddCylinder:"加入圓柱",sceneAddTorus:"加入圓環",sceneSelection:"選取項目",sceneMerge:"合併選取項目",sceneDuplicate:"刪除選擇"},"sceneDuplicate",null),a(n,"meshTitle","網面"),a(n,"meshNbVertices","頂點 : "),a(n,"meshNbFaces","面 : "),a(n,"topologyTitle","網面結構(拓撲)"),a(n,"multiresTitle","多重解析度"),a(n,"multiresSubdivide","細分"),a(n,"multiresReverse","反轉"),a(n,"multiresResolution","解析度"),a(n,"multiresNoLower","沒有更低等級的解析度。"),a(n,"multiresNoHigher","沒有更高等級的解析度。"),a(n,"multiresDelHigher","刪除較高等級"),a(n,"multiresDelLower","刪除較低等級"),a(n,"multiresSelectLowest","反轉前請先選擇最低的解析度。"),a(n,"multiresSelectHighest","細分前請先選擇最高的解析度。"),a(n,"multiresWarnBigMesh",(function(e){return"下一個細分等級會達到 "+e+" 個面。\n若你清楚你自己正在做什麼再點擊「細分」一次。"})),a(n,"multiresNotReversible","抱歉,無法反轉此網面。\n此網面不是由流形網面經過細分曲面 (loop-catmull) 而來。"),a(n,"remeshTitle","立體像素網面重構"),a(n,"remeshRemesh","網面重構"),a(n,"remeshResolution","解析度"),a(n,"remeshBlock","塊狀重構"),a(n,"dynamicTitle","動態網面結構"),a(n,"dynamicActivated","啟用 (無四邊形)"),a(n,"dynamicSubdivision","細分"),a(n,"dynamicDecimation","削減面數"),a(n,"dynamicLinear","線性細分"),a(n,"sculptTitle","雕刻和塗繪"),a(n,"sculptBrush","筆刷"),a(n,"sculptInflate","膨脹"),a(n,"sculptTwist","扭轉"),a(n,"sculptSmooth","平滑 (-Shift)"),a(n,"sculptFlatten","抹平"),a(n,"sculptPinch","捏塑"),a(n,"sculptCrease","皺褶"),a(n,"sculptDrag","拖拉"),a(n,"sculptPaint","塗繪"),a(n,"sculptMasking","遮罩 (-Ctrl)"),a(n,"sculptMove","移動"),a(n,"sculptLocalScale","局部縮放"),a(n,"sculptTransform","變形 (E)"),a(n,"sculptCommon","通用"),a(n,"sculptTool","工具"),a(n,"sculptSymmetry","對稱"),a(n,"sculptContinuous","連續"),a(n,"sculptRadius","半徑 (-X)"),a(n,"sculptIntensity","強度 (-C)"),a(n,"sculptHardness","硬度"),a(n,"sculptCulling","薄曲面 (僅影響前面頂點)"),a(n,"sculptAlphaTitle","透明色版 (Alpha)"),a(n,"sculptLockPositon","鎖定位置"),a(n,"sculptAlphaTex","紋理"),a(n,"sculptImportAlpha","匯入 alpha 紋理 (jpg, png...)"),a(n,"sculptNegative","反向 (N 或 -Alt)"),a(n,"sculptColor","反照率"),a(n,"sculptRoughness","粗糙度"),a(n,"sculptMetallic","金屬性"),a(n,"sculptClay","黏土"),a(n,"sculptAccumulate","累積 (每道筆劃無限制)"),a(n,"sculptColorGlobal","總體"),a(n,"sculptPickColor","選擇材質或顏色 (-S)"),a(n,"sculptTangentialSmoothing","僅放鬆"),a(n,"sculptTopologicalCheck","網面結構檢查"),a(n,"sculptMoveAlongNormal","沿法線方向移動 (N 或 -Alt)"),a(n,"sculptMaskingClear","清除 (-Ctrl + 拖動)"),a(n,"sculptMaskingInvert","反轉 (-Ctrl + 點擊)"),a(n,"sculptMaskingBlur","模糊"),a(n,"sculptMaskingSharpen","銳利化"),a(n,"sculptPBRTitle","PBR 材質"),a(n,"sculptPaintAll","塗繪全部"),a(n,"sculptExtractTitle","提取"),a(n,"sculptExtractThickness","厚度"),a(n,"sculptExtractAction","提取 !"),a(n,"stateTitle","記錄"),a(n,"stateUndo","復原"),a(n,"stateRedo","取消復原"),a(n,"stateMaxStack","最大推疊"),a(n,"pressureTitle","感壓繪圖板"),a(n,"pressureRadius","半徑感壓"),a(n,"pressureIntensity","強度感壓"),a(n,"renderingTitle","圖形繪算"),a(n,"renderingGrid","顯示格線"),a(n,"renderingSymmetryLine","顯示鏡像線"),a(n,"renderingMatcap","材質捕捉 (Matcap)"),a(n,"renderingCurvature","曲率"),a(n,"renderingPBR","物理式繪算(PBR)"),a(n,"renderingTransparency","透明"),a(n,"renderingNormal","法線著色器"),a(n,"renderingUV","UV 著色器"),a(n,"renderingShader","著色器"),a(n,"renderingMaterial","材質"),a(n,"renderingImportUV","匯入 (jpg, png...)"),a(n,"renderingImportMatcap","匯入 (jpg, png...)"),a(n,"renderingExtra","額外"),a(n,"renderingFlat","平整面"),a(n,"renderingWireframe","線框 (W)"),a(n,"renderingExposure","曝光"),a(n,"renderingEnvironment","環境"),a(n,"renderingIsolate","隔離/顯示 (I)"),a(n,"renderingFilmic","電影色調對應"),a(n,"contour","輪廓"),a(n,"contourShow","顯示輪廓"),a(n,"contourColor","顏色"),a(n,"darkenUnselected","未選取部分變暗"),a(n,"resolution","解析度"),a(n,"matcapPearl","珍珠"),a(n,"matcapClay","黏土"),a(n,"matcapSkin","膚色"),a(n,"matcapGreen","綠色"),a(n,"matcapWhite","白色"),a(n,"sketchfabTitle","前往 Sketchfab !"),a(n,"sketchfabUpload","上傳"),a(n,"sketchfabUploadMessage",'請輸入你的 sketchfab API 密鑰.\n你也可以不填寫留下 "guest" 進行匿名上傳。\n(當上傳中和完成時會跳出新視窗)'),a(n,"sketchfabUploadError",(function(e){return"Sketchfab 上傳錯誤 :\n"+e})),a(n,"sketchfabUploadSuccess","上傳成功 !\n這是你的連結 :"),a(n,"sketchfabAbort","中止最後上傳的項目 ?"),a(n,"sketchfabUploadProcessing","處理中...\n你的模型將會存放在"),a(n,"about","關於和說明"),a(n,"alphaNone","無"),a(n,"alphaSquare","方塊"),a(n,"alphaSkin","皮膚"),n),o=function e(t){var r=e.languages[e.select][t]||e.languages.english[t];return"string"==typeof r?r:"function"==typeof r?r.apply(this,Array.prototype.slice.call(arguments,1)):(console.error("No TR found for : "+t),t)};o.languages={english:{backgroundTitle:"Background",backgroundReset:"Reset",backgroundImport:"Import (jpg, png...)",backgroundFill:"Fill",cameraTitle:"Camera",cameraReset:"View",cameraCenter:"Reset (bar)",cameraFront:"Front (F)",cameraLeft:"Left (L)",cameraTop:"Top (T)",cameraMode:"Mode",cameraOrbit:"Orbit (Turntable)",cameraSpherical:"Spherical (Trackball)",cameraPlane:"Plane (Trackball)",cameraProjection:"Projection",cameraPerspective:"Perspective",cameraOrthographic:"Orthographic",cameraFov:"Fov",cameraPivot:"Picking pivot",fileTitle:"Files (import/export)",fileImportTitle:"Import",fileAdd:"Add (obj, sgl, ply, stl)",fileAutoMatrix:"Scale and center",fileVertexSRGB:"sRGB vertex color",fileExportSceneTitle:"Export Scene",fileExportAll:"Export all",fileExportSGL:"Save .sgl (SculptGL)",fileExportOBJ:"Save .obj",fileExportPLY:"Save .ply",fileExportSTL:"Save .stl",fileExportTextureTitle:"Export textures",fileExportTextureSize:"Size",fileExportColor:"Save diffuse",fileExportRoughness:"Save roughness",fileExportMetalness:"Save metalness",sceneTitle:"Scene",sceneReset:"Clear scene",sceneResetConfirm:"Confirm clear scene",sceneAddSphere:"Add sphere",sceneAddCube:"Add cube",sceneAddCylinder:"Add cylinder",sceneAddTorus:"Add torus",sceneSelection:"Selection",sceneMerge:"Merge selection",sceneDuplicate:"Copy selection",sceneDelete:"Delete selection",meshTitle:"Mesh",meshNbVertices:"Vertex : ",meshNbFaces:"Faces : ",topologyTitle:"Topology",multiresTitle:"Multiresolution",multiresSubdivide:"Subdivide",multiresReverse:"Reverse",multiresResolution:"Resolution",multiresNoLower:"There is no lower resolution level.",multiresNoHigher:"There is no higher resolution level.",multiresDelHigher:"Delete higher",multiresDelLower:"Delete lower",multiresSelectLowest:"Select the lowest resolution before reversing.",multiresSelectHighest:"Select the highest resolution before subdividing.",multiresWarnBigMesh:function(e){return"The next subdivision level will reach "+e+' faces.\nIf you know what you are doing, click again on "subdivide".'},multiresNotReversible:"Sorry it is not possile to reverse this mesh.\nThe mesh is not a product of a (loop-catmull) subdivision surface on a manifold mesh.",remeshTitle:"Voxel remeshing (quads)",remeshRemesh:"Remesh",remeshResolution:"Resolution",remeshBlock:"Block",dynamicTitle:"Dynamic Topology",dynamicActivated:"Activated (no quads)",dynamicSubdivision:"Subdivision",dynamicDecimation:"Decimation",dynamicLinear:"Linear subdivision",sculptTitle:"Sculpting & Painting",sculptBrush:"Brush",sculptInflate:"Inflate",sculptTwist:"Twist",sculptSmooth:"Smooth (-Shift)",sculptFlatten:"Flatten",sculptPinch:"Pinch",sculptCrease:"Crease",sculptDrag:"Drag",sculptPaint:"Paint",sculptMasking:"Masking (-Ctrl)",sculptMove:"Move",sculptLocalScale:"Local scale",sculptTransform:"Transform (E)",sculptPen:"Pen",sculptCommon:"Common",sculptTool:"Tool",sculptSymmetry:"Symmetry",sculptContinuous:"Continuous",sculptRadius:"Radius (-X)",sculptIntensity:"Intensity (-C)",sculptHardness:"Hardness",sculptCulling:"Thin surface (front vertex only)",sculptAlphaTitle:"Alpha",sculptLockPositon:"Lock position",sculptAlphaTex:"Texture",sculptImportAlpha:"Import alpha tex (jpg, png...)",sculptNegative:"Negative (N or -Alt)",sculptColor:"Albedo",sculptRoughness:"Roughness",sculptMetallic:"Metallic",sculptClay:"Clay",sculptAccumulate:"Accumulate (no limit per stroke)",sculptColorGlobal:"Global",sculptPickColor:"Material / Color picker (-S)",sculptTangentialSmoothing:"Relax only",sculptTopologicalCheck:"Topological check",sculptMoveAlongNormal:"Move along normal (N or -Alt)",sculptMaskingClear:"Clear (-Ctrl + Drag)",sculptMaskingInvert:"Invert (-Ctrl + Click)",sculptMaskingBlur:"Blur",sculptMaskingSharpen:"Sharpen",sculptPBRTitle:"PBR materials",sculptPaintAll:"Paint all",sculptExtractTitle:"Extract",sculptExtractThickness:"Thickness",sculptExtractAction:"Extract !",penMode:"Pen mode",penModePoints:"Points",penModeStroke:"Stroke",penTitle:"Pen",penEnable:"Enable pen tool",penCloseLoop:"Close loop",penSpacing:"Spacing",penClear:"Clear stroke",penNewSet:"New set",penFinishSet:"Finish set",penFeatureList:"Point sets",penNoFeatures:"No feature sets yet",penClosed:"Closed",padsTrimsTitle:"Pads & Trims",padsTrimsSourceSets:"Point sets",padsTrimsCreatePad:"Create pad",padsTrimsCreateTrim:"Create trim",padsTrimsPadHeight:"Pad height",padsTrimsTrimDepth:"Trim depth",padsTrimsPadDirection:"Pad direction",padsTrimsTrimDirection:"Trim direction",padsTrimsDirIn:"In",padsTrimsDirOut:"Out",padsTrimsDirBoth:"Both",padsTrimsFeatureSets:"Volumes",padsTrimsFrom:"from",padsTrimsPadLabel:"Pad",padsTrimsTrimLabel:"Trim",padsTrimsHeight:"height",padsTrimsDepth:"depth",stateTitle:"History",stateUndo:"Undo",stateRedo:"Redo",stateMaxStack:"Max Stack",pressureTitle:"Tablet pressure",pressureRadius:"Pressure radius",pressureIntensity:"Pressure intensity",renderingTitle:"Rendering",renderingGrid:"Show grid",renderingSymmetryLine:"Show mirror line",renderingMatcap:"Matcap",renderingCurvature:"Curvature",renderingPBR:"PBR",renderingTransparency:"Transparency",renderingNormal:"Normal shader",renderingUV:"UV shader",renderingShader:"Shader",renderingMaterial:"Material",renderingImportUV:"Import (jpg, png...)",renderingImportMatcap:"Import (jpg, png...)",renderingExtra:"Extra",renderingFlat:"Flat shading",renderingWireframe:"Wireframe (W)",renderingSectionCut:"Section cut",renderingSectionAxis:"Axis",renderingSectionOffset:"Offset",renderingSectionInvert:"Invert",renderingExposure:"Exposure",renderingEnvironment:"Environment",renderingIsolate:"Isolate/Show (I)",renderingFilmic:"Filmic tonemapping",contour:"Contour",contourShow:"Show contour",contourColor:"Color",darkenUnselected:"Darken unselected",resolution:"Resolution",matcapPearl:"Pearl",matcapClay:"Clay",matcapSkin:"Skin",matcapGreen:"Green",matcapWhite:"White",sketchfabTitle:"Go to Sketchfab !",sketchfabUpload:"Upload",sketchfabUploadMessage:'Please enter your sketchfab API Key.\nYou can also leave "guest" to upload anonymously.\n(a new window will pop up when the uploading and processing is finished)',sketchfabUploadError:function(e){return"Sketchfab upload error :\n"+e},sketchfabUploadSuccess:"Upload success !\nHere is your link :",sketchfabAbort:"Abort the last upload ?",sketchfabUploadProcessing:"Processing...\nYour model will be available at :",about:"About & Help",alphaNone:"None",alphaSquare:"Square",alphaSkin:"Skin",remeshTitleMC:"Voxel remeshing (manifold tris)",remeshRemeshMC:"Remesh",remeshSmoothingMC:"Relax topology"},日本語:{backgroundTitle:"バックグラウンド",backgroundReset:"リセット",backgroundImport:"インポート (jpg, png...)",backgroundFill:null,cameraTitle:"カメラ",cameraReset:"View",cameraCenter:null,cameraFront:null,cameraLeft:null,cameraTop:null,cameraMode:"モード",cameraOrbit:null,cameraSpherical:"球体 (Trackball)",cameraPlane:"平面 (Trackball)",cameraProjection:"タイプ",cameraPerspective:"透視投影",cameraOrthographic:"平行投影",cameraFov:"視野",cameraPivot:"ピボット選択",fileTitle:"ファイル (インポート/エクスポート)",fileImportTitle:null,fileAdd:"Add (obj, sgl, ply, stl)",fileAutoMatrix:null,fileVertexSRGB:null,fileExportSceneTitle:null,fileExportAll:null,fileExportSGL:null,fileExportOBJ:null,fileExportPLY:null,fileExportSTL:null,fileExportTextureTitle:null,fileExportTextureSize:null,fileExportColor:null,fileExportRoughness:null,fileExportMetalness:null,sceneTitle:null,sceneReset:null,sceneAddSphere:null,sceneAddCube:null,sceneAddCylinder:null,sceneAddTorus:null,sceneSelection:null,sceneMerge:null,sceneDuplicate:null,meshTitle:"メッシュ",meshNbVertices:null,meshNbFaces:null,topologyTitle:null,multiresTitle:null,multiresSubdivide:null,multiresReverse:null,multiresResolution:null,multiresNoLower:null,multiresNoHigher:null,multiresDelHigher:null,multiresDelLower:null,multiresSelectLowest:null,multiresSelectHighest:null,multiresWarnBigMesh:null,multiresNotReversible:null,remeshTitle:null,remeshRemesh:null,remeshResolution:null,remeshBlock:null,dynamicTitle:null,dynamicActivated:null,dynamicSubdivision:null,dynamicDecimation:null,dynamicLinear:null,sculptTitle:null,sculptBrush:"ブラシ",sculptInflate:"膨張",sculptTwist:"回転",sculptSmooth:"スムーズ化 (-Shift)",sculptFlatten:"フラット化",sculptPinch:"つまむ",sculptCrease:"しわ",sculptDrag:"ドラッグ",sculptPaint:"ペイント",sculptMasking:null,sculptMove:null,sculptLocalScale:null,sculptTransform:null,sculptCommon:null,sculptTool:"ツール",sculptSymmetry:"対称加工",sculptContinuous:"連続加工",sculptRadius:"半径 (-X)",sculptIntensity:"明るさ (-C)",sculptHardness:null,sculptCulling:null,sculptAlphaTitle:null,sculptLockPositon:null,sculptAlphaTex:null,sculptImportAlpha:null,sculptNegative:"ネガティブ (N or -Alt)",sculptColor:null,sculptRoughness:null,sculptMetallic:null,sculptClay:"クレイ",sculptAccumulate:null,sculptColorGlobal:null,sculptPickColor:null,sculptTangentialSmoothing:null,sculptTopologicalCheck:null,sculptMoveAlongNormal:null,sculptMaskingClear:null,sculptMaskingInvert:null,sculptMaskingBlur:null,sculptMaskingSharpen:null,sculptPBRTitle:null,sculptPaintAll:null,sculptExtractTitle:null,sculptExtractThickness:null,sculptExtractAction:null,stateTitle:"履歴",stateUndo:"アンドゥ",stateRedo:"リドゥ",stateMaxStack:null,pressureTitle:"ワコムタブレット",pressureRadius:"圧力半径?",pressureIntensity:"圧力の強さ?",renderingTitle:null,renderingGrid:null,renderingSymmetryLine:null,renderingMatcap:null,renderingCurvature:null,renderingPBR:null,renderingTransparency:"透過",renderingNormal:"ノーマル",renderingUV:null,renderingShader:"シェーダー",renderingMaterial:null,renderingImportUV:null,renderingImportMatcap:null,renderingExtra:null,renderingFlat:"フラットシェーディング",renderingWireframe:"ワイヤーフレーム (W)",renderingExposure:null,renderingEnvironment:null,renderingIsolate:null,renderingFilmic:null,contour:null,contourShow:null,contourColor:null,darkenUnselected:null,resolution:null,matcapPearl:null,matcapClay:"クレイ",matcapSkin:"スキン",matcapGreen:null,matcapWhite:null,sketchfabTitle:"Sketchfabへ移動",sketchfabUpload:"アップロード",sketchfabUploadMessage:null,sketchfabUploadError:null,sketchfabUploadSuccess:null,sketchfabAbort:null,sketchfabUploadProcessing:null,about:null,alphaNone:null,alphaSquare:null,alphaSkin:null},中文:s,한국어:{backgroundTitle:"배경",backgroundReset:"초기화",backgroundImport:"가져오기 (jpg, png...)",backgroundFill:"화면 가득 채우기",cameraTitle:"카메라",cameraReset:"뷰",cameraCenter:"초기화 (bar)",cameraFront:"앞쪽 (F)",cameraLeft:"왼쪽 (L)",cameraTop:"위쪽 (T)",cameraMode:"조작방식",cameraOrbit:"궤도 (Turntable)",cameraSpherical:"구형 (Trackball)",cameraPlane:"평면 (Trackball)",cameraProjection:"사영법",cameraPerspective:"투시원근법",cameraOrthographic:"정사영법",cameraFov:"시야각",cameraPivot:"피봇 찍기",fileTitle:"파일 (가져오기/내보내기)",fileImportTitle:"가져오기",fileAdd:"추가 (obj, sgl, ply, stl)",fileAutoMatrix:"크기조정 및 중앙정렬",fileVertexSRGB:"sRGB 버텍스 색상",fileExportSceneTitle:"장면 내보내기",fileExportAll:"모두 내보내기",fileExportSGL:".sgl 파일로 저장하기",fileExportOBJ:".obj 파일로 저장하기",fileExportPLY:".ply 파일로 저장하기",fileExportSTL:".stl 파일로 저장하기",fileExportTextureTitle:null,fileExportTextureSize:null,fileExportColor:null,fileExportRoughness:null,fileExportMetalness:null,sceneTitle:"장면",sceneReset:"모두 없애기",sceneResetConfirm:"모두 제거 확인",sceneAddSphere:"구 추가하기",sceneAddCube:"정육면체 추가하기",sceneAddCylinder:"기둥 추가하기",sceneAddTorus:"도넛 추가하기",sceneSelection:"선택",sceneMerge:"장면 병합하기",sceneDuplicate:null,sceneDelete:"선택 항목 삭제",meshTitle:"메시",meshNbVertices:"버텍스 개수 : ",meshNbFaces:"페이스 개수 : ",topologyTitle:"토폴로지",multiresTitle:"다중 해상도",multiresSubdivide:"세분화",multiresReverse:"간소화",multiresResolution:"해상도",multiresNoLower:"더 낮은 해상도가 존재하지 않습니다.",multiresNoHigher:"더 높은 해상도가 존재하지 않습니다.",multiresDelHigher:"상위 단계 제거",multiresDelLower:"하위 단계 제거",multiresSelectLowest:"간소화 하기 전에 더 낮은 해상도를 고르세요.",multiresSelectHighest:"세분화 하기 전에 더 높은 해상도를 고르세요",multiresWarnBigMesh:function(e){return"다음 분할 단계의 면 개수는 "+e+' 개가 될 것입니다.\n지금 뭘 하려는건지 정확히 이해하고 있다면 "세분화" 버튼을 다시 누르세요.'},multiresNotReversible:"이 메시는 더이상 병합할 수 없습니다.\n이 메시는 다양체 메시상의 세분화(loop-catmull) 결과가 아닙니다.",remeshTitle:"복셀 리메싱",remeshRemesh:"리메시",remeshResolution:"해상도",remeshBlock:"각지게",dynamicTitle:"동적 토폴로지",dynamicActivated:"활성화 (사각형 유지 안함)",dynamicSubdivision:"세분화",dynamicDecimation:"간소화",dynamicLinear:"선형 세분화",sculptTitle:"스컬핑 & 페인팅",sculptBrush:"브러시",sculptInflate:"부풀리기",sculptTwist:"비틀기",sculptSmooth:"부드럽게 (-Shift)",sculptFlatten:"평평하게",sculptPinch:"꼬집기",sculptCrease:"주름내기",sculptDrag:"잡아끌기",sculptPaint:"칠하기",sculptMasking:"마스킹 (-Ctrl)",sculptMove:"잡아당기기",sculptLocalScale:"지역 스케일",sculptTransform:"변환 (E)",sculptCommon:"일반",sculptTool:"도구",sculptSymmetry:"대칭",sculptContinuous:"누적",sculptRadius:"반경 (-X)",sculptIntensity:"세기 (-C)",sculptHardness:"경도",sculptCulling:"얇은 표면 (앞쪽 면만 적용)",sculptAlphaTitle:"알파",sculptLockPositon:"위치 고정",sculptAlphaTex:"텍스쳐",sculptImportAlpha:"알파 텍스쳐 가져오기 (jpg, png...)",sculptNegative:"반전 (N 또는 -Alt)",sculptColor:"알베도",sculptRoughness:"거칠기",sculptMetallic:"금속",sculptClay:"찰흙",sculptAccumulate:"누적 (획 당으로 제한받지 않음)",sculptColorGlobal:null,sculptPickColor:"재질 / 색상 선택 (-S)",sculptTangentialSmoothing:"완화 한정",sculptTopologicalCheck:"위상 검사",sculptMoveAlongNormal:"법선 방향으로 움직이기",sculptMaskingClear:"초기화 (-Ctrl + Drag)",sculptMaskingInvert:"반전 (-Ctrl + Click)",sculptMaskingBlur:"흐리게",sculptMaskingSharpen:"선명하게",sculptPBRTitle:"PBR 재질",sculptPaintAll:"전부 칠하기",sculptExtractTitle:"추출하기",sculptExtractThickness:"두께",sculptExtractAction:"추출!",stateTitle:"히스토리",stateUndo:"실행 취소",stateRedo:"다시 실행",stateMaxStack:"최대 실행취소 횟수",pressureTitle:"필압",pressureRadius:"필압반경",pressureIntensity:"필압 세기",renderingTitle:"렌더링",renderingGrid:"그리드 보기",renderingSymmetryLine:"대칭선 보기",renderingMatcap:"매트캡",renderingCurvature:"곡률 강조",renderingPBR:"PBR",renderingTransparency:"투명도",renderingNormal:"노말 셰이더",renderingUV:"UV 셰이더",renderingShader:"셰이더",renderingMaterial:"재질",renderingImportUV:"가져오기 (jpg, png...)",renderingImportMatcap:"가져오기 (jpg, png...)",renderingExtra:"그 외",renderingFlat:"플랫 셰이딩",renderingWireframe:"와이어프레임 (W)",renderingExposure:"노출",renderingEnvironment:"환경",renderingIsolate:"하나보기/모두보기 (I)",renderingFilmic:"영화적(filmic) 톤매핑",contour:"윤곽선",contourShow:"윤곽선 보기",contourColor:"색상",darkenUnselected:"선택안된건 어둡게",resolution:"해상도",matcapPearl:"진주",matcapClay:"찰흙",matcapSkin:"피부",matcapGreen:"초록",matcapWhite:"하양",sketchfabTitle:"Sketchfab에 올리기",sketchfabUpload:"올리기",sketchfabUploadMessage:null,sketchfabUploadError:null,sketchfabUploadSuccess:null,sketchfabAbort:null,sketchfabUploadProcessing:null,about:"SculptGL 정보",alphaNone:null,alphaSquare:null,alphaSkin:null},русский:{backgroundTitle:"Фон",backgroundReset:"Сброс",backgroundImport:"Импорт (jpg, png...)",backgroundFill:"Заполнить",cameraTitle:"Камера",cameraReset:"Вид",cameraCenter:"Сброс (bar)",cameraFront:"Спереди (F)",cameraLeft:"Слева (L)",cameraTop:"Сверху (T)",cameraMode:"Режим камеры",cameraOrbit:"Орбита (Вращение)",cameraSpherical:"Сферическая (трекбол)",cameraPlane:"Плоскость (трекбол)",cameraProjection:"Проекция",cameraPerspective:"Перспективная",cameraOrthographic:"Ортогональная",cameraFov:"Угол обзора",cameraPivot:"Выбор вращения",fileTitle:"Файл",fileImportTitle:"Импорт",fileAdd:"Добавить(obj,sgl,ply,stl)",fileAutoMatrix:"Масштаб-вид",fileVertexSRGB:"Цвета вершин sRGB",fileExportSceneTitle:"Экспорт сцены",fileExportAll:"Экспорт все",fileExportSGL:"Сохранить .sgl",fileExportOBJ:"Сохранить .obj",fileExportPLY:"Сохранить .ply",fileExportSTL:"Сохранить .stl",fileExportTextureTitle:null,fileExportTextureSize:null,fileExportColor:null,fileExportRoughness:null,fileExportMetalness:null,sceneTitle:"Сцена",sceneReset:"Очистить сцену",sceneResetConfirm:"Подтвердить четкую сцену",sceneAddSphere:"Добавить сферу",sceneAddCube:"Добавить куб",sceneAddCylinder:"Добавить цилиндр",sceneAddTorus:"Добавить тор",sceneSelection:"Выбрать",sceneMerge:"Объединить",sceneDuplicate:null,sceneDelete:"Удалить выделение",meshTitle:"Сетка",meshNbVertices:"Вершины : ",meshNbFaces:"Грани : ",topologyTitle:"Топология",multiresTitle:"Детализация",multiresSubdivide:"Увеличить",multiresReverse:"Реверс",multiresResolution:"Разрешение",multiresNoLower:"Ниже уровня не существует.",multiresNoHigher:"Выше уровня не существует.",multiresDelHigher:"Удалить высокое",multiresDelLower:"Удалить низкое",multiresSelectLowest:"Выберете низкий перед реверсом.",multiresSelectHighest:"Выберете бысокий перед увеличением.",multiresWarnBigMesh:function(e){return"Следующий уровень "+e+' faces.\nЕсли вы уверены, снова нажмите на "разрешение".'},multiresNotReversible:"К сожалению это не возможно, чтобы изменить эту сетку.\nСетка не продуктивна.",remeshTitle:"Перестроить воксели",remeshRemesh:"Перестроить",remeshResolution:"Разрешение",remeshBlock:"Блоки-кубики",dynamicTitle:"Динамическая топология",dynamicActivated:"Активировать (без кубиков)",dynamicSubdivision:"Увеличить",dynamicDecimation:"Прореживание",dynamicLinear:"Линейное увеличение",sculptTitle:"Лепить и красить",sculptBrush:"3D Кисть",sculptInflate:"3D Надуть",sculptTwist:"3D Закручивание",sculptSmooth:"3D Сгладить (-Shift)",sculptFlatten:"3D Расплющить",sculptPinch:"3D Сдавить",sculptCrease:"3D Складка",sculptDrag:"3D Тянучка",sculptMove:"3D Перемещать",sculptLocalScale:"3D масштабирование",sculptPaint:"2D Кисть",sculptMasking:"2D Маска (-Ctrl)",sculptTransform:"Трансформация",sculptCommon:"Общее",sculptTool:"Инструмент",sculptSymmetry:"Симетрия",sculptContinuous:"Спрей",sculptRadius:"Размер (-X)",sculptIntensity:"Сила (-C)",sculptHardness:"Жесткость",sculptCulling:"Тонкая поверхность(передние вершины)",sculptAlphaTitle:"Альфа",sculptLockPositon:"Фиксация",sculptAlphaTex:"Текстура",sculptImportAlpha:"Импорт альфа текстуры (jpg, png...)",sculptNegative:"Негатив (N или -Alt)",sculptColor:"Палитра",sculptRoughness:"Шероховатость",sculptMetallic:"Металлический",sculptClay:"Без учета содержимого",sculptAccumulate:"Наращивать без ограничений",sculptColorGlobal:"Глобальный",sculptPickColor:"Пипетка материал (-S)",sculptTangentialSmoothing:"Сглаживание по касательной",sculptTopologicalCheck:"Проверка топологии",sculptMoveAlongNormal:"Перемещать вдоль нормали",sculptMaskingClear:"Очистить (-Ctrl + Drag)",sculptMaskingInvert:"Инверсия (-Ctrl + Click)",sculptMaskingBlur:"Сгладить",sculptMaskingSharpen:"Резко",sculptPBRTitle:"PBR материал",sculptPaintAll:"Краска",sculptExtractTitle:"Извлечь",sculptExtractThickness:"Толщина",sculptExtractAction:"Извлечь!",stateTitle:"История",stateUndo:"Назад",stateRedo:"Вперед",stateMaxStack:"Количество шагов",pressureTitle:"Планшет pressure",pressureRadius:"Нажим-размер",pressureIntensity:"Нажим-жесткость",renderingTitle:"Визуализация",renderingGrid:"Показать сетку",renderingSymmetryLine:"Линия симетрии",renderingMatcap:null,renderingCurvature:"Рельефность",renderingPBR:"PBR",renderingTransparency:"Прозрачность",renderingNormal:"Карта нормалей",renderingUV:"UV",renderingShader:"Шейдеры",renderingMaterial:"Материал",renderingImportUV:"Импорт (jpg, png...)",renderingImportMatcap:"Импорт (jpg, png...)",renderingExtra:"Дополнительно",renderingFlat:"Плоскости",renderingWireframe:"Каркас (W)",renderingExposure:"Экспозиция",renderingEnvironment:"Отражение",renderingIsolate:"Изолировать / Показать (I)",renderingFilmic:"Пленка",contour:"Контур",contourShow:"Показать контур",contourColor:"Цвет",darkenUnselected:"Затемнить невыбранное",resolution:"Разрешение",matcapPearl:"Жемчуг",matcapClay:"Глина",matcapSkin:"Кожа",matcapGreen:"Зеленый",matcapWhite:"Белый",sketchfabTitle:"В Sketchfab.com ",sketchfabUpload:"Загрузить",sketchfabUploadMessage:"Ведите API-ключ sketchfab.\nОставьте слово «guest», чтобы загрузить модель анонимно.\n(По окончании загрузки и обработки откроется новое окно)",sketchfabUploadError:function(e){return"Ошибка загрузки в Sketchfab :\n"+e},sketchfabUploadSuccess:"Загрузка выполнена !\nВаша ссылка:",sketchfabAbort:"Прервать загрузку?",sketchfabUploadProcessing:"Обработка...\nВаша модель будет доступна после:",about:"О программе",alphaNone:"Нет",alphaSquare:"Квадрат",alphaSkin:"Кожа"},turkish:{backgroundTitle:"Arka plan",backgroundReset:"Temizle",backgroundImport:"İçe Aktar (jpg, png...)",backgroundFill:"Doldur",cameraTitle:"Kamera",cameraReset:"Görünüm",cameraCenter:"Temizle (boşluk)",cameraFront:"Ön (F)",cameraLeft:"Sol (L)",cameraTop:"Üst (T)",cameraMode:"Mod",cameraOrbit:"Eksen (Döner Tabla)",cameraSpherical:"Küresel (Trackball)",cameraPlane:"Düzlem (Trackball)",cameraProjection:"İz Düşüm",cameraPerspective:"Perspektif",cameraOrthographic:"Orthografik",cameraFov:"Görüş Alanı",cameraPivot:"Eksen",fileTitle:"Dosyalar (içeri/dışarı)",fileImportTitle:"İçe Aktar",fileAdd:"Aktar (obj, sgl, ply, stl)",fileAutoMatrix:"Ölçekle ve ortala",fileVertexSRGB:"sRGB verteks renk",fileExportSceneTitle:"Sahneyi Dışa Aktar",fileExportAll:"tümünü ver",fileExportSGL:"Kaydet .sgl (SculptGL)",fileExportOBJ:"Kaydet .obj",fileExportPLY:"Kaydet .ply",fileExportSTL:"Kaydet .stl",fileExportTextureTitle:null,fileExportTextureSize:null,fileExportColor:null,fileExportRoughness:null,fileExportMetalness:null,sceneTitle:"Sahne",sceneReset:"Sahneyi temizle",sceneResetConfirm:"Net sahneyi doğrulayın",sceneAddSphere:"Küre ekle",sceneAddCube:"Küp ekle",sceneAddCylinder:"Silindir ekle",sceneAddTorus:"Halka ekle",sceneSelection:"Seçim",sceneMerge:"Seçimi birleştir",sceneDuplicate:null,sceneDelete:"Seçimi sil",meshTitle:"Nesne",meshNbVertices:"Verteks : ",meshNbFaces:"Cephe : ",topologyTitle:"Topoloji",multiresTitle:"Çoklu çözünürlük",multiresSubdivide:"Böl",multiresReverse:"Ters",multiresResolution:"Çözünürlük",multiresNoLower:"Daha düşük çözünürlük yok.",multiresNoHigher:"Daha yüksek çözünürlük yok.",multiresDelHigher:"Üst çözünürlüğü sil",multiresDelLower:"Alt çözünürlüğü sil",multiresSelectLowest:"Tersine çevirmeden önce en düşük çözünürlüğü seç.",multiresSelectHighest:"Tesine çevirmeden önce en yüksek çözünürlüğü seç.",multiresWarnBigMesh:function(e){return"Sonraki çözünürlük "+e+' cepheden oluşacak.\nEğer devam etmek istiyorsanız, tekrar "böl" butonuna basın.'},multiresNotReversible:"Malesef bu nesneyi tersine çevirmek mümkün değil.\nThe mesh is not a product of a (loop-catmull) subdivision surface on a manifold mesh.",remeshTitle:"Voksel Remeshing",remeshRemesh:"Remesh",remeshResolution:"Çözünürlük",remeshBlock:"Engelle",dynamicTitle:"Dinamik Topoloji",dynamicActivated:"Aktifleştirildi (no quads)",dynamicSubdivision:"Altbölüm",dynamicDecimation:"Üstbölüm",dynamicLinear:"Doğrusal altbölüm",sculptTitle:"Oyma & Boyama",sculptBrush:"Fırça",sculptInflate:"Şişir",sculptTwist:"Bükülme",sculptSmooth:"Yumuşat (-Shift)",sculptFlatten:"Düzleştir",sculptPinch:"Çimdik",sculptCrease:"Kıvrım",sculptDrag:"Sürükle",sculptPaint:"Boya",sculptMasking:"Maskeleme (-Ctrl)",sculptMove:"Taşı",sculptLocalScale:"Yerel ölçek",sculptTransform:"Transform (E)",sculptCommon:"Genel",sculptTool:"Araç",sculptSymmetry:"Simetri",sculptContinuous:"Sürekli",sculptRadius:"Yarıçağ (-X)",sculptIntensity:"Yoğunluk (-C)",sculptHardness:"Sertlik",sculptCulling:"İnce yüzey (front vertex only)",sculptAlphaTitle:"Alfa",sculptLockPositon:"Pozisyonu kilitle",sculptAlphaTex:"Kaplama",sculptImportAlpha:"Alfa kaplama yükle (jpg, png...)",sculptNegative:"Negatif (N or -Alt)",sculptColor:"Aklık",sculptRoughness:"Pürüzlülük",sculptMetallic:"Metalik",sculptClay:"Kil",sculptAccumulate:"Biriktir (limitsiz)",sculptColorGlobal:"Evrensel",sculptPickColor:"Materyal / Renk seçici (-S)",sculptTangentialSmoothing:"Rahatlat",sculptTopologicalCheck:"Topoloji kontrol",sculptMoveAlongNormal:"Normal boyunca taşı (N or -Alt)",sculptMaskingClear:"Temizle (-Ctrl + Drag)",sculptMaskingInvert:"Tersine çevir (-Ctrl + Click)",sculptMaskingBlur:"Bulanıklaştır",sculptMaskingSharpen:"Keskinleştir",sculptPBRTitle:"PBR materyali",sculptPaintAll:"Tümünü boya",sculptExtractTitle:ıkar",sculptExtractThickness:"Kalınlık",sculptExtractAction:ıkar !",stateTitle:"Geçmiş",stateUndo:"Geri Al",stateRedo:"İleri Al",stateMaxStack:"Maksimum Yığın",pressureTitle:"Tablet pressure",pressureRadius:"Basınç çapı",pressureIntensity:"Basınç hassasiyeti",renderingTitle:"Sahneleme",renderingGrid:"Izgarayı göster",renderingSymmetryLine:"aynalama çizgisini göster",renderingMatcap:"Matcap",renderingCurvature:"Eğrilik",renderingPBR:"PBR",renderingTransparency:"Transparanlık",renderingNormal:"Normal shader",renderingUV:"UV shader",renderingShader:"Shader",renderingMaterial:"Materyal",renderingImportUV:"İçe AKtar (jpg, png...)",renderingImportMatcap:"İçe AKtar (jpg, png...)",renderingExtra:"Ekstra",renderingFlat:"Düz gölgeleme",renderingWireframe:"Tel kafes (W)",renderingExposure:"Teşir",renderingEnvironment:"Ortam",renderingIsolate:"İzole/Göster (I)",renderingFilmic:"Film Ton Eşleşmesi",contour:"Kontür",contourShow:"Kontürü göster",contourColor:"Renk",darkenUnselected:"Seçilmeyenleri koyu yap",resolution:"Çözünürlük",matcapPearl:"İnci",matcapClay:"Kil",matcapSkin:"Deri",matcapGreen:"Yeşil",matcapWhite:"Beyaz",sketchfabTitle:"Sketchfab'a git !",sketchfabUpload:"Yükle",sketchfabUploadMessage:'Lütfen sketchfab entegrasyon anahtarını giriniz.\nAnonim olarak kullanmak için "guest" olarak bırakınız.\n(İşleme ve yükleme tamamlandığında yeni bir pencere açılacak)',sketchfabUploadError:function(e){return"Sketchfab yükleme hatası :\n"+e},sketchfabUploadSuccess:"Yükleme başarılı !\nAdresiniz burada :",sketchfabAbort:"Son yüklemeyi iptal et ?",sketchfabUploadProcessing:"Hesaplanıyor...\nModeliniz şu adreste olacak :",about:"Hakkında & Yardım",alphaNone:"Hiç Biri",alphaSquare:"Kare",alphaSkin:"Deri"},svenska:{backgroundTitle:"Bakgrund",backgroundReset:"Återställ",backgroundImport:"Importera (jpg, png...)",backgroundFill:"Fyll",cameraTitle:"Kamera",cameraReset:"Vy",cameraCenter:"Återställ (bar)",cameraFront:"Fram (F)",cameraLeft:"Vänster (L)",cameraTop:"Över (T)",cameraMode:"Läge",cameraOrbit:"Omloppsbana (skivtallrik)",cameraSpherical:"Sfärisk (trackball)",cameraPlane:"Plan (trackball)",cameraProjection:"Projektion",cameraPerspective:"Perspektiv",cameraOrthographic:"Ortografisk",cameraFov:"Fov",cameraPivot:"Plocka pivot",fileTitle:"Filer (import/export)",fileImportTitle:"Importera",fileAdd:"Lägg till (obj, sgl, ply, stl)",fileAutoMatrix:"Skala och centrera",fileVertexSRGB:"sRGB vertexfärg",fileExportSceneTitle:"Exportera Scen",fileExportAll:"Exportera alla",fileExportSGL:"Spara .sgl (SculptGL)",fileExportOBJ:"Spara .obj",fileExportPLY:"Spara .ply",fileExportSTL:"Spara .stl",fileExportTextureTitle:null,fileExportTextureSize:null,fileExportColor:null,fileExportRoughness:null,fileExportMetalness:null,sceneTitle:"Scen",sceneReset:"Rensa scen",sceneResetConfirm:"Bekräfta klar scen",sceneAddSphere:"Lägg till sfär",sceneAddCube:"Lägg till kub",sceneAddCylinder:"Lägg till cylinder",sceneAddTorus:"Lägg till torus",sceneSelection:"Urval",sceneMerge:"Sammanfoga urval",sceneDuplicate:null,sceneDelete:"Radera valet",meshTitle:"Mesh",meshNbVertices:"Vertex : ",meshNbFaces:"Faces : ",topologyTitle:"Topologi",multiresTitle:"Upplösningar",multiresSubdivide:"Dela upp yta",multiresReverse:"Omvänd",multiresResolution:"Upplösning",multiresNoLower:"Det finns ingen lägre upplösningsnivå.",multiresNoHigher:"Det finns ingen högre upplösningsnivå.",multiresDelHigher:"Ta bort högre",multiresDelLower:"Ta bort lägre",multiresSelectLowest:"Välj den lägsta upplösningen innan omvändning.",multiresSelectHighest:"Välj den högsta upplösningen innan uppdelning.",multiresWarnBigMesh:function(e){return"Nästa underavdelning nivå kommer att ha "+e+' faces.\nOm du vet vad du gör, klicka igen på "dela upp yta".'},multiresNotReversible:"Tyvärr, det går inte att omvända denna mesh.\nMeshen är inte en produkt av en (loop-calmull) mångfaldsytindelning.",remeshTitle:"Voxel Meshombyggnation",remeshRemesh:"Bygg om mesh",remeshResolution:"Upplösning",remeshBlock:"Kuber",dynamicTitle:"Dynamisk Topologi",dynamicActivated:"Aktiverad (inga quads)",dynamicSubdivision:"Ytindelning",dynamicDecimation:"Decimering",dynamicLinear:"Linjär ytindelning",sculptTitle:"Skulptering & Måleri",sculptBrush:"Pensel",sculptInflate:"Blås upp",sculptTwist:"Tvista",sculptSmooth:"Jämna ut (-Shift)",sculptFlatten:"Platta till",sculptPinch:"Nyp",sculptCrease:"Vecka",sculptDrag:"Dra",sculptPaint:"Måla",sculptMasking:"Maskera (-Ctrl)",sculptMove:"Flytta",sculptLocalScale:"Skala lokalt",sculptTransform:"Transformera (E)",sculptCommon:"Generellt",sculptTool:"Verktyg",sculptSymmetry:"Symmetri",sculptContinuous:"Kontinuerlig",sculptRadius:"Radie (-X)",sculptIntensity:"Intensitet (-C)",sculptHardness:"Hårdhet",sculptCulling:"Tunn yta (endast främre vertex)",sculptAlphaTitle:"Alfa",sculptLockPositon:"Lås position",sculptAlphaTex:"Textur",sculptImportAlpha:"Importera alfatextur (jpg, png...)",sculptNegative:"Negativ (N or -Alt)",sculptColor:"Albedo",sculptRoughness:"Ytjämnhet",sculptMetallic:"Metallisk",sculptClay:"Lera",sculptAccumulate:"Ackumulera (ingen gräns per strykning)",sculptColorGlobal:"Global",sculptPickColor:"Material / Färgvälgare (-S)",sculptTangentialSmoothing:"Tangentiell utjämning",sculptTopologicalCheck:"Topologisk check",sculptMoveAlongNormal:"Flytta längsmed normal (N or -Alt)",sculptMaskingClear:"Rensa (-Ctrl + Drag)",sculptMaskingInvert:"Invertera (-Ctrl + Click)",sculptMaskingBlur:"Gör suddig",sculptMaskingSharpen:"Gör skarp",sculptPBRTitle:"PBR-material",sculptPaintAll:"Måla allt",sculptExtractTitle:"Extrahera",sculptExtractThickness:"Tjocklek",sculptExtractAction:"Extrahera!",stateTitle:"Historia",stateUndo:"Ångra",stateRedo:"Gör om",stateMaxStack:"Ågra antal steg",pressureTitle:"pressureplatta",pressureRadius:"Tryckradie",pressureIntensity:"Tryckintensitet",renderingTitle:"Rendering",renderingGrid:"Visa rutnät",renderingSymmetryLine:"Visa speglingslinje",renderingMatcap:"MatCap",renderingCurvature:"Kurvatur",renderingPBR:"PBR",renderingTransparency:"Genomskinlighet",renderingNormal:"Normal shader",renderingUV:"UV-shader",renderingShader:"Shader",renderingMaterial:"Material",renderingImportUV:"Importera (jpg, png...)",renderingImportMatcap:"Importera (jpg, png...)",renderingExtra:"Extra",renderingFlat:"Platt shading",renderingWireframe:"Wireframe (W)",renderingExposure:"Exponering",renderingEnvironment:"Miljö",renderingIsolate:"Isolera/Visa (I)",renderingFilmic:"Filmiska färgtoner",contour:"Kontur",contourShow:"Visa kontur",contourColor:"Färg",darkenUnselected:"Skym ej valda",resolution:"Upplösning",matcapPearl:"Pärla",matcapClay:"Lera",matcapSkin:"Hud",matcapGreen:"Grön",matcapWhite:"Vit",sketchfabTitle:"Gå till Sketchfab!",sketchfabUpload:"Ladda upp",sketchfabUploadMessage:'Vänligen fyll i din sketchfab API-nyckel.\nDu kan även ange "guest" för att ladda upp anonymt.\n(ett nytt fönster kommer att öppnas när uppladdning och bearbetning är klar)',sketchfabUploadError:function(e){return"Sketchfab uppladdningsfel:\n"+e},sketchfabUploadSuccess:"Uppladdning lyckades!\nHär är din länk:",sketchfabAbort:"Avbryta senaste uppladdningen?",sketchfabUploadProcessing:"Bearbetar...\nDin modell kommer bli tillgänglig här:",about:"Om & Hjälp",alphaNone:"Ingen",alphaSquare:"Fyrkant",alphaSkin:"Hud"},français:{backgroundTitle:"Fond d'écran",backgroundReset:"Réinitialiser",backgroundImport:"Importer (jpg, png...)",backgroundFill:"Remplir",cameraTitle:"Caméra",cameraReset:"Vue",cameraCenter:"Reset (bar)",cameraFront:"De face (F)",cameraLeft:"De gauche (L)",cameraTop:"De haut (T)",cameraMode:"Mode",cameraOrbit:"Orbite (Turntable)",cameraSpherical:"Spherique (Trackball)",cameraPlane:"Planaire (Trackball)",cameraProjection:"Projection",cameraPerspective:"Perspective",cameraOrthographic:"Orthographique",cameraFov:"Champs de vision",cameraPivot:"Point de pivot",fileTitle:"Fichiers (importer/exporter)",fileImportTitle:"Importer",fileAdd:"Ajouter (obj, sgl, ply, stl)",fileAutoMatrix:"Mise a l'échelle et centrage",fileVertexSRGB:"Couleur de vertex en sRGB",fileExportSceneTitle:"Exporter Scene",fileExportAll:"Tout exporter",fileExportSGL:"Sauver .sgl (SculptGL)",fileExportOBJ:"Sauver .obj",fileExportPLY:"Sauver .ply",fileExportSTL:"Sauver .stl",fileExportTextureTitle:null,fileExportTextureSize:null,fileExportColor:null,fileExportRoughness:null,fileExportMetalness:null,sceneTitle:"Scène",sceneReset:"Réinitialiser scène",sceneResetConfirm:"Confirmer réinitialiser la scène?",sceneAddSphere:"Ajouter sphere",sceneAddCube:"Ajouter cube",sceneAddCylinder:"Ajouter cylindre",sceneAddTorus:"Ajouter tore",sceneSelection:"Sélection",sceneMerge:"Fusionner selection",sceneDuplicate:null,sceneDelete:"Supprimer la sélection",meshTitle:"Mesh",meshNbVertices:"Vertex : ",meshNbFaces:"Faces : ",topologyTitle:"Topologie",multiresTitle:"Multirésolution",multiresSubdivide:"Subdiviser",multiresReverse:"Inverser",multiresResolution:"Résolution",multiresNoLower:"Il n'y a pas de niveau de résolution inférieur.",multiresNoHigher:"Il n'y a pas de niveau de résolution plus élevé.",multiresDelHigher:"Suppression supérieur",multiresDelLower:"Suppression inférieur",multiresSelectLowest:"Sélectionnez la résolution la plus basse avant d'inverser.",multiresSelectHighest:"Sélectionnez la résolution la plus élevée avant de subdiviser.",multiresWarnBigMesh:function(e){return"Le prochain niveau de subdivision atteindra "+e+' faces.\nSi vous savez ce que vous faites, cliquez de nouveau sur "subdiviser".'},multiresNotReversible:"Désolé, il n'est pas possible d'inverser ce maillage.\nLe mesh n'est pas un produit d'une surface de subdivision (loop-catmull) provenant manifold.",remeshTitle:"Remaillage volumétrique",remeshRemesh:"Remaillage",remeshResolution:"Résolution",remeshBlock:"Bloc",dynamicTitle:"Topologie dynamique",dynamicActivated:"Activaté (pas quads)",dynamicSubdivision:"Subdivision",dynamicDecimation:"Décimation",dynamicLinear:"Subdivision linéaire",sculptTitle:"Sculpture & Painture",sculptBrush:"Brosse",sculptInflate:"Gonfler",sculptTwist:"Tordre",sculptSmooth:"Lisser (-Shift)",sculptFlatten:"Aplatir",sculptPinch:"Pincer",sculptCrease:"Plier",sculptDrag:"Tirer",sculptPaint:"Peindre",sculptMasking:"Masquer (-Ctrl)",sculptMove:"Bouger",sculptLocalScale:"Mise à l'échelle locale",sculptTransform:"Transformer (E)",sculptCommon:"Commun",sculptTool:"Outil",sculptSymmetry:"Symétrie",sculptContinuous:"Continu",sculptRadius:"Rayon (-X)",sculptIntensity:"Intensité (-C)",sculptHardness:"Dureté",sculptCulling:"Surface fine (vertex de face uniquement)",sculptAlphaTitle:"Alpha",sculptLockPositon:"Bloquer position",sculptAlphaTex:"Texture",sculptImportAlpha:"Importer texture alpha (jpg, png...)",sculptNegative:"Négatif (N ou -Alt)",sculptColor:"Albedo",sculptRoughness:"Rugosité",sculptMetallic:"Métallique",sculptClay:"Argile",sculptAccumulate:"Accumuler effet",sculptColorGlobal:"Global",sculptPickColor:"Matériau / selection de couleur (-S)",sculptTangentialSmoothing:"Relaxer uniquement",sculptTopologicalCheck:"Vérification topologique",sculptMoveAlongNormal:"Extruder suivant la normale (N ou -Alt)",sculptMaskingClear:"Reset (-Ctrl + Drag)",sculptMaskingInvert:"Inverser (-Ctrl + Click)",sculptMaskingBlur:"Brouiller",sculptMaskingSharpen:"Aiguiser",sculptPBRTitle:"Matériaux physiques (PBR)",sculptPaintAll:"Peindre tout",sculptExtractTitle:"Extraire",sculptExtractThickness:"Epaisseur",sculptExtractAction:"Extraire !",stateTitle:"Historique",stateUndo:"Annuler",stateRedo:"Refaire",stateMaxStack:"Nombre maximale d'action",pressureTitle:"Pression de la tablette",pressureRadius:"Pression sur le rayon",pressureIntensity:"Pression sur l'intensité",renderingTitle:"Rendu",renderingGrid:"Afficher grille",renderingSymmetryLine:"Afficher ligne de symétrie",renderingMatcap:"Matcap",renderingCurvature:"Courbure",renderingPBR:"PBR",renderingTransparency:"Transparence",renderingNormal:"Normal shader",renderingUV:"UV shader",renderingShader:"Shader",renderingMaterial:"Matériau",renderingImportUV:"Importer (jpg, png...)",renderingImportMatcap:"Importer (jpg, png...)",renderingExtra:"Extra",renderingFlat:"Ombrage plat",renderingWireframe:"Fil de fer (W)",renderingExposure:"Exposition",renderingEnvironment:"Environment",renderingIsolate:"Isoler/Afficher (I)",renderingFilmic:"Tonemapping filmique",contour:"Contour",contourShow:"Afficher les contours",contourColor:"Couleur",darkenUnselected:"Assombrir non séléctioné",resolution:"Résolution",matcapPearl:"Perle",matcapClay:"Argile",matcapSkin:"Peau",matcapGreen:"Vert",matcapWhite:"Blanc",sketchfabTitle:"Vers Sketchfab !",sketchfabUpload:"Uploader",sketchfabUploadMessage:"Entrez votre clé d'API sketchfab.\n",sketchfabUploadError:function(e){return"Sketchfab upload error :\n"+e},sketchfabUploadSuccess:"Téléchargement fini !\nVoici le lien :",sketchfabAbort:"Annuler le dernier téléchargement ?",sketchfabUploadProcessing:"En traitement...\nLe modèle sera disponible sur :",about:"A propos & aide",alphaNone:"Vide",alphaSquare:"Carré",alphaSkin:"Peau",remeshTitleMC:"Remaillage surfacique (manifold tris)",remeshRemeshMC:"Remaillage",remeshSmoothingMC:"Lisser topologie"},deutsch:{backgroundTitle:"Hintergrund",backgroundReset:"Zurücksetzen",backgroundImport:"Importieren (jpg, png...)",backgroundFill:"Füllen",cameraTitle:"Kamera",cameraReset:"Ansicht",cameraCenter:"Reset (space)",cameraFront:"Front (F)",cameraLeft:"Links (L)",cameraTop:"Oben (T)",cameraMode:"Modus",cameraOrbit:"Orbit (Drehscheibe)",cameraSpherical:"Sphärisch (Rollkugel)",cameraPlane:"Ebene (Rollkugel)",cameraProjection:"Projektion",cameraPerspective:"Perspektivisch",cameraOrthographic:"Orthographisch",cameraFov:"Sichtfeld (fov)",cameraPivot:"Pivot auswählen",fileTitle:"Datei (import/export)",fileImportTitle:"Importieren",fileAdd:"Hinzufügen (obj, sgl, ply, stl)",fileAutoMatrix:"Skalieren und zentrieren",fileVertexSRGB:"Vertexfarbe sRGB",fileExportSceneTitle:"Exportieren",fileExportAll:"Alles Exportieren",fileExportSGL:"Speichern .sgl (SculptGL)",fileExportOBJ:"Speichern .obj",fileExportPLY:"Speichern .ply",fileExportSTL:"Speichern .stl",fileExportTextureTitle:"Texturen exportieren",fileExportTextureSize:"Größe",fileExportColor:"Farben speichern",fileExportRoughness:"Rauheit speichern",fileExportMetalness:"Metallisches speichern",sceneTitle:"Szene",sceneReset:"Szene löschen",sceneResetConfirm:"Bestätige das Löschen der aktuellen Szene",sceneAddSphere:"Kugel hinzufügen",sceneAddCube:"Würfel hinzufügen",sceneAddCylinder:"Zylinder hinzufügen",sceneAddTorus:"Torus hinzufügen",sceneSelection:"Auswahl",sceneMerge:"Auswahl zusammenführen",sceneDuplicate:"Auswahl kopieren",sceneDelete:"Auswahl löschen",meshTitle:"Mesh",meshNbVertices:"Vertex : ",meshNbFaces:"Faces : ",topologyTitle:"Topologie",multiresTitle:"Mehrfachauflösung",multiresSubdivide:"Aufteilen",multiresReverse:"Umkehren",multiresResolution:"Auflösung",multiresNoLower:"Es gibt keine kleinere Auflösung.",multiresNoHigher:"Es gibt keine höhere Auflösung.",multiresDelHigher:"Höhere löschen",multiresDelLower:"Niedrigere löschen",multiresSelectLowest:"Wählen Sie vor dem Umkehren die kleinste Auflösung aus.",multiresSelectHighest:"Wählen Sie vor dem Umkehren die höchste Auflösung aus.",multiresWarnBigMesh:function(e){return"Die nächste Unterteilungsebene wird "+e+' Flächen erreichen\nWenn Sie wissen, was Sie tun, dann klicken Sie nocheinmal auf "umkehren".'},multiresNotReversible:"Es ist leider nicht möglich dieses Netz umzukehren.\nDas Netz ist kein Produkt einer (loop/catmull) Unterteilungsfläche auf eines mannigfaltigen Netzes",remeshTitle:"Voxel remeshing (Vierecke)",remeshRemesh:"Remesh",remeshResolution:"Auflösung",remeshBlock:"Block",dynamicTitle:"Dynamische Topologie",dynamicActivated:"Aktiviert (ohne Vierecke)",dynamicSubdivision:"Aufteilung",dynamicDecimation:"Dezimierung",dynamicLinear:"Lineare Aufteilung",sculptTitle:"Modellieren & Bemalen",sculptBrush:"Pinsel",sculptInflate:"Aufblasen",sculptTwist:"Verdrehen",sculptSmooth:"Glätten (-Shift)",sculptFlatten:"Ebnen",sculptPinch:"Kneifen",sculptCrease:"Falten",sculptDrag:"Ziehen",sculptPaint:"Malen",sculptMasking:"Maskieren (-Strg)",sculptMove:"Bewegen",sculptLocalScale:"Lokales Skalieren",sculptTransform:"Transformieren (E)",sculptCommon:"Allgemein",sculptTool:"Werkzeuge",sculptSymmetry:"Symmetrie",sculptContinuous:"Kontinuierlich",sculptRadius:"Radius (-X)",sculptIntensity:"Intensität (-C)",sculptHardness:"Härte",sculptCulling:"Dünne Oberfläche (nur vorderer vertex)",sculptAlphaTitle:"Alpha",sculptLockPositon:"Verriegelungsposition",sculptAlphaTex:"Textur",sculptImportAlpha:"Alpha tex importieren(jpg, png...)",sculptNegative:"Negativ (N or -Alt)",sculptColor:"Albedo",sculptRoughness:"Rauheit",sculptMetallic:"Metallisches",sculptClay:"Lehm",sculptAccumulate:"Akkumulieren (Kein Limit pro Anschlag)",sculptColorGlobal:"Global",sculptPickColor:"Material / Farb Auswahl (-S)",sculptTangentialSmoothing:"Tangentiale Glättung",sculptTopologicalCheck:"Topologischer Check",sculptMoveAlongNormal:"Normal weiterlaufen (N or -Alt)",sculptMaskingClear:"Löschen (-Ctrl + Drag)",sculptMaskingInvert:"Invertieren (-Ctrl + Click)",sculptMaskingBlur:"Verwischen",sculptMaskingSharpen:"Schärfen",sculptPBRTitle:"PBR Materialen",sculptPaintAll:"Alles Anmalen",sculptExtractTitle:"Extrahieren",sculptExtractThickness:"Dicke",sculptExtractAction:"Extrahieren !",stateTitle:"Verlauf",stateUndo:"Rückgängig",stateRedo:"Wiederholen",stateMaxStack:"Max. Schritte",pressureTitle:"Tablet Druck",pressureRadius:"Druckradius",pressureIntensity:"Druckintensität",renderingTitle:"Rendering",renderingGrid:"Gitter anzeigen",renderingSymmetryLine:"Spiegellinie anzeigen",renderingMatcap:"Matcap",renderingCurvature:"Krümmung",renderingPBR:"PBR",renderingTransparency:"Transparenz",renderingNormal:"Normale Shader",renderingUV:"UV shader",renderingShader:"Shader",renderingMaterial:"Material",renderingImportUV:"Importieren (jpg, png...)",renderingImportMatcap:"Importieren (jpg, png...)",renderingExtra:"Extra",renderingFlat:"Flaches Schattieren",renderingWireframe:"Drahtgitter (W)",renderingExposure:"Belichtung",renderingEnvironment:"Umgebung",renderingIsolate:"Isoliert/Zeige (I)",renderingFilmic:"Filmische Tonzuordnung",contour:"Kontur",contourShow:"Kontur anzeigen",contourColor:"Farbe",darkenUnselected:"Nicht markiertes abdunkeln",resolution:"Auflösung",matcapPearl:"Perle",matcapClay:"Ton",matcapSkin:"Haut",matcapGreen:"Grün",matcapWhite:"Weiß",sketchfabTitle:"Hier gehts zu Sketchfab !",sketchfabUpload:"Hochladen",sketchfabUploadMessage:'Please enter your sketchfab API Key.\nYou can also leave "guest" to upload anonymously.\n(a new window will pop up when the uploading and processing is finished)',sketchfabUploadError:function(e){return"Sketchfab upload error :\n"+e},sketchfabUploadSuccess:"Upload success !\nHere is your link :",sketchfabAbort:"Abort the last upload ?",sketchfabUploadProcessing:"Processing...\nYour model will be available at :",about:"Über & Hilfe (Englisch)",alphaNone:"None",alphaSquare:"Würfel",alphaSkin:"Haut",remeshTitleMC:"Voxel remeshing (mannigfaltige Dreiecke)",remeshRemeshMC:"Remesh",remeshSmoothingMC:"Topologie entspannen"},italiano:{backgroundTitle:"Sfondo",backgroundReset:"Resetta",backgroundImport:"Importa (jpg, png...)",backgroundFill:"Riempi",cameraTitle:"Camera",cameraReset:"Vista",cameraCenter:"Resetta (bar)",cameraFront:"Fronte (F)",cameraLeft:"Sinistra (L)",cameraTop:"Sopra (T)",cameraMode:"Modalitá",cameraOrbit:"Orbita (Ruota intorno)",cameraSpherical:"Sferica (Trackball)",cameraPlane:"Planare (Trackball)",cameraProjection:"Proiezione",cameraPerspective:"Prospettiva",cameraOrthographic:"Ortografica",cameraFov:"Fov",cameraPivot:"Seleziona pivot",fileTitle:"Files (importa/esporta)",fileImportTitle:"Importa",fileAdd:"Aggiungi (obj, sgl, ply, stl)",fileAutoMatrix:"Scala e centra",fileVertexSRGB:"sRGB vertex color",fileExportSceneTitle:"Esporta Scena",fileExportAll:"Exporta tutto",fileExportSGL:"Salva .sgl (SculptGL)",fileExportOBJ:"Salva .obj",fileExportPLY:"Salva .ply",fileExportSTL:"Salva .stl",fileExportTextureTitle:"Esporta textures",fileExportTextureSize:"Dimensione",fileExportColor:"Salva diffuse",fileExportRoughness:"Salva roughness",fileExportMetalness:"Salva metalness",sceneTitle:"Scena",sceneReset:"Pulisci scena",sceneResetConfirm:"Conferma pulitura scena",sceneAddSphere:"Aggiungi sfera",sceneAddCube:"Aggiungi cubo",sceneAddCylinder:"Aggiungi cilindro",sceneAddTorus:"Aggiungi toroide",sceneSelection:"Selezione",sceneMerge:"Unisci selezione",sceneDuplicate:"Copia selezione",sceneDelete:"Elimina selezione",meshTitle:"Mesh",meshNbVertices:"Vertex : ",meshNbFaces:"Faces : ",topologyTitle:"Topologia",multiresTitle:"Multirisoluzione",multiresSubdivide:"Suddivisione",multiresReverse:"Invertire",multiresResolution:"Risoluzione",multiresNoLower:"Non esiste un livello di risoluzione inferiore.",multiresNoHigher:"Non esiste un livello di risoluzione più alto.",multiresDelHigher:"Elimina superiore",multiresDelLower:"Elimina inferiore",multiresSelectLowest:"Selezionare la risoluzione più bassa prima di invertire.",multiresSelectHighest:"Seleziona la risoluzione più alta prima di suddividere.",multiresWarnBigMesh:function(e){return"Il livello di suddivisione successivo raggiungerà "+e+' facce.\nSe sai cosa stai facendo, clicca di nuovo su "Suddividi".'},multiresNotReversible:"Spiacenti, non è possibile invertire questa mesh.\nLa mesh non è un prodotto di una superficie di suddivisione (loop-catmull) su una mesh collettore.",remeshTitle:"Voxel remeshing (quads)",remeshRemesh:"Remesh",remeshResolution:"Risolutione",remeshBlock:"Blocca",dynamicTitle:"Topologia Dinamica",dynamicActivated:"Attivata (no quads)",dynamicSubdivision:"Suddivisione",dynamicDecimation:"Decimazione",dynamicLinear:"Suddivisione Lineare",sculptTitle:"Scalpisci & Dipingi",sculptBrush:"Spazzola",sculptInflate:"Gonfia",sculptTwist:"Torci",sculptSmooth:"Ammorbidisci (-Shift)",sculptFlatten:"Appiattisci",sculptPinch:"Pizzica",sculptCrease:"Piega",sculptDrag:"Trascina",sculptPaint:"Dipingi",sculptMasking:"Maschera (-Ctrl)",sculptMove:"Muovi",sculptLocalScale:"Scala Locale",sculptTransform:"Trasformazioni (E)",sculptCommon:"Comune",sculptTool:"Strumento",sculptSymmetry:"Simmetria",sculptContinuous:"Continua",sculptRadius:"Raggio (-X)",sculptIntensity:"Intensità (-C)",sculptHardness:"Durezza",sculptCulling:"Superficie sottile (solo vertici frontali)",sculptAlphaTitle:"Alpha",sculptLockPositon:"Blocca posizione",sculptAlphaTex:"Texture",sculptImportAlpha:"Importa alpha tex (jpg, png...)",sculptNegative:"Negativo (N or -Alt)",sculptColor:"Albedo",sculptRoughness:"Rugosità",sculptMetallic:"Metallico",sculptClay:"Clay",sculptAccumulate:"Accumulazione (no limit per stroke)",sculptColorGlobal:"Globale",sculptPickColor:"Materiale / Color picker (-S)",sculptTangentialSmoothing:"Solo Relax",sculptTopologicalCheck:"Controllo Topologia",sculptMoveAlongNormal:"Muovi lungo la normale (N o -Alt)",sculptMaskingClear:"Pulisci (-Ctrl + Drag)",sculptMaskingInvert:"Inverti (-Ctrl + Click)",sculptMaskingBlur:"Sfoca",sculptMaskingSharpen:"Nitidezza",sculptPBRTitle:"Materiali PBR",sculptPaintAll:"Dipingi tutto",sculptExtractTitle:"Estrazione",sculptExtractThickness:"Assottigliamento",sculptExtractAction:"Estrai !",stateTitle:"Story",stateUndo:"Indietro",stateRedo:"Avanti",stateMaxStack:"Pila massima",pressureTitle:"Pressione tavoletta",pressureRadius:"Raggio pressione",pressureIntensity:"Intensità pressione",renderingTitle:"Rendering",renderingGrid:"Vedi Griglia",renderingSymmetryLine:"Vedi linea di specchiatura",renderingMatcap:"Matcap",renderingCurvature:"Curvature",renderingPBR:"PBR",renderingTransparency:"Trasparenza",renderingNormal:"Normal shader",renderingUV:"UV shader",renderingShader:"Shader",renderingMaterial:"Materiale",renderingImportUV:"Importa (jpg, png...)",renderingImportMatcap:"Importa (jpg, png...)",renderingExtra:"Extra",renderingFlat:"Shading piatto",renderingWireframe:"Wireframe (W)",renderingExposure:"Esposizione",renderingEnvironment:"Ambiente",renderingIsolate:"Isola/Vedi (I)",renderingFilmic:"Coloritura tipo Film",contour:"Contorno",contourShow:"Vedi contorno",contourColor:"Colore",darkenUnselected:"Scurisci i non selezionati",resolution:"Risolutione",matcapPearl:"Perla",matcapClay:"Argilla",matcapSkin:"Pelle",matcapGreen:"Verde",matcapWhite:"Bianco",sketchfabTitle:"Vai su Sketchfab !",sketchfabUpload:"Upload",sketchfabUploadMessage:'Inserisci la tua chiave API di sketchfab.\nPuoi anche lasciare "guest" per caricare in modo anonimo.\n(verrà visualizzata una nuova finestra al termine del caricamento e dell\'elaborazione)',sketchfabUploadError:function(e){return"Sketchfab errore upload :\n"+e},sketchfabUploadSuccess:"Caricato con successo !\nEcco il tuo link :",sketchfabAbort:"Annulla l'ultimo caricamento?",sketchfabUploadProcessing:"Processing...\nIl tuo modello sarà disponibile su :",about:"Informazioni & Aiuto",alphaNone:"Nessuno",alphaSquare:"Quadrata",alphaSkin:"Pelle",remeshTitleMC:"Voxel remeshing (manifold tris)",remeshRemeshMC:"Remesh",remeshSmoothingMC:"Relax topology"}},o.select="english";var l=window.navigator.language||window.navigator.userLanguage;switch(l&&(l=l.substr(0,2)),"ja"===l?o.select="日本語":"zh"===l?o.select="中文":"ko"===l?o.select="한국어":"tr"===l?o.select="turkish":"sv"===l?o.select="svenska":"fr"===l?o.select="français":"de"===l&&(o.select="deutsch"),(0,i.Z)().language){case"english":o.select="english";break;case"chinese":o.select="中文";break;case"korean":o.select="한국어";break;case"japanese":o.select="日本語";break;case"russian":o.select="русский";break;case"turkish":o.select="turkish";break;case"swedish":o.select="svenska";break;case"french":o.select="français";break;case"german":o.select="deutsch";break;case"italian":o.select="italiano"}const u=o},165:(e,t,r)=>{"use strict";r.d(t,{Z:()=>T});var i,n,a,s,o,l,u,c,h,d,f,_,p,g,m,v,y=r(928),b={normalizedMouse:function(e,t,r,i){return[2*e/r-1,1-2*t/i]},mouseOnUnitSphere:function(e){var t=e[0],r=e[1],i=1-t*t-r*r,n=[t,r,i>0?Math.sqrt(i):0];return y.Fv(n,n)}};b.intersectionRayTriangleEdges=(i=1+1e-15,n=-1e-15,a=[0,0,0],s=[0,0,0],o=[0,0,0],function(e,t,r,l,u,c){y.kC(a,t,l);var h=y.AK(r,a);if(h>-1e-15&&h<1e-15)return-1;var d=1/h;y.lu(s,e,u);var f=y.AK(s,a)*d;if(f<n||f>i)return-1;y.kC(o,s,r);var _=y.AK(t,o)*d;if(_<n||f+_>i)return-1;var p=y.AK(l,o)*d;return p<n?-1:(c&&y.od(c,e,t,p),p)}),b.intersectionRayTriangle=(l=[0,0,0],u=[0,0,0],function(e,t,r,i,n,a){return y.lu(l,i,r),y.lu(u,n,r),b.intersectionRayTriangleEdges(e,t,l,u,r,a)}),b.distance2PointTriangleEdges=(c=[0,0,0],function(e,t,r,i,n,a,s,o){y.lu(c,i,e);var l,u,h,d,f,_=y.AK(c,t),p=y.AK(c,r),g=y.x9(c),m=Math.abs(n*s-a*a),v=a*p-s*_,b=a*_-n*p,T=4;if(v+b<=m)if(v<0)b<0?(T=4,_<0?(b=0,-_>=n?(v=1,l=n+2*_+g):l=_*(v=-_/n)+g):(v=0,p>=0?(b=0,l=g):-p>=s?(b=1,l=s+2*p+g):l=p*(b=-p/s)+g)):(T=3,v=0,p>=0?(b=0,l=g):-p>=s?(b=1,l=s+2*p+g):l=p*(b=-p/s)+g);else if(b<0)T=5,b=0,_>=0?(v=0,l=g):-_>=n?(v=1,l=n+2*_+g):l=_*(v=-_/n)+g;else{T=0;var M=1/m;l=(v*=M)*(n*v+a*(b*=M)+2*_)+b*(a*v+s*b+2*p)+g}else v<0?(T=2,(h=s+p)>(u=a+_)?(d=h-u)>=(f=n-2*a+s)?(v=1,b=0,l=n+2*_+g):l=(v=d/f)*(n*v+a*(b=1-v)+2*_)+b*(a*v+s*b+2*p)+g:(v=0,h<=0?(b=1,l=s+2*p+g):p>=0?(b=0,l=g):l=p*(b=-p/s)+g)):b<0?(T=6,(h=n+_)>(u=a+p)?(d=h-u)>=(f=n-2*a+s)?(b=1,v=0,l=s+2*p+g):l=(v=1-(b=d/f))*(n*v+a*b+2*_)+b*(a*v+s*b+2*p)+g:(b=0,h<=0?(v=1,l=n+2*_+g):_>=0?(v=0,l=g):l=_*(v=-_/n)+g)):(T=1,(d=s+p-a-_)<=0?(v=0,b=1,l=s+2*p+g):d>=(f=n-2*a+s)?(v=1,b=0,l=n+2*_+g):l=(v=d/f)*(n*v+a*(b=1-v)+2*_)+b*(a*v+s*b+2*p)+g);return l<0&&(l=0),o&&(o[0]=i[0]+v*t[0]+b*r[0],o[1]=i[1]+v*t[1]+b*r[1],o[2]=i[2]+v*t[2]+b*r[2],o[3]=T),l}),b.distance2PointTriangle=function(){var e=[0,0,0],t=[0,0,0];return function(r,i,n,a,s){y.lu(e,n,i),y.lu(t,a,i);var o=y.x9(e),l=y.AK(e,t),u=y.x9(t);return b.distance2PointTriangleEdges(r,e,t,i,o,l,u,s)}}(),b.pointInsideTriangle=(h=[0,0,0],d=[0,0,0],f=[0,0,0],_=[0,0,0],p=[0,0,0],function(e,t,r,i){y.lu(h,t,r),y.lu(d,t,i),y.lu(f,e,r),y.lu(_,e,i);var n=y.Zh(y.kC(p,h,d)),a=y.Zh(y.kC(p,h,f)),s=y.Zh(y.kC(p,d,_)),o=y.Zh(y.kC(p,f,_));return Math.abs(n-(a+s+o))<1e-20}),b.triangleInsideSphere=function(e,t,r,i,n){return b.distanceSqToSegment(e,r,i)<t||b.distanceSqToSegment(e,i,n)<t||b.distanceSqToSegment(e,r,n)<t},b.distanceSqToSegment=(g=[0,0,0],m=[0,0,0],function(e,t,r){y.lu(g,e,t),y.lu(m,r,t);var i=y.x9(m),n=y.AK(g,m)/i;return n<0?y.x9(g):n>1?y.x9(y.lu(g,e,r)):(g[0]=e[0]-t[0]-n*m[0],g[1]=e[1]-t[1]-n*m[1],g[2]=e[2]-t[2]-n*m[2],y.x9(g))}),b.signedAngle2d=function(e,t){var r=e[0],i=e[1],n=t[0],a=t[1];return Math.atan2(r*a-i*n,r*n+i*a)},b.pointPlaneDistance=function(){var e=[0,0,0];return function(t,r,i){return y.AK(y.lu(e,t,r),i)}}(),b.mirrorPoint=function(){var e=[0,0,0];return function(t,r,i){return y.lu(t,t,y.bA(e,i,2*b.pointPlaneDistance(t,r,i)))}}(),b.vertexOnLine=(v=[0,0,0],function(e,t,r){y.lu(v,r,t);var i=[0,0,0],n=y.AK(v,y.lu(i,e,t));return y.od(i,t,v,n/y.x9(v))}),b.intersectLinePlane=function(e,t,r,i,n){var a=y.AK(y.lu(n,e,r),i),s=y.AK(y.lu(n,t,r),i);if(a===s)return t;var o=-a/(s-a);return y.od(n,e,y.lu(n,t,e),o)},b.getPerpendicularVector=function(e){var t=[0,0,0];return 0===e[0]?t[0]=1:0===e[1]?t[1]=1:0===e[2]?t[2]=1:(t[0]=e[2],t[1]=e[2],t[2]=-e[0]-e[1],y.Fv(t,t)),t};const T=b},358:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{Z:()=>__WEBPACK_DEFAULT_EXPORT__});var gl_matrix__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(89),gl_matrix__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(928),math3d_Geometry__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(165),misc_Tablet__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(522),misc_Utils__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(781),gui_GuiTR__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(183);function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}var _TMP_NEAR=[0,0,0],_TMP_NEAR_1=[0,0,0],_TMP_FAR=[0,0,0],_TMP_INV=gl_matrix__WEBPACK_IMPORTED_MODULE_4__.Ue(),_TMP_INTER=[0,0,0],_TMP_INTER_1=[0,0,0],_TMP_V1=[0,0,0],_TMP_V2=[0,0,0],_TMP_V3=[0,0,0],Picking=function(){function e(t,r){_classCallCheck(this,e),this._mesh=null,this._main=t,this._pickedFace=-1,this._pickedVertices=[],this._interPoint=[0,0,0],this._rLocal2=0,this._rWorld2=0,this._eyeDir=[0,0,0],this._xSym=!!r,this._pickedNormal=[0,0,0],this._alphaOrigin=[0,0,0],this._alphaSide=0,this._alphaLookAt=gl_matrix__WEBPACK_IMPORTED_MODULE_4__.Ue(),this._alpha=null}return _createClass(e,[{key:"setIdAlpha",value:function(t){this._alpha=e.ALPHAS[t]}},{key:"getAlpha",value:function(e,t,r){var i=this._alpha;if(!i||!i._texture)return 1;var n=this._alphaLookAt,a=this._alphaSide,s=i._ratioY*(n[0]*e+n[4]*t+n[8]*r+n[12])/(this._xSym?-a:a);if(Math.abs(s)>1)return 0;var o=i._ratioX*(n[1]*e+n[5]*t+n[9]*r+n[13])/a;if(Math.abs(o)>1)return 0;var l=i._width;return s=(.5-.5*s)*l,o=(.5-.5*o)*i._height,i._texture[(0|s)+l*(0|o)]/255}},{key:"updateAlpha",value:function(e){var t=_TMP_V1,r=_TMP_V2,i=Math.sqrt(this._rLocal2);if(this._alphaSide=i*Math.SQRT1_2,gl_matrix__WEBPACK_IMPORTED_MODULE_5__.lu(t,this._interPoint,this._alphaOrigin),0!==gl_matrix__WEBPACK_IMPORTED_MODULE_5__.Zh(t)){gl_matrix__WEBPACK_IMPORTED_MODULE_5__.Fv(t,t);var n=this._pickedNormal;gl_matrix__WEBPACK_IMPORTED_MODULE_5__.od(t,t,n,-gl_matrix__WEBPACK_IMPORTED_MODULE_5__.AK(t,n)),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.Fv(t,t),e||gl_matrix__WEBPACK_IMPORTED_MODULE_5__.JG(this._alphaOrigin,this._interPoint),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.od(r,this._alphaOrigin,n,i),gl_matrix__WEBPACK_IMPORTED_MODULE_4__.zB(this._alphaLookAt,this._alphaOrigin,r,t)}}},{key:"initAlpha",value:function(){this.computePickedNormal(),this.updateAlpha()}},{key:"getMesh",value:function(){return this._mesh}},{key:"setLocalRadius2",value:function(e){this._rLocal2=e}},{key:"getLocalRadius2",value:function(){return this._rLocal2}},{key:"getLocalRadius",value:function(){return Math.sqrt(this._rLocal2)}},{key:"getWorldRadius2",value:function(){return this._rWorld2}},{key:"getWorldRadius",value:function(){return Math.sqrt(this._rWorld2)}},{key:"setIntersectionPoint",value:function(e){this._interPoint=e}},{key:"getEyeDirection",value:function(){return this._eyeDir}},{key:"getIntersectionPoint",value:function(){return this._interPoint}},{key:"getPickedVertices",value:function(){return this._pickedVertices}},{key:"getPickedFace",value:function(){return this._pickedFace}},{key:"getPickedNormal",value:function(){return this._pickedNormal}},{key:"intersectionMouseMeshes",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._main.getMeshes(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._main._mouseX,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this._main._mouseY,i=this.unproject(t,r,0),n=this.unproject(t,r,.1),a=1/0,s=null,o=-1,l=0,u=e.length;l<u;++l){var c=e[l];if(c.isVisible()&&(gl_matrix__WEBPACK_IMPORTED_MODULE_4__.U_(_TMP_INV,c.getMatrix()),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.fF(_TMP_NEAR_1,i,_TMP_INV),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.fF(_TMP_FAR,n,_TMP_INV),this.intersectionRayMesh(c,_TMP_NEAR_1,_TMP_FAR))){var h=this.getIntersectionPoint(),d=gl_matrix__WEBPACK_IMPORTED_MODULE_5__.TK(_TMP_NEAR_1,h)*c.getScale();d<a&&(a=d,s=c,gl_matrix__WEBPACK_IMPORTED_MODULE_5__.JG(_TMP_INTER_1,h),o=this.getPickedFace())}}return this._mesh=s,gl_matrix__WEBPACK_IMPORTED_MODULE_5__.JG(this._interPoint,_TMP_INTER_1),this._pickedFace=o,-1!==o&&this.updateLocalAndWorldRadius2(),!!s}},{key:"intersectionMouseMesh",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._main.getMesh(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._main._mouseX,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this._main._mouseY,i=this.unproject(t,r,0),n=this.unproject(t,r,.1),a=gl_matrix__WEBPACK_IMPORTED_MODULE_4__.Ue();return gl_matrix__WEBPACK_IMPORTED_MODULE_4__.U_(a,e.getMatrix()),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.fF(i,i,a),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.fF(n,n,a),this.intersectionRayMesh(e,i,n)}},{key:"intersectionRayMesh",value:function(e,t,r){if(this._mesh=null,this._pickedFace=-1,gl_matrix__WEBPACK_IMPORTED_MODULE_5__.JG(_TMP_NEAR,t),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.JG(_TMP_FAR,r),this._xSym){var i=e.getSymmetryOrigin(),n=e.getSymmetryNormal();math3d_Geometry__WEBPACK_IMPORTED_MODULE_0__.Z.mirrorPoint(_TMP_NEAR,i,n),math3d_Geometry__WEBPACK_IMPORTED_MODULE_0__.Z.mirrorPoint(_TMP_FAR,i,n)}var a=e.getVertices(),s=e.getFaces(),o=this.getEyeDirection();gl_matrix__WEBPACK_IMPORTED_MODULE_5__.lu(o,_TMP_FAR,_TMP_NEAR),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.Fv(o,o);for(var l=e.intersectRay(_TMP_NEAR,o),u=1/0,c=l.length,h=0;h<c;++h){var d=4*l[h],f=3*s[d],_=3*s[d+1],p=3*s[d+2];_TMP_V1[0]=a[f],_TMP_V1[1]=a[f+1],_TMP_V1[2]=a[f+2],_TMP_V2[0]=a[_],_TMP_V2[1]=a[_+1],_TMP_V2[2]=a[_+2],_TMP_V3[0]=a[p],_TMP_V3[1]=a[p+1],_TMP_V3[2]=a[p+2];var g=math3d_Geometry__WEBPACK_IMPORTED_MODULE_0__.Z.intersectionRayTriangle(_TMP_NEAR,o,_TMP_V1,_TMP_V2,_TMP_V3,_TMP_INTER);g<0&&(_=s[d+3])!==misc_Utils__WEBPACK_IMPORTED_MODULE_2__.Z.TRI_INDEX&&(_*=3,_TMP_V2[0]=a[_],_TMP_V2[1]=a[_+1],_TMP_V2[2]=a[_+2],g=math3d_Geometry__WEBPACK_IMPORTED_MODULE_0__.Z.intersectionRayTriangle(_TMP_NEAR,o,_TMP_V1,_TMP_V3,_TMP_V2,_TMP_INTER)),g>=0&&g<u&&(u=g,gl_matrix__WEBPACK_IMPORTED_MODULE_5__.JG(this._interPoint,_TMP_INTER),this._pickedFace=l[h])}return-1!==this._pickedFace?(this._mesh=e,this.updateLocalAndWorldRadius2(),!0):(this._rLocal2=0,!1)}},{key:"pickVerticesInSphere",value:function(e){for(var t=this._mesh,r=t.getVertices(),i=t.getVerticesSculptFlags(),n=this.getIntersectionPoint(),a=t.intersectSphere(n,e,!0),s=t.getVerticesFromFaces(a),o=s.length,l=++misc_Utils__WEBPACK_IMPORTED_MODULE_2__.Z.SCULPT_FLAG,u=new Uint32Array(misc_Utils__WEBPACK_IMPORTED_MODULE_2__.Z.getMemory(4*o),0,o),c=0,h=n[0],d=n[1],f=n[2],_=0;_<o;++_){var p=s[_],g=3*p,m=h-r[g],v=d-r[g+1],y=f-r[g+2];m*m+v*v+y*y<e&&(i[p]=l,u[c++]=p)}return this._pickedVertices=new Uint32Array(u.subarray(0,c)),this._pickedVertices}},{key:"_isInsideSphere",value:function(e,t,r){if(e===misc_Utils__WEBPACK_IMPORTED_MODULE_2__.Z.TRI_INDEX)return!1;var i=3*e;return gl_matrix__WEBPACK_IMPORTED_MODULE_5__.nI(t,this._mesh.getVertices().subarray(i,i+3))<=r}},{key:"pickVerticesInSphereTopological",value:function(e){var t=this._mesh,r=t.getNbVertices(),i=t.getVertices(),n=t.getFaces(),a=t.getVerticesRingVertStartCount(),s=t.getVerticesRingVert(),o=s instanceof Array?s:null,l=t.getVerticesSculptFlags(),u=t.getVerticesTagFlags(),c=++misc_Utils__WEBPACK_IMPORTED_MODULE_2__.Z.SCULPT_FLAG,h=++misc_Utils__WEBPACK_IMPORTED_MODULE_2__.Z.TAG_FLAG,d=this.getIntersectionPoint(),f=d[0],_=d[1],p=d[2],g=new Uint32Array(misc_Utils__WEBPACK_IMPORTED_MODULE_2__.Z.getMemory(4*r),0,r),m=4*this.getPickedFace(),v=1;this._isInsideSphere(n[m],d,e)?g[0]=n[m]:this._isInsideSphere(n[m+1],d,e)?g[0]=n[m+1]:this._isInsideSphere(n[m+2],d,e)?g[0]=n[m+2]:this._isInsideSphere(n[m+3],d,e)?g[0]=n[m+3]:v=0,1===v&&(l[g[0]]=c,u[g[0]]=h);for(var y=0;y<v;++y){var b,T,M=g[y];o?(b=0,T=(s=o[M]).length):T=(b=a[2*M])+a[2*M+1];for(var S=b;S<T;++S){var k=s[S];if(u[k]!==h){u[k]=h;var E=3*k,A=f-i[E],C=_-i[E+1],w=p-i[E+2];A*A+C*C+w*w>e||(l[k]=c,g[v++]=k)}}}return this._pickedVertices=new Uint32Array(g.subarray(0,v)),this._pickedVertices}},{key:"computeWorldRadius2",value:function(e){gl_matrix__WEBPACK_IMPORTED_MODULE_5__.fF(_TMP_INTER,this.getIntersectionPoint(),this._mesh.getMatrix());var t=this._main.getSculptManager().getCurrentTool().getScreenRadius();e||(t*=misc_Tablet__WEBPACK_IMPORTED_MODULE_1__.Z.getPressureRadius());var r=this.project(_TMP_INTER);return gl_matrix__WEBPACK_IMPORTED_MODULE_5__.nI(_TMP_INTER,this.unproject(r[0]+t,r[1],r[2]))}},{key:"updateLocalAndWorldRadius2",value:function(){this._mesh&&(this._rWorld2=this.computeWorldRadius2(),this._rLocal2=this._rWorld2/this._mesh.getScale2())}},{key:"unproject",value:function(e,t,r){return this._main.getCamera().unproject(e,t,r)}},{key:"project",value:function(e){return this._main.getCamera().project(e)}},{key:"computePickedNormal",value:function(){if(this._mesh&&!(this._pickedFace<0))return this.polyLerp(this._mesh.getNormals(),this._pickedNormal),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.Fv(this._pickedNormal,this._pickedNormal)}},{key:"polyLerp",value:function(e,t){var r=this._mesh.getVertices(),i=this._mesh.getFaces(),n=4*this._pickedFace,a=3*i[n],s=3*i[n+1],o=3*i[n+2],l=i[n+3],u=l!==misc_Utils__WEBPACK_IMPORTED_MODULE_2__.Z.TRI_INDEX;u&&(l*=3);var c=1/gl_matrix__WEBPACK_IMPORTED_MODULE_5__.TK(this._interPoint,r.subarray(a,a+3)),h=1/gl_matrix__WEBPACK_IMPORTED_MODULE_5__.TK(this._interPoint,r.subarray(s,s+3)),d=1/gl_matrix__WEBPACK_IMPORTED_MODULE_5__.TK(this._interPoint,r.subarray(o,o+3)),f=u?1/gl_matrix__WEBPACK_IMPORTED_MODULE_5__.TK(this._interPoint,r.subarray(l,l+3)):0,_=1/(c+h+d+f);return gl_matrix__WEBPACK_IMPORTED_MODULE_5__.t8(t,0,0,0),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.od(t,t,e.subarray(a,a+3),c*_),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.od(t,t,e.subarray(s,s+3),h*_),gl_matrix__WEBPACK_IMPORTED_MODULE_5__.od(t,t,e.subarray(o,o+3),d*_),u&&gl_matrix__WEBPACK_IMPORTED_MODULE_5__.od(t,t,e.subarray(l,l+3),f*_),t}}],[{key:"addAlpha",value:function(t,r,i,n){var a={};a._name=n,a._texture=t,a._ratioX=Math.max(1,r/i),a._ratioY=Math.max(1,i/r),a._ratioMax=Math.max(a._ratioX,a._ratioY),a._width=r,a._height=i;for(var s=1;e.ALPHAS[a._name];)a._name=n+s++;return e.ALPHAS[a._name]=a,e.ALPHAS_NAMES[a._name]=a._name,a}}]),e}();Picking.INIT_ALPHAS_NAMES=[(0,gui_GuiTR__WEBPACK_IMPORTED_MODULE_3__.Z)("alphaSquare"),(0,gui_GuiTR__WEBPACK_IMPORTED_MODULE_3__.Z)("alphaSkin")],Picking.INIT_ALPHAS_PATHS=["square.jpg","skin.jpg"];var readAlphas=function readAlphas(){if(window.module&&window.module.exports){var fs=eval("require")("fs"),path=eval("require")("path"),directoryPath=path.join(window.__filename,"../resources/alpha");fs.readdir(directoryPath,(function(e,t){if(!e)for(var r=0;r<t.length;++r){var i=t[r];"square.jpg"!=i&&"skin.jpg"!=i&&(Picking.INIT_ALPHAS_NAMES.push(i),Picking.INIT_ALPHAS_PATHS.push(i))}}))}};readAlphas();var none=(0,gui_GuiTR__WEBPACK_IMPORTED_MODULE_3__.Z)("alphaNone");Picking.ALPHAS_NAMES={},Picking.ALPHAS_NAMES[none]=none,Picking.ALPHAS={},Picking.ALPHAS[none]=null;const __WEBPACK_DEFAULT_EXPORT__=Picking},839:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});var i=r(781),n={Action:{NOTHING:0,MASK_EDIT:1,SCULPT_EDIT:2,CAMERA_ZOOM:3,CAMERA_ROTATE:4,CAMERA_PAN:5,CAMERA_PAN_ZOOM_ALT:6},Tools:{BRUSH:0,INFLATE:1,TWIST:2,SMOOTH:3,FLATTEN:4,PINCH:5,CREASE:6,DRAG:7,PAINT:8,MOVE:9,MASKING:10,LOCALSCALE:11,TRANSFORM:12,PEN:13},Shader:{PBR:0,FLAT:1,NORMAL:2,WIREFRAME:3,UV:4,MATCAP:5,SELECTION:6,BACKGROUND:7,MERGE:8,FXAA:9,CONTOUR:10,PAINTUV:11,BLUR:12,COMPARISON_IMAGE:13},Projection:{PERSPECTIVE:0,ORTHOGRAPHIC:1},CameraMode:{ORBIT:0,SPHERICAL:1,PLANE:2},MultiState:{NONE:0,SCULPT:1,CAMERA:2,PICKING:3}},a=Object.keys(n.Tools).length;n.KeyAction=i.Z.extend({INTENSITY:a++,RADIUS:a++,NEGATIVE:a++,PICKER:a++,DELETE:a++,CAMERA_FRONT:a++,CAMERA_TOP:a++,CAMERA_LEFT:a++,CAMERA_RESET:a++,STRIFE_LEFT:a++,STRIFE_RIGHT:a++,STRIFE_UP:a++,STRIFE_DOWN:a++,WIREFRAME:a++,REMESH:a++},n.Tools);const s=n},50:()=>{if(window.Map||(window.Map=function(){this.map={}},window.Map.prototype={set:function(e,t){this.map[e]=t},get:function(e){return this.map[e]}}),!Float32Array.prototype.slice){var e=function(e,t){return new this.constructor(this.subarray(e,t))};Int8Array.prototype.slice=e,Uint8Array.prototype.slice=e,Uint8ClampedArray.prototype.slice=e,Int16Array.prototype.slice=e,Uint16Array.prototype.slice=e,Int32Array.prototype.slice=e,Uint32Array.prototype.slice=e,Float32Array.prototype.slice=e,Float64Array.prototype.slice=e}String.prototype.endsWith||(String.prototype.endsWith=function(e){return this.slice(-e.length)===e}),String.prototype.startsWith||(String.prototype.startsWith=function(e){return this.slice(0,e.length)===e});for(var t=["moz","webkit"],r=0;r<t.length&&!window.requestAnimationFrame;++r)window.requestAnimationFrame=window[t[r]+"RequestAnimationFrame"];window.requestAnimationFrame||window.alert("browser is too old. Probably no webgl there anyway")},522:(e,t,r)=>{"use strict";r.d(t,{Z:()=>n});var i={radiusFactor:.75,intensityFactor:0,pressure:.5,getPressureIntensity:function(){return 1+i.intensityFactor*(2*i.pressure-1)},getPressureRadius:function(){return 1+i.radiusFactor*(2*i.pressure-1)}};const n=i},781:(e,t,r)=>{"use strict";r.d(t,{Z:()=>l});var i=r(928),n={SCALE:100,TAG_FLAG:1,SCULPT_FLAG:1,STATE_FLAG:1,TRI_INDEX:4294967295,cursors:{}};n.cursors.dropper="url(resources/dropper.png) 5 25, auto",n.linearToSRGB1=function(e){return e<.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055},n.sRGBToLinear1=function(e){return e<.04045?e*(1/12.92):Math.pow((e+.055)*(1/1.055),2.4)},n.extend=function(e,t){for(var r=Object.keys(t),i=0,n=r.length;i<n;++i){var a=r[i];void 0===e[a]&&(e[a]=t[a])}return e},n.invert=function(e){for(var t=Object.keys(e),r={},i=0,n=t.length;i<n;++i)r[e[t[i]]]=t[i];return r},n.replaceElement=function(e,t,r){for(var i=0,n=e.length;i<n;++i)if(e[i]===t)return void(e[i]=r)},n.removeElement=function(e,t){for(var r=0,i=e.length;r<i;++r)if(e[r]===t)return e[r]=e[i-1],void e.pop()},n.appendArray=function(e,t){var r=e.length,i=t.length;e.length+=i;for(var n=0;n<i;++n)e[r+n]=t[n]},n.isPowerOfTwo=function(e){return 0!==e&&0==(e&e-1)},n.nextHighestPowerOfTwo=function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1};var a,s,o=function(e,t){return e-t};n.tidy=function(e){e.sort(o);var t=e.length,r=0,i=0;for(r=1;r<t;++r)e[i]!==e[r]&&(e[++i]=e[r]);r>1&&(e.length=i+1)},n.intersectionArrays=function(e,t){for(var r=0,i=0,n=[],a=e.length,s=t.length;r<a&&i<s;)e[r]<t[i]?r++:e[r]>t[i]?i++:(n.push(e[r]),++r,++i);return n},n.littleEndian=(a=new ArrayBuffer(2),new DataView(a).setInt16(0,256,!0),256===new Int16Array(a)[0]),n.getBytes=function(e,t){return[e[t].charCodeAt(),e[t+1].charCodeAt(),e[t+2].charCodeAt(),e[t+3].charCodeAt()]},n.getUint32=function(e,t){var r=n.getBytes(e,t);return r[0]<<0|r[1]<<8|r[2]<<16|r[3]<<24},n.getFloat32=function(e,t){var r=n.getBytes(e,t),i=1-2*(r[3]>>7),a=(r[3]<<1&255|r[2]>>7)-127,s=(127&r[2])<<16|r[1]<<8|r[0];return 128===a?0!==s?NaN:i*(1/0):-127===a?i*s*Math.pow(2,-149):i*(1+s*Math.pow(2,-23))*Math.pow(2,a)},n.ab2str=function(e){for(var t="",r=new Uint8Array(e),i=65535,n=0,a=r.length;n<a;n+=i){var s=r.subarray(n,i<a-n?i+n:a);t+=String.fromCharCode.apply(null,s)}return t},n.getMemory=(s=new ArrayBuffer(1e5),function(e){return s.byteLength>=e?s:s=new ArrayBuffer(e)}),n.now=Date.now||function(){return(new Date).getTime()},n.throttle=function(e,t){var r,i=[],a=null,s=0,o=function(){s=n.now(),a=null,r=e.apply(e,i)};return function(){for(var l=n.now(),u=t-(l-s),c=i.length=arguments.length,h=0;h<c;++h)i[h]=arguments[h];return u<=0||u>t?(window.clearTimeout(a),a=null,s=l,r=e.apply(e,i)):a||(a=window.setTimeout(o,u)),r}},n.normalizeArrayVec3=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,r=0,i=e.length/3;r<i;++r){var n=3*r,a=e[n],s=e[n+1],o=e[n+2],l=a*a+s*s+o*o;0!==l?(l=1/Math.sqrt(l),t[n]=a*l,t[n+1]=s*l,t[n+2]=o*l):t[n]=1}return t},n.convertArrayVec3toSRGB=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,r=0,i=e.length;r<i;++r)t[r]=n.linearToSRGB1(e[r]);return t},n.convertArrayVec3toLinear=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,r=0,i=e.length;r<i;++r)t[r]=n.sRGBToLinear1(e[r]);return t},n.computeWorldVertices=function(e,t){var r=e.getNbVertices(),n=e.getVertices().subarray(0,3*r);t||(t=new Float32Array(3*r));for(var a=e.getMatrix(),s=i.Ue(),o=0;o<r;++o){var l=3*o;i.t8(s,n[l],n[l+1],n[l+2]),i.fF(s,s,a),t[l]=s[0],t[l+1]=s[1],t[l+2]=s[2]}return t};const l=n},52:(e,t,r)=>{"use strict";r.d(t,{Z:()=>h});var i,n=r(839),a=n.Z.KeyAction,s=function(e,t){return void 0===e?t:"false"!==e&&"0"!==e},o=function(e,t,r,i){var n=parseFloat(e);return n||0===n?Math.max(t,Math.min(r,n)):i},l=function(e,t,r,i){var n=parseInt(e,10);return n||0===n?Math.max(t,Math.min(r,n)):i},u=function(e,t,r){if(t){var i=e[t.toUpperCase()];if(void 0!==i)return i}return r},c=function(){if(i)return i;i={};var e=function(){for(var e=window.location.search.substr(1).split("&"),t={},r=0,i=e.length;r<i;r++){var n=e[r].split("=",2);2===n.length&&(t[n[0].toLowerCase()]=n[1])}return t}();return i.language=e.language,i.scalecenter=s(e.scalecenter,!1),i.grid=s(e.grid,!0),i.outline=s(e.outline,!1),i.outlinecolor=function(e,t){if(!e)return t;var r=e.split(",");if(r.length<3)return t;var i=t.slice();return i[0]=parseInt(r[0]||0,10)/255,i[1]=parseInt(r[1]||0,10)/255,i[2]=parseInt(r[2]||0,10)/255,void 0!==r[3]&&(i[3]=parseFloat(r[3])),i}(e.outlinecolor,[.3,0,0,1]),i.mirrorline=s(e.mirrorline,!1),i.darkenunselected=s(e.darkenunselected,!0),i.projection=u(n.Z.Projection,e.projection,n.Z.Projection.PERSPECTIVE),i.cameramode=u(n.Z.CameraMode,e.cameramode,n.Z.Projection.ORBIT),i.pivot=s(e.pivot,!0),i.fov=o(e.fov,10,90,45),i.flatshading=s(e.flatshading,!1),i.wireframe=s(e.wireframe,!1),i.curvature=o(e.curvature,0,5,0),i.exposure=o(e.exposure,0,5),i.environment=l(e.environment,0,1/0,0),i.matcap=l(e.matcap,0,1/0,3),i.shader=u(n.Z.Shader,e.shader,n.Z.Shader.MATCAP),i.filmic=s(e.filmic,!1),i.modelurl=e.modelurl,i.nosphere=s(e.nosphere,!1),i.shortcuts=function(e){var t={};if(t["0".charCodeAt(0)]=a.MOVE,t["1".charCodeAt(0)]=a.BRUSH,t["2".charCodeAt(0)]=a.INFLATE,t["3".charCodeAt(0)]=a.TWIST,t["4".charCodeAt(0)]=a.SMOOTH,t["5".charCodeAt(0)]=a.FLATTEN,t["6".charCodeAt(0)]=a.PINCH,t["7".charCodeAt(0)]=a.CREASE,t["8".charCodeAt(0)]=a.DRAG,t["9".charCodeAt(0)]=a.PAINT,t["E".charCodeAt(0)]=a.TRANSFORM,t["C".charCodeAt(0)]=a.INTENSITY,t["X".charCodeAt(0)]=a.RADIUS,t["N".charCodeAt(0)]=a.NEGATIVE,t["S".charCodeAt(0)]=a.PICKER,t[46]=a.DELETE,t["F".charCodeAt(0)]=a.CAMERA_FRONT,t["T".charCodeAt(0)]=a.CAMERA_TOP,t["L".charCodeAt(0)]=a.CAMERA_LEFT,t[32]=a.CAMERA_RESET,t[37]=a.STRIFE_LEFT,t[39]=a.STRIFE_RIGHT,t[38]=a.STRIFE_UP,t[40]=a.STRIFE_DOWN,t["W".charCodeAt(0)]=a.WIREFRAME,t["R".charCodeAt(0)]=a.REMESH,!e)return t;for(var r=e.split(","),i=0,n=r.length;i<n;i++){var s=r[i].split(":",2);if(2===s.length){var o=s[1].toUpperCase(),l=parseInt(o,10);o=l==l&&l>=10?l:o.charCodeAt(0);var u=a[s[0].toUpperCase()];void 0!==u&&(t[o]=u)}}return t}(e.shortcuts),i};c(),c.getShortKey=function(e){return e>=96&&e<=105&&(e-=48),c().shortcuts[e]};const h=c}},__webpack_module_cache__={};function __webpack_require__(e){if(__webpack_module_cache__[e])return __webpack_module_cache__[e].exports;var t=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(t.exports,t,t.exports,__webpack_require__),t.loaded=!0,t.exports}return __webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),__webpack_require__(866)})()}));