(window.webpackJsonp=window.webpackJsonp||[]).push([[18],{1e3:function(e,t){e.exports=function(e,t){for(var i=t,s=new Array,o=1;o<256;o++)s[o]={r:e[i++],g:e[i++],b:e[i++],a:e[i++]};return s}},1001:function(e,t){e.exports=function(e,t){let i=t;const s=Math.abs(e.readInt32LE(i));i+=4;const o=[];for(var n=0;n>2&3,o=16&e?-1:1,n=32&e?-1:1,r=64&e?-1:1;return t[i]=o,t[3+s]=n,t[6+(3^i^s)]=r,t}},1007:function(e,t,i){var s=i(554);e.exports=function(e,t){var i,o=t,n=e.readInt32LE(o);o+=4,[i,o]=s(e,o);var r=e.readInt32LE(o);o+=4,o+=4;var a=e.readInt32LE(o);o+=4;var l=e.readInt32LE(o);o+=4;for(var h=new Array(l),c=0;ce};const h={muType:"struct",muData:a,json:{type:"rbush3d-node"},identity:{children:[],boxes:[],minX:0,minY:0,minZ:0,maxX:0,maxY:0,maxZ:0},alloc:()=>l.alloc(),clone:e=>l.clone(e),free:e=>l.free(e),assign:(e,t)=>l.assign(e,t),equal:(e,t)=>l.equal(e,t),diff:(e,t,i)=>l.diff(e,t,i),patch:(e,t)=>l.patch(e,t),toJSON:e=>l.toJSON(e),fromJSON:e=>l.fromJSON(e)};a.children=new s.b(h,1/0),l=new s.q(a),Object.assign(h,l)},128:function(e,t,i){"use strict";i.d(t,"a",(function(){return a})),i.d(t,"c",(function(){return l})),i.d(t,"b",(function(){return h}));var s=i(0),o=i(44),n=i(35);class r{constructor(e,t,i){this.muType="relative array";const o=this.arraySchema=new s.b(e,t,i);this.json={type:"relative array",value:e.json},this.muData=e,this.identity=o.identity,this.alloc=o.alloc,this.free=o.free,this.clone=o.clone,this.equal=o.equal,this.assign=o.assign,this.toJSON=o.toJSON,this.fromJSON=o.fromJSON}diff(e,t,i){const s=i.offset,o=t.length,n=Math.ceil(o/8);i.grow(4+n),i.writeUint32(o);let r=i.offset;i.offset=r+n;let a=0,l=0;const h=e.length,c=this.muData;let d=e.length>0?e[0]:c.identity;for(let e=0;e0||h!==o||(i.offset=s,!1)}patch(e,t){const i=this.clone(e),s=t.readUint32();i.length=s;let o=t.offset;const n=Math.ceil(s/8);t.offset=o+n;let r=0;const a=this.muData;let l=e.length>0?e[0]:a.identity;for(let e=0;e(e[e.default=0]="default",e[e.symbol=1]="symbol",e[e.number=2]="number",e[e.letter=3]="letter",e[e.color=4]="color",e[e.nature=5]="nature",e[e.structure=6]="structure",e[e.light=7]="light",e[e.food=8]="food",e))(a||{});const l=new s.q({ids:new r(new s.o,1/0,[0]),names:new s.b(new s.r,1/0,["air"]),emissive:new r(new s.w,1/0,[0]),texture:new r(new s.o,1/0,[0,0,0,0,0,0]),animLength:new r(new s.w(1),1/0,[1,1,1,1,1,1]),friction:new r(new s.n(1/256,1),1/0,[0]),restitution:new r(new s.n(1/256,0),1/0,[0]),velocity:new r(new s.g(0),1/0,[0,0,0]),fluids:new s.b(new s.q({id:new s.w,info:new s.t,mass:new s.h(1)}),1/0,[{id:0,info:0,mass:0}]),category:new s.f(new r(new s.o,1/0),1/0,{default:[0]}),atlasRadius:new s.w(16),blockBumpShift:new s.w(6),blockColorShift:new s.w(4),colorAtlas:new s.b(o.a,1/0),materialAtlas:new s.b(o.a,1/0),bumpAtlas:new s.b(o.a,1/0)}),h=new s.q({id:new s.f(new s.w,1/0,{air:0}),valid:new s.b(new s.c(!1),1/0),name:new s.b(new s.r,1/0,["air"]),emissive:new s.b(new s.s,1/0,[0]),texture:new s.b(new s.t,1/0,[0,0,0,0,0,0]),mass:new s.b(new s.h,1/0,[0]),restitution:new s.b(new s.h,1/0,[0]),friction:new s.b(new s.h,1/0,[0]),fluid:new s.b(new s.w,1/0,[1]),fluidInfo:new s.b(new s.t,1/0,[0,0]),velocity:new s.b(new s.g(0),1/0,[0,0,0]),isFluid:new n.a})},129:function(e,t,i){"use strict";i.d(t,"a",(function(){return o})),i.d(t,"b",(function(){return r}));var s=i(3);class o{constructor(){this.hitPosition=s.e.create(),this.hitNormal=s.e.create(),this.hitVoxel=[0,0,0],this.hitDistance=1/0,this.hitBlock=0}}function n(e,t,i){return Math.min(Math.max(e,t),i)}function r(e,t,i,s,o,r,a){const l=+s[0],h=+s[1],c=+s[2],d=+o[0],p=+o[1],u=+o[2],f=Math.sqrt(Math.pow(d,2)+Math.pow(p,2)+Math.pow(u,2));return function(e,t,i,s,o,r,a,l,h,c,d){let p=0,u=c;const f=Math.abs(1/a),m=Math.abs(1/l),g=Math.abs(1/h),v=-s/a,b=(i.shape[0]-s)/a,x=-o/l,y=(i.shape[1]-o)/l,_=-r/h,E=(i.shape[2]-r)/h;let M=1,S=-1,w=-1;if(a<0){if(s<0)return!1;s>=i.shape[0]&&b>p&&(p=b,S=0,w=1),u=Math.min(u,v),M=-1}else{if(s>=i.shape[0])return!1;s<0&&v>p&&(p=v,S=0,w=-1),u=Math.min(u,b)}let C=1;if(l<0){if(o<0)return!1;o>=i.shape[1]&&y>p&&(p=y,S=1,w=1),u=Math.min(u,x),C=-1}else{if(o>=i.shape[1])return!1;o<0&&x>p&&(p=x,S=1,w=-1),u=Math.min(u,y)}let P=2*+(h>0)-1;if(h<0){if(r<0)return!1;r>=i.shape[2]&&E>p&&(p=E,S=2,w=1),u=Math.min(u,_),P=-1}else{if(r>=i.shape[2])return!1;r<0&&_>p&&(p=_,S=2,w=-1),u=Math.min(u,E)}const k=n(s+p*a,0,i.shape[0]-.001),R=n(o+p*l,0,i.shape[1]-.001),I=n(r+p*h,0,i.shape[2]-.001);let O=0|Math.floor(k),j=0|Math.floor(R),T=0|Math.floor(I),N=p+(f<1/0?f*(M>0?O+1-k:k-O):1/0),D=p+(m<1/0?m*(C>0?j+1-R:R-j):1/0),V=p+(g<1/0?g*(P>0?T+1-I:I-T):1/0),B=-1;const{data:A,stride:[L,z,H],offset:U,shape:F}=i;let G=0;for(;p<=u;){let n=A[O*L+j*z+T*H+U];if((O>=i.shape[0]||j>=i.shape[1]||T>=i.shape[2]||O<0||j<0||T<0)&&(n=0),n&&(!d||!t.fluid[4095&n]))return e.hitPosition[0]=s+p*a,e.hitPosition[1]=o+p*l,e.hitPosition[2]=r+p*h,e.hitVoxel[0]=O,e.hitVoxel[1]=j,e.hitVoxel[2]=T,e.hitNormal[0]=e.hitNormal[1]=e.hitNormal[2]=0,0==G&&-1!=S&&(e.hitNormal[S]=w),0===B&&(e.hitNormal[0]=-M),1===B&&(e.hitNormal[1]=-C),2===B&&(e.hitNormal[2]=-P),e.hitDistance=p,e.hitBlock=n,!0;N(e[e.bakeAoData=0]="bakeAoData",e[e.generateTerrainData=1]="generateTerrainData",e[e.syncVoxel=2]="syncVoxel",e[e.updateVoxel=3]="updateVoxel",e[e.sendPoints=4]="sendPoints",e[e.clearData=5]="clearData",e[e.changeSize=6]="changeSize",e))(n||{}),r=(e=>(e[e.Attach=0]="Attach",e[e.Erase=1]="Erase",e[e.Paint=2]="Paint",e[e.Select=3]="Select",e[e.Translate=4]="Translate",e[e.ColorSelect=5]="ColorSelect",e[e.PickColor=6]="PickColor",e[e.HollowOut=7]="HollowOut",e[e.FillSameColorSpace=8]="FillSameColorSpace",e))(r||{}),a=(e=>(e[e.line=0]="line",e[e.center=1]="center",e[e.box=2]="box",e[e.voxel=3]="voxel",e[e.face=4]="face",e))(a||{}),l=(e=>(e[e.volume=0]="volume",e[e.face=1]="face",e[e.all=2]="all",e))(l||{}),h=(e=>(e[e.square=0]="square",e[e.circle=1]="circle",e))(h||{}),c=(e=>(e[e.voxelColor=0]="voxelColor",e[e.currentColor=1]="currentColor",e))(c||{}),d=(e=>(e[e.geometry=0]="geometry",e[e.colorGeometry=1]="colorGeometry",e))(d||{});function p(e,t,i,s,o){const{start:n,end:r}=u(e,t,[-1/0,-1/0,-1/0],[1/0,1/0,1/0]),a=[],l=[],h=[],c=s?-1:1;if(i)for(let e=0;e<3;e++)r[e]=o?Math.min(r[e]+1,o[e]):r[e]+1;a.push([n[0],n[1],n[2]]),a.push([n[0],n[1],r[2]]),a.push([r[0],n[1],r[2]]),a.push([r[0],n[1],n[2]]),a.push([n[0],r[1],n[2]]),a.push([r[0],r[1],n[2]]),a.push([r[0],r[1],r[2]]),a.push([n[0],r[1],r[2]]),a.push([r[0],n[1],n[2]]),a.push([r[0],n[1],r[2]]),a.push([r[0],r[1],r[2]]),a.push([r[0],r[1],n[2]]),a.push([n[0],n[1],n[2]]),a.push([n[0],r[1],n[2]]),a.push([n[0],r[1],r[2]]),a.push([n[0],n[1],r[2]]),a.push([n[0],n[1],n[2]]),a.push([r[0],n[1],n[2]]),a.push([r[0],r[1],n[2]]),a.push([n[0],r[1],n[2]]),a.push([n[0],n[1],r[2]]),a.push([n[0],r[1],r[2]]),a.push([r[0],r[1],r[2]]),a.push([r[0],n[1],r[2]]);for(let e=0;e<4;e++)h.push([0,1*c,0]);for(let e=0;e<4;e++)h.push([0,-1*c,0]);for(let e=0;e<4;e++)h.push([-1*c,0,0]);for(let e=0;e<4;e++)h.push([1*c,0,0]);for(let e=0;e<4;e++)h.push([0,0,1*c]);for(let e=0;e<4;e++)h.push([0,0,-1*c]);const d=[0,4,8,12,16,20];for(let e=0;eo[0]||t>o[1]||i>o[2])}function _(e,t,i,s,n,r,a,l,h){const c=[];c.push(i);const d=[e.shape[0]-1,e.shape[1]-1,e.shape[2]-1];for(;c.length;){const[i,p,u]=c.pop();if(y([i,p,u],[0,0,0],d)&&(!h||!y([i+h[0],p+h[1],u+h[2]],[0,0,0],d)||0===e.getVoxel(i+h[0],p+h[1],u+h[2]))){if(-1===s){const s=t.index(i,p,u);if(0!=t.data[s])continue;if(0===e.data[s])continue;t.data[s]=e.data[s]}else if(0===s){if(t.getVoxel(i,p,u)===n)continue;if(0!==e.getVoxel(i,p,u))continue;t.setVoxel(i,p,u,n),e.setVoxel(i,p,u,n)}else{if(t.getVoxel(i,p,u)===s)continue;if(e.getVoxel(i,p,u)!==s)continue;t.setVoxel(i,p,u,s)}o.e.min(a,a,[i,p,u]),o.e.max(l,l,[i,p,u]),0!=r[0]&&(c.push([i+1,p,u]),c.push([i-1,p,u])),0!=r[1]&&(c.push([i,p+1,u]),c.push([i,p-1,u])),0!=r[2]&&(c.push([i,p,u+1]),c.push([i,p,u-1]))}}}function E(e,t,i,s,o,n){let r=0,a=s,l=5/4-s;for("string"!=typeof o&&(0!=o[0]?o="x":0!=o[1]?o="y":0!=o[2]&&(o="z"));r<=a;)if(l<0?(l=l+2*r+3,r++):(l=l+2*(r-a)+5,a--,r++),"z"===o){for(let e=i[0]-r;e<=i[0]+r;e++)n(e,i[1]+a,i[2]),n(e,i[1]-a,i[2]);for(let e=i[0]-a;e<=i[0]+a;e++)n(e,i[1]+r,i[2]),n(e,i[1]-r,i[2]);for(let e=i[0]-s;e<=i[0]+s;e++)e!=i[0]&&n(e,i[1],i[2])}else if("y"===o){for(let e=i[2]-r;e<=i[2]+r;e++)n(i[0]+a,i[1],e),n(i[0]-a,i[1],e);for(let e=i[2]-a;e<=i[2]+a;e++)n(i[0]+r,i[1],e),n(i[0]-r,i[1],e);for(let e=i[2]-s;e<=i[2]+s;e++)e!=i[2]&&n(i[0],i[1],e)}else if("x"===o){for(let e=i[2]-r;e<=i[2]+r;e++)n(i[0],i[1]+a,e),n(i[0],i[1]-a,e);for(let e=i[2]-a;e<=i[2]+a;e++)n(i[0],i[1]+r,e),n(i[0],i[1]-r,e);for(let e=i[2]-s;e<=i[2]+s;e++)e!=i[2]&&n(i[0],i[1],e)}}function M(e,t,i,s,o,n=!1){if("string"!=typeof o&&(0!=o[0]?o="x":0!=o[1]?o="y":0!=o[2]&&(o="z")),"z"===o){for(let o=i[0]-s;o<=i[0]+s;o++)for(let r=i[1]-s;r<=i[1]+s;r++)if(o!=i[0]||r!=i[1]){const s=e.index(o,r,i[2]);s>-1&&(e.data[s]=n?t:e.data[s]||t)}}else if("y"===o){for(let o=i[0]-s;o<=i[0]+s;o++)for(let r=i[2]-s;r<=i[2]+s;r++)if(o!=i[0]||r!=i[2]){const s=e.index(o,i[1],r);s>-1&&(e.data[s]=n?t:e.data[s]||t)}}else if("x"===o)for(let o=i[1]-s;o<=i[1]+s;o++)for(let r=i[2]-s;r<=i[2]+s;r++)if(o!=i[1]||r!=i[2]){const s=e.index(i[0],o,r);s>-1&&(e.data[s]=n?t:e.data[s]||t)}}function S(e,t,i){if(0!=e[0]){const e=i[1]-t[1],s=i[2]-t[2];return Math.round(Math.pow(e*e+s*s,.5))}if(0!=e[1]){const e=i[0]-t[0],s=i[2]-t[2];return Math.round(Math.pow(e*e+s*s,.5))}if(0!=e[2]){const e=i[0]-t[0],s=i[1]-t[1];return Math.round(Math.pow(e*e+s*s,.5))}return 0}function w(e,t,i){if(0!=e[0]){const e=Math.abs(i[1]-t[1]),s=Math.abs(i[2]-t[2]);return Math.max(e,s)}if(0!=e[1]){const e=Math.abs(i[0]-t[0]),s=Math.abs(i[2]-t[2]);return Math.max(e,s)}if(0!=e[2]){const e=Math.abs(i[0]-t[0]),s=Math.abs(i[1]-t[1]);return Math.max(e,s)}return 0}function C(e,t,i){const s=Math.min(e[0],t[0]),o=Math.min(e[1],t[1]),n=Math.min(e[2],t[2]),r=Math.max(e[0],t[0]),a=Math.max(e[1],t[1]),l=Math.max(e[2],t[2]);let h=+(t[0]-e[0]),c=+(t[1]-e[1]),d=+(t[2]-e[2]);const p=Math.sqrt(Math.pow(h,2)+Math.pow(c,2)+Math.pow(d,2));h/=p,c/=p,d/=p;const u=Math.abs(1/h),f=Math.abs(1/c),m=Math.abs(1/d);let g=u<1/0?Math.abs(h)+1:1/0,v=f<1/0?Math.abs(c)+1:1/0,b=m<1/0?Math.abs(d)+1:1/0;const x=h<0?-1:h>0?1:0,y=c<0?-1:c>0?1:0,_=d<0?-1:d>0?1:0;let[E,M,S]=e;for(;;){if(i(E,M,S),E==t[0]&&M==t[1]&&S==t[2])return;if(gr)return;g+=u}else{if(S+=_,Sl)return;b+=m}else if(va)return;v+=f}else{if(S+=_,Sl)return;b+=m}}}function P(e,t,i,s,o,n,r,a){const l=u(s,o,[0,0,0],e.shape.map(e=>e-1)),[h,c,d]=l.start,[p,f,m]=l.end;if(t&&3==t.length){const s=u(t,i,[0,0,0],e.shape.map(e=>e-1)),[o,l,g]=s.start,[v,b,x]=s.end,y=function(e,t,i,s){const o=Math.max,n=Math.min,r=[o(e[0],i[0]),o(e[1],i[1]),o(e[2],i[2])],a=[n(t[0],s[0]),n(t[1],s[1]),n(t[2],s[2])];if(!(r[0]{for(let t=0;t{for(let t=0;t{k(e,t[0],t[1],n)}),y.addition.forEach(t=>{k(e,t[0],t[1],r,a)})}else for(let t=h;t<=p;t++)for(let i=c;i<=f;i++)for(let s=d;s<=m;s++)"function"==typeof r?e.setVoxel(t,i,s,r(t,i,s)):e.setVoxel(t,i,s,r);return e}function k(e,t,i,s,o){for(let n=t[0];n<=i[0];n++)for(let r=t[1];r<=i[1];r++)for(let a=t[2];a<=i[2];a++){let t;t="function"==typeof s?s(n,r,a):s;(null==o||o(n,r,a))&&e.setVoxel(n,r,a,t)}}function R(e,t,i){const o=Object(s.b)(e,t,i);for(let e=0;ee-1)),[r,a,l]=n.start,[h,c,d]=n.end;for(let i=r;i<=h;i++)for(let s=a;s<=c;s++)for(let n=l;n<=d;n++)1===o?0==e.getVoxel(i,s,n)&&e.setVoxel(i,s,n,t.getVoxel(i,s,n)):2===o?e.setVoxel(i,s,n,t.getVoxel(i,s,n)):3===o?0!=t.getVoxel(i,s,n)&&e.setVoxel(i,s,n,t.getVoxel(i,s,n)):4===o?0!=t.getVoxel(i,s,n)&&(e.setVoxel(i,s,n,t.getVoxel(i,s,n)),t.setVoxel(i,s,n,0)):5===o&&0==e.getVoxel(i,s,n)&&(e.setVoxel(i,s,n,t.getVoxel(i,s,n)),t.setVoxel(i,s,n,0));return function(t,i,s,o=1){return j(e,t,i,s,o)}}function T(e,t){const i=[],s=t[0]-e[0],o=t[1]-e[1],n=t[2]-e[2],r=e[0],a=e[1],l=e[2],h=Math.max(Math.abs(s),Math.abs(o),Math.abs(n));let c;const d=2e3;if(h===Math.abs(s)){c=s>0?[[d,d],[-d,d],[-d,-d],[d,-d]]:[[d,d],[d,-d],[-d,-d],[-d,d]];for(let e=0;e0?[[d,d],[d,-d],[-d,-d],[-d,d]]:[[d,d],[-d,d],[-d,-d],[d,-d]];for(let e=0;e0?c=[[d,d],[-d,d],[-d,-d],[d,-d]]:n<0&&(c=[[d,d],[d,-d],[-d,-d],[-d,d]]);for(let e=0;ee/255),[255,135,126].map(e=>e/255)],[[220,156,119].map(e=>e/255),[255,175,189].map(e=>e/255)],[[44,62,80].map(e=>e/255),[189,195,199].map(e=>e/255)],[[0,4,40].map(e=>e/255),[0,78,146].map(e=>e/255)],[[67,206,162].map(e=>e/255),[24,90,157].map(e=>e/255)],[[51,8,103].map(e=>e/255),[48,207,208].map(e=>e/255)],[[245,247,250].map(e=>e/255),[195,207,226].map(e=>e/255)],[[173,87,108].map(e=>e/255),[255,177,153].map(e=>e/255)],[[208,227,255].map(e=>e/255),[243,231,233].map(e=>e/255)],[[243,144,79].map(e=>e/255),[59,67,113].map(e=>e/255)]],this.projectInfo={content_id:-1,dispaly_name:"new_model",author:-1,description:"",preview:""},this.timeFreeze=!1,this.timeOfDay=4/24,this.lunarPhase=0,this.basicConfig={workspaceSize:[32,32,32]},this.viewConfig={blockWireframe:!1,boundaryCheckboard:!1},this.terrainMode=!1,this.pbrPreviewMode=!1,this.previewMeshMode=!1,this._faceModeColorOpt=s.d.currentColor,this._faceModeSelectionOpt=s.e.colorGeometry,this.basicActionOption={Mirror:{X:!1,Y:!1,Z:!1},Axis:{X:!1,Y:!1,Z:!1}},this._previewList=[],this._dialogState={show:!1,dialog:n.none},this._currentTool=s.a.Attach,this._currentEditingMode=s.c.box,this._currentCenterMode=s.b.circle,this._colorSelectOptions=s.l.face}updateEnvTime(){this.timeOfDay+=.001,this.lunarPhase+=.001/24/2}getFaceModeSelectionOpt(){return this._faceModeSelectionOpt}setFaceModeSelectionOpt(e){this._faceModeSelectionOpt=e}setEditingActions(e){this._currentTool!=e&&(this._currentTool=e)}getCurrentEditingTool(){return this._currentTool}getCenterMode(){return this._currentCenterMode}setCenterMode(e){this._currentCenterMode=e}setEditingMode(e){this._currentEditingMode!=e&&(this._currentEditingMode=e)}getEditingMode(){return this._currentEditingMode}setWorkSpaceSize(e,t,i){const s=this.basicConfig.workspaceSize;s[0]==e&&s[1]==t&&s[2]==i||(this.basicConfig.workspaceSize[0]=e,this.basicConfig.workspaceSize[1]=t,this.basicConfig.workspaceSize[2]=i)}setColorSelectOption(e){this._colorSelectOptions=e}getColorSelectOption(){return this._colorSelectOptions}getFaceModeColorOpt(){return this._faceModeColorOpt}setFaceModeColorOpt(e){this._faceModeColorOpt=e}setDialogState(e){this._dialogState.show=e.show,this._dialogState.dialog=e.dialog}getDialogState(){return this._dialogState}getPreviewList(){return this._previewList}setPreviewList(e){this._previewList=[],this._previewList=this._previewList.concat(e)}removePreviewListItemById(e){for(let t=0;t(e[e.colorPicker=0]="colorPicker",e[e.savingDialog=1]="savingDialog",e[e.libraryDialog=2]="libraryDialog",e[e.importImgDialog=3]="importImgDialog",e[e.publish=4]="publish",e[e.none=5]="none",e))(n||{})},1371:function(e,t,i){e.exports={VE_dialog:"I27bJzzxyPYDbHu_w_jsM",actived:"_2FSPLncmlqdkXRhl0r96TT",mainWindow:"N-mhGVi2UiAO6emTy-az_",solid:"_2RE-qL8OZrvafxqdlUcCiP",dialogTitle:"Zme6nSUEQsESajqugdAY-",dialogTitleText:"_13VT-zt1b_V_sVEolivCuH",dialogTitleCloseBtn:"_1wwnjALmmYP8iN947TTOhn",dialogContent:"fzFKnj88isjkxvqLsHJyb",dialogActions:"_1ighd0oiIlHo860WBk7aDR",dialogBtn:"hLwlcIYsQH_iZ7EnTV8_8",VE_saving_dialog:"_1tUuoPRSSuRVXzclhDN_Lp",inGameEditor:"_2JV5MWAjRy-7YEbCbGsJFS",negative:"_3xbc3p1209EBvqGpYKe05R",VE_library_dialog:"_2w1w6hhY5TAeOKxaWqN_8O",previewItem:"_38xlc1jorN6UHxrtiE841N",innerBorder:"_1BaUHiItTYXHzB3t771Cb8",previewImage:"_1BBV5H_YfvMIXAjoqOoMsO",previewDescription:"_2pyfFFmrVDpA8gDhV-RZQO",deleteBtn:"_3-XzOi71DT8kDRVF80m0qX",deletStick1:"_3PnQGg6fFPg7lTEC9BNlxF",deletStick2:"MmZg37RG-9PeFq47N2onQ",VE_publis_dialog:"_3rPH1L6gWARqWbRmgyJn9F",publishLeft:"_2a90CB_JtvErcwY10QHbWl",publishRight:"_2N-kdDxyzsNhgCUW2tIeRg",imageWrapper:"_1r7uNtH3snBSTQPwPL_On6",publishBtn:"_3daxeU2n8NXerKARvkj-Au",inputContent:"CUBcOJtdR7d5iZQJPgAuS",dialogHeader:"_2HYT8L7ys8Eu573MWLfKF1",editBtn:"_1KOHJ90li3c06Iw96zXAXU",closeBtn:"RqvMUC4QWSJDx_1SMW3Az",stickWrap:"_1sHxI5iafbd1bYf8nd0Fqr",stick_1:"_3OWKg1j7T4aEuQufoxB7lw",stick_2:"_3AjdGT2oiw-zBx4KgVOwRN",inputName:"_38DcJ1Vf5dnOQwATGK6cBn",loader:"_3za3y0OmcXUngoa50PODNi",center:"_5K2OkDmnZd6uGBfSl7kAF",loader_2:"_17LeieJv9UTgLrYXUt0d_n","loader-2-1":"djkSzKFp5uuV6TCafpX4R","loader-2-2":"_17xafHK2oQgPzmFPsBq1H",VE_ImportImg_dialog:"_1waQWj72uywcRsUux79n6m",imgInput:"A2pE6pwUNxFSTc4ovExaU",plusBtn:"_3c3PoK8Y6CeYLD-5_JunB2",stick:"_2K1VD7LtIthtX36ykh_zG_",imgAlt:"iU93Olf8ERlkikhW-rApd",confirmBtn:"_2GJRlG6-x4yazvFxge4kgF",previewImg:"_1BwdcHCJFYBexbtG91Re1J",ldsRingWrapper:"_12rHWb9DGnkfVdrXu_pZYQ",ldsRing:"_2VdZw-AH8kxXWuGp2nWyfr","lds-ring":"_3pJ_6sZKQi--J3IN2YBNSa"}},1375:function(e,t,i){var s=i(1401),o=i(992),n="undefined"!=typeof Float64Array;function r(e,t){return e[0]-t[0]}function a(){var e,t=this.stride,i=new Array(t.length);for(e=0;eMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===t&&n.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):n.push("ORDER})")),n.push("proto.set=function "+i+"_set("+l.join(",")+",v){"),o?n.push("return this.data.set("+c+",v)}"):n.push("return this.data["+c+"]=v}"),n.push("proto.get=function "+i+"_get("+l.join(",")+"){"),o?n.push("return this.data.get("+c+")}"):n.push("return this.data["+c+"]}"),n.push("proto.index=function "+i+"_index(",l.join(),"){return "+c+"}"),n.push("proto.hi=function "+i+"_hi("+l.join(",")+"){return new "+i+"(this.data,"+r.map((function(e){return["(typeof i",e,"!=='number'||i",e,"<0)?this.shape[",e,"]:i",e,"|0"].join("")})).join(",")+","+r.map((function(e){return"this.stride["+e+"]"})).join(",")+",this.offset)}");var u=r.map((function(e){return"a"+e+"=this.shape["+e+"]"})),f=r.map((function(e){return"c"+e+"=this.stride["+e+"]"}));n.push("proto.lo=function "+i+"_lo("+l.join(",")+"){var b=this.offset,d=0,"+u.join(",")+","+f.join(","));for(var m=0;m=0){d=i"+m+"|0;b+=c"+m+"*d;a"+m+"-=d}");n.push("return new "+i+"(this.data,"+r.map((function(e){return"a"+e})).join(",")+","+r.map((function(e){return"c"+e})).join(",")+",b)}"),n.push("proto.step=function "+i+"_step("+l.join(",")+"){var "+r.map((function(e){return"a"+e+"=this.shape["+e+"]"})).join(",")+","+r.map((function(e){return"b"+e+"=this.stride["+e+"]"})).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(m=0;m=0){c=(c+this.stride["+m+"]*i"+m+")|0}else{a.push(this.shape["+m+"]);b.push(this.stride["+m+"])}");return n.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),n.push("return function construct_"+i+"(data,shape,stride,offset){return new "+i+"(data,"+r.map((function(e){return"shape["+e+"]"})).join(",")+","+r.map((function(e){return"stride["+e+"]"})).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",n.join("\n"))(h[e],a)}var h={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};e.exports=function(e,t,i,s){if(void 0===e)return(0,h.array[0])([]);"number"==typeof e&&(e=[e]),void 0===t&&(t=[e.length]);var r=t.length;if(void 0===i){i=new Array(r);for(var a=r-1,c=1;a>=0;--a)i[a]=c,c*=t[a]}if(void 0===s){s=0;for(a=0;a{o.target!=document.getElementById("voxel-editor")&&o.target!=e||this.distance<.003&&o.deltaY<0||this.distance>6.5&&o.deltaY>0||(this.ddistance+=i/this.canvas.offsetHeight/2,this.lastScrollTime=Date.now())}),this._onContextMenu=this._onContextMenu.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this)}isRotating(){return this.startRotate}setPosition(e){this.target[0]=e[0]/2,this.target[1]=e[1]/2,this.target[2]=e[2]/2,this.ddistance=5.987249185732558,this.phi=.5089343452708008,this.theta=30.628504829794284}calcProjection(){this.viewportWidth=this.canvas.offsetWidth,this.viewportHeight=this.canvas.offsetHeight,s.b.perspective(this.projection,this.fovY,this.viewportWidth/this.viewportHeight,this.zNear,this.zFar),s.b.invert(this.invProjection,this.projection)}calcView(){const{eye:e,view:t,target:i,up:o}=this;s.b.lookAt(t,e,i,o),s.b.invert(this.invView,t);const n=s.e.sub(s.e.create(),i,e);s.e.normalize(n,n),s.b.lookAt(this.fixedView,e,s.e.add(s.e.create(),n,e),o)}recalc(){const{viewProjection:e,invViewProjection:t,projection:i,view:o}=this;this.calcView(),this.calcProjection(),s.b.mul(e,i,o),s.b.invert(t,e)}reset(){s.e.set(this.target,0,0,0),s.c.identity(this.rotation),this.fovY=a,this.zNear=1,this.zFar=1024,this.gamma=2.2,this.recalc()}updateCamera(){const e=this.target,t=this.eye,i=this.up;this.theta+=this.dtheta,this.phi=this.clamp(this.phi+this.dphi,-Math.PI/2.001,Math.PI/2.001),this.keyZoomIn&&!this.keyZoomOut?this.ddistance+=-30/this.canvas.offsetHeight/2:!this.keyZoomIn&&this.keyZoomOut&&(this.ddistance+=30/this.canvas.offsetHeight/2),this.keyThetaRotate||(this.dtheta=0),this.keyPhiRotate||(this.dphi=0),this.distance=this.clamp(this.distance+this.ddistance,this.minDistance,this.maxDistance),this.distance=this.damp(this.ddistance);const s=this.theta,o=this.phi,n=Math.exp(this.distance),r=n*Math.sin(s)*Math.cos(o),a=n*Math.cos(s)*Math.cos(o),d=n*Math.sin(o);for(let s=0;s<3;s++)t[s]=e[s]+r*h[s]+a*l[s]+d*i[s];this.recalc(),0!==this.lastScrollTime&&Date.now()-this.lastScrollTime>500&&(this.emit(c.cameraMoveEnd),this.lastScrollTime=0)}_onKeyDown(e){"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName&&(91===e.keyCode?this.ctrlDown=!0:88===e.keyCode?(this.metaDown=!0,this.startRotate=!0):68!==e.keyCode||this.ctrlDown?65!==e.keyCode||this.ctrlDown?69!==e.keyCode||this.ctrlDown?81!==e.keyCode||this.ctrlDown?87!==e.keyCode||this.ctrlDown?83!==e.keyCode||this.ctrlDown||(this.keyZoomOut=!0):this.keyZoomIn=!0:(this.dphi=-.017453292519943295,this.keyPhiRotate=!0):(this.dphi=.017453292519943295,this.keyPhiRotate=!0):(this.dtheta=.017453292519943295,this.keyThetaRotate=!0):(this.dtheta=-.017453292519943295,this.keyThetaRotate=!0))}_onKeyUp(e){"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName&&(91==e.keyCode?this.ctrlDown=!1:88==e.keyCode?(this.metaDown=!1,this.startRotate=!1,this.emit(c.cameraMoveEnd)):68===e.keyCode||65===e.keyCode?(this.keyThetaRotate=!1,this.emit(c.cameraMoveEnd)):69===e.keyCode||81===e.keyCode?(this.keyPhiRotate=!1,this.emit(c.cameraMoveEnd)):87===e.keyCode?(this.keyZoomIn=!1,this.emit(c.cameraMoveEnd)):83===e.keyCode&&(this.keyZoomOut=!1,this.emit(c.cameraMoveEnd)))}_onMouseDown(e){(2==e.button||0==e.button&&1==this.metaDown)&&(this.startRotate=!0,this.prevX=e.clientX,this.prevY=e.clientY)}_onTouchStart(e){e.stopPropagation(),e.cancelable&&(e.defaultPrevented||e.preventDefault()),2==e.targetTouches.length?this.prevPinchDist=Math.hypot(e.touches[0].pageX-e.touches[1].pageX,e.touches[0].pageY-e.touches[1].pageY):(this.startRotate=!0,this.prevX=e.touches[0].clientX,this.prevY=e.touches[0].clientY)}_onTouchMove(e){if(e.stopPropagation(),!this.rotateLock)if(2==e.targetTouches.length){const t=Math.hypot(e.touches[0].pageX-e.touches[1].pageX,e.touches[0].pageY-e.touches[1].pageY),i=t-this.prevPinchDist;if(this.distance<.003&&i>0||this.distance>6.5&&i<0)return;this.ddistance+=-3*i/this.canvas.offsetHeight,this.prevPinchDist=t}else e.clientY=e.touches[0].clientY,e.clientX=e.touches[0].clientX,this._onMouseMove(e)}_onTouchEnd(e){this._onMouseUp(),this.prevPinchDist=0}_onContextMenu(e){e.stopPropagation(),e.preventDefault()}_onMouseMove(e){const t=e.clientX-this.canvas.offsetLeft,i=e.clientY-this.canvas.offsetTop;if(this.startRotate){const e=(t-this.prevX)/this.canvas.offsetWidth/2,s=(i-this.prevY)/this.canvas.offsetHeight/2,o=Math.max(3*this.distance,.5);this.dtheta+=o*e,this.dphi+=o*s}this.prevX=t,this.prevY=i}_onMouseUp(){this.startRotate&&(this.startRotate=!1,this.emit(c.cameraMoveEnd))}damp(e){const t=.8*e;return t<.005&&t>-.005?0:t}clamp(e,t,i){return Math.min(Math.max(e,t),i)}attachEventListener(){document.body.addEventListener("keydown",this._onKeyDown),document.body.addEventListener("keyup",this._onKeyUp),document.body.addEventListener("mousedown",this._onMouseDown),document.body.addEventListener("contextmenu",this._onContextMenu),document.body.addEventListener("mousemove",this._onMouseMove),document.body.addEventListener("mouseup",this._onMouseUp);const e=document.getElementsByTagName("canvas")[0];if(!e)throw new Error("could not find html canvas");this.canvasElement=e,this.canvasElement.addEventListener("touchstart",this._onTouchStart),this.canvasElement.addEventListener("touchmove",this._onTouchMove),this.canvasElement.addEventListener("touchend",this._onTouchEnd)}releaseEventListener(){document.body.removeEventListener("keydown",this._onKeyDown),document.body.removeEventListener("keyup",this._onKeyUp),document.body.removeEventListener("mousedown",this._onMouseDown),document.body.removeEventListener("contextmenu",this._onContextMenu),document.body.removeEventListener("mousemove",this._onMouseMove),document.body.removeEventListener("mouseup",this._onMouseUp),this.canvasElement&&(this.canvasElement.removeEventListener("touchstart",this._onTouchStart),this.canvasElement.removeEventListener("touchmove",this._onTouchMove),this.canvasElement.removeEventListener("touchend",this._onTouchEnd))}}function p(e){return Object(o.w)(e.target,e.eye)}},1380:function(e,t,i){"use strict";var s=i(1375),o=i(1507),n=i(1510),r=i(1513);function a(e,t,i){return e&&t?1:3-(e+t+i)}function l(e,t,i,s,o,n,r,l){var h=32768&t?1:0,c=32768&i?1:0,d=32768&s?1:0,p=32768&o?1:0,u=32768&n?1:0,f=32768&r?1:0,m=32768&l?1:0;return(a(d,h,32768&e?1:0)<<16)+(a(h,p,c)<<18)+(a(p,f,m)<<20)+(a(f,d,u)<<22)}function h(e,t,i,s,o,n,r,a,h,c,d,p,u,f,m,g,v,b){var x=!(32768&o),y=!(32768&f);return f&&(!o||x&&!y)?f|1<<24|l(e,t,i,s,n,r,a,h):o&&(!f||y&&!x)?o|l(c,d,p,u,m,g,v,b):void 0}var c=function(){function e(e,t,i,s){return{name:e,lvalue:t,rvalue:i,count:s}}for(var t={args:[],thisVars:[],localVars:[],body:""},i=["scalar","array","array","array","array"],s=[e("_func",!1,!0,3),e("_o0",!0,!1,1),e("_o1",!0,!1,1),e("_o2",!0,!1,1)],n=[],r=0;r<3;++r){for(var a=(r+1)%3,l=(r+2)%3,c=[],d=0;d<2;++d)for(var p=0;p<=2;++p)for(var u=0;u<=2;++u){var f=[u,p,d];c.push(["_a",f[l],f[a],f[r]].join(""))}n.push(["_o",r,"=_func(",c.join(","),")"].join(""))}var m=n.join("\n");for(u=-1;u<=1;++u)for(p=-1;p<=1;++p)for(d=-1;d<=1;++d)if(1!==u||1!==p||1!==d){-1===u&&-1===p&&-1===d||i.push({offset:[u+1,p+1,d+1],array:3});var g=["_a",u+1,p+1,d+1].join("");s.push(e(g,!1,!0,m.split(g).length-1))}return o({args:i,pre:t,body:{args:s,body:m,thisVars:[],localVars:[]},post:t,funcName:"calcAO"}).bind(void 0,h)}();function d(){this.buffer=r.mallocUint8(1024),this.ptr=0,this.z=0,this.u=0,this.v=0,this.d=0}var p=new Uint8Array([0,153,204,255]);d.prototype.append=function(e,t,i,s,o){var n=this.buffer,a=this.ptr>>>0,l=0|this.z,h=0|this.u,c=0|this.v,d=0|this.d;if(a+48>n.length){var u=r.mallocUint8(2*n.length);u.set(n),r.freeUint8(n),n=u,this.buffer=n}var f=!!(o&1<<24),m=d+(f?3:0),g=o>>>16&3,v=o>>>18&3,b=o>>>20&3,x=o>>>22&3,y=(x<<6)+(b<<4)+(v<<2)+g,_=(h<<4)+(c<<2)+d,E=p[g],M=p[v],S=p[b],w=p[x],C=function(e,t,i){return i?i.get(255&e,t):255&e}(65535&o,m,this.voxelSideTextureIDs),P=128,k=128,R=128,I=f?127:129;0===d?P=I:1===d?k=I:2===d&&(R=I);var O=E+S128?1:t<128?2:t>128?3:i<128?4:i>128?5:0}(P,k,R);O?f?(n[a+h]=e,n[a+c]=t,n[a+d]=l,n[a+3]=E,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=t,n[a+d]=l,n[a+3]=M,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=e,n[a+c]=s,n[a+d]=l,n[a+3]=w,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=s,n[a+d]=l,n[a+3]=S,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=e,n[a+c]=s,n[a+d]=l,n[a+3]=w,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=t,n[a+d]=l,n[a+3]=M,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,a+=8):(n[a+h]=e,n[a+c]=t,n[a+d]=l,n[a+3]=E,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=e,n[a+c]=s,n[a+d]=l,n[a+3]=w,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=t,n[a+d]=l,n[a+3]=M,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=s,n[a+d]=l,n[a+3]=S,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=t,n[a+d]=l,n[a+3]=M,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=e,n[a+c]=s,n[a+d]=l,n[a+3]=w,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,a+=8):f?(n[a+h]=e,n[a+c]=s,n[a+d]=l,n[a+3]=w,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=e,n[a+c]=t,n[a+d]=l,n[a+3]=E,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=s,n[a+d]=l,n[a+3]=S,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=t,n[a+d]=l,n[a+3]=M,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=s,n[a+d]=l,n[a+3]=S,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=e,n[a+c]=t,n[a+d]=l,n[a+3]=E,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,a+=8):(n[a+h]=e,n[a+c]=t,n[a+d]=l,n[a+3]=E,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=e,n[a+c]=s,n[a+d]=l,n[a+3]=w,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=s,n[a+d]=l,n[a+3]=S,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=s,n[a+d]=l,n[a+3]=S,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=i,n[a+c]=t,n[a+d]=l,n[a+3]=M,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,n[(a+=8)+h]=e,n[a+c]=t,n[a+d]=l,n[a+3]=E,n[a+4]=_,n[a+5]=j,n[a+6]=y,n[a+7]=C,a+=8),this.ptr=a};var u=new d,f=n({order:[1,0],append:d.prototype.append.bind(u)});var m,g,v,b=(m=d.prototype.append.bind(u),g=r.mallocUint8,v=r.freeUint8,function(e,t,i,s,o){for(var n=e.data,r=e.offset,a=e.shape,l=e.stride,h=0|l[1],c=0|a[1],d=0|h,p=0,u=0,f=0,b=0|l[0],x=0|a[0],y=b-h*c|0,_=0,E=0,M=0,S=c,w=0|y,C=r>>>0,P=0,k=0,R=0,I=0,O=0,j=0,T=0,N=c*x,D=g(N);I({x:e.x-o[0]+1,y:e.y-o[1]+1,z:e.z-o[2]+1,c:e.c}));return u(s,{x:n[0]-o[0]+1,y:n[1]-o[1]+1,z:n[2]-o[2]+1},l[0])}}return{coords:s,lo:o,hi:n}}(i,t);return[function(e,t,i){const o=[];o[0]=i[0]-t[0]+1,o[1]=i[1]-t[1]+1,o[2]=i[2]-t[2]+2;const n=Object(s.b)(o[1],o[2],o[0]);for(let e=0;e{try{const[i,s]=d(e.target.result);return t&&t({voxels:i,colors:s}),{voxels:i,colors:s}}catch(e){return void console.log("readFromMVox error",e)}},i.readAsArrayBuffer(e)}function m(e,t){const i=new FileReader;return i.onload=e=>{const i=JSON.parse(e.target.result);return t&&t(i),i},i.readAsText(e),!1}function g(e,t,i="text/plain"){if(!c)return;let s;s=new Blob([t],{type:i});const o=document.createElementNS("http://www.w3.org/1999/xhtml","a");o.href=c.createObjectURL(s),o.download=e,function(e){const t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}(o)}function v(e,t){const i=e.width,s=e.height,o=Math.min(i,s);return function(e,t,i="image/jpeg"){const s={sx:0,sy:0,sw:0,sh:0,dw:0,dh:0};let o;o="string"==typeof e?document.getElementById(e):e;null==b&&(b=document.createElement("canvas"));"object"==typeof t&&(s.sw=t.sw||o.width,s.sh=t.sh||o.height,s.sx=t.sx||(o.width-s.sw)/2,s.sy=t.sy||(o.height-s.sh)/2,s.dw=t.dw||o.width,s.dh=t.dh||o.height);b.width=s.dw,b.height=s.dh,x||(x=b.getContext("2d"));return x.drawImage(o,s.sx,s.sy,s.sw,s.sh,0,0,s.dw,s.dh),b.toDataURL(i,1)}(e,{sx:(i-o)/2,sy:(s-o)/2,sw:o,sh:o,dw:250,dh:250},t)}let b,x;function y(e){const t=e||b;return new Promise((e,i)=>{if(!t)return i(new Error("getImageBuffer: canvas is not init"));t.toBlob(t=>{if(!t)return i(new Error("getImageBuffer: blob is null"));const s=new FileReader;s.onload=t=>{e(t.target.result)},s.readAsArrayBuffer(t)},"image/jpeg",.7)})}function _(e,t){const i=new FileReader;i.onload=function(e){const i=e.target.result.split("\n"),s=[],o=[],n=[],r=[],a=[];for(let e=0;et in e?B(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,G=(e,t)=>{for(var i in t||(t={}))H.call(t,i)&&F(e,i,t[i]);if(z)for(var i of z(t))U.call(t,i)&&F(e,i,t[i]);return e},W=(e,t,i)=>new Promise((s,o)=>{var n=e=>{try{a(i.next(e))}catch(e){o(e)}},r=e=>{try{a(i.throw(e))}catch(e){o(e)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(n,r);a((i=i.apply(e,t)).next())});class Y extends w.EventEmitter{constructor(e){super(),this._rendering=!1,this.connectedToGameEditor=!1,this.maxNameLen=30,this._sensorsReport=(e=!1,t=!0,i="")=>{const s={is_success:t,fail_reason:i,is_first_save:e,voxel_name:this.veState.projectInfo.dispaly_name,voxel_id:this.veState.projectInfo.content_id};this.sensors.track(V.c.VOXEL_SAVE,s)},this.sensors=new V.a,this.brpc=e.brpc,this.content=e.content,this.logger=e.logger.create("voxel-builder"),e.client?(this._parentClient=e.client,this._voxelEditorClient=new E.a({client:this._parentClient,content:e.content})):this._voxelEditorClient=new E.a({content:e.content}),this._regl=e.regl,this.camera=new n.a(this._regl._gl.canvas),this.veState=new x.a;const t=this.veState.basicConfig.workspaceSize,[i,s,o]=t;this.paletteManager=new u.a(this);const a={wireframeColor:[.6,.6,.6],veState:this.veState,editor:this};if(e.loader)this._reglLoader=e.loader;else{const e=document.createElement("canvas");Object.assign(e.style,{border:0,margin:0,padding:0,top:0,left:0,position:"absolute",width:"100%",height:"100%","pointer-events":"none"}),document.body.appendChild(e);const t=e.getContext("2d");if(!t)throw new Error("bad context2d");this._reglLoader=Object(c.a)(this._regl,!0,t)}const f=this.content.cdnPath;var g;this.destModel=new v.a(this._regl,this._reglLoader,G({voxels:Object(m.h)(i,s,o),name:"destModel"},a),f),this.editingModel=new v.a(this._regl,this._reglLoader,G({voxels:Object(m.h)(i,s,o),name:"editingModel"},a),f),this.selectionModel=new v.a(this._regl,this._reglLoader,(g=G({voxels:Object(m.h)(i,s,o),name:"selectionModel"},a),A(g,L({wireframeColor:[1,1,1]}))),f),this.selectionModel.inflate=!0,this.selectionModel.showGrid(!0),Object(r.b)(i,s,o),this.boundaryBox=Object(l.a)([i,s,o],"#111111");const b=this._reglLoader.require(h.a);this.pointer=new p.a(this._regl,this),this.previewModel=new O.a(this._regl),this.previewMesh=new y.a(this._regl,this),this.camera.setPosition([i,s,o]),this.veController=new d.a({veState:this.veState,editor:this,canvas:this._regl._gl.canvas,camera:this.camera,boundaryBox:this.boundaryBox,destModel:this.destModel,editingModel:this.editingModel,selectionModel:this.selectionModel,pointer:this.pointer,paletteManager:this.paletteManager});const _=this;this.voxelEditorFrameCB=function(){_.camera.updateCamera(),b.renderFrame({camera:_.camera,veState:_.veState,boundaryBox:_.boundaryBox,pointer:_.pointer,axis:Object(r.a)(),destModel:_.destModel,editingModel:_.editingModel,selectionModel:_.selectionModel,triangleMesh:_.previewMesh.triangleMeshs,pbrRenderer:_.pbrRenderer})};const M=Object.keys(localStorage);for(let e=0;e{const t=P.a.alloc();t.type=P.c.closeEcho,t.from=P.b.voxelEditor,t.data.type="empty",this.veState.gameEditorSource&&this.veState.gameEditorSource.postMessage(t,e.origin),this.connectedToGameEditor=!1}),this.connectedToGameEditor=!0,this.emit(b.a.FORCEUPDATETOPBAR)}}}createPbrRenderer(){const e=this.veState.basicConfig.workspaceSize;this.pbrRenderer=new j.a(this._regl,this._reglLoader,this.camera,e[0],e[1],e[2])}renderDom(e){return!1===this._rendering&&e.onOpen(),s.createElement(_.a,{VERef:this,voxelEditorClient:this._voxelEditorClient,mainCamera:this.camera,veState:this.veState,onClose:e.onClose,onHandleLogin:e.onHandleLogin})}startFrame(){return W(this,null,(function*(){if(document.body.style.overflow="hidden",this.veController.attachEvent(),this._rendering=!0,null!=this.veState.loadProjectInfo){const e=this._voxelEditorClient.fetchModelProjectData(this.veState.loadProjectInfo.modelProjectHash);this.onProjectLoadingStart(),e.then(e=>{this.onProjectLoadingFinished(),this.loadProject(JSON.parse(e),this.veState.loadProjectInfo),this.veState.loadProjectInfo=null,this.historyManagerRBTree.emptyHistory()},e=>{this.onProjectLoadingFinished(),console.log(e)})}else this.newFile();const e=document.getElementsByTagName("body");e&&e[0]&&(e[0].style.overflowY="hidden")}))}stopFrame(){document.body.style.overflow="initial",this.veController.releaseEvent(),this.veState.setEditingActions(m.a.Attach),this._rendering=!1;const e=document.getElementsByTagName("body");e&&e[0]&&(e[0].style.overflowY="initial")}newFile(){this.veController.clearAllModels(),this.veState.projectInfo.dispaly_name="new_model",this.veState.projectInfo.content_id=-1,this.veState.projectInfo.preview="",this.veState.projectInfo.description="",this.updateSpaceSize(32,32,32),this.emit(b.a.PROJECTINFOCHANGE),this.historyManagerRBTree.emptyHistory(),this.veController.saveStepMark=0,this.veController.editStepCount=0}previewBackendContent(e){this.loadBackendContent(e),this.veState.setEditingActions(m.a.PickColor)}loadBackendContent(e){const t={name:e.name,contentId:e.content_id},i=this._voxelEditorClient.fetchModelProjectData(e.hash);this.onProjectLoadingStart(),i.then(e=>{this.onProjectLoadingFinished(),this.loadProject(JSON.parse(e),t)},e=>{this.onProjectLoadingFinished(),console.log(e)})}downloadModel(){this.destModel.getCompactModelData(t=>{const i=new o.c(12);P.d.diff(P.d.identity,t,i),Object(S.a)(this.veState.projectInfo.dispaly_name+".vem",new e(i.bytes()))})}getScreenShot(e,t){this.boundaryBox.show=!1,this._regl._gl.canvas.width=window.innerWidth,this._regl._gl.canvas.height=window.innerHeight,setTimeout(()=>{const i=Object(S.f)(this._regl._gl.canvas,t);this.boundaryBox.show=!0;const s=this.veState.projectInfo.content_id;e(i,s)},20)}getProjectData(){const e=new o.c(12);Object(f.e)(this.destModel.voxels,e);const t=[],i=[],s=[],n=this.paletteManager.getAllColortables();for(let e=0;eW(this,null,(function*(){Object(S.f)(this._regl._gl.canvas);const o=yield Object(S.b)(),n=yield this.content.storeImageBuffer(o,"jpeg"),r=yield this.content.storeProjectDataDirectly(JSON.stringify(t));if(this.boundaryBox.show=!0,this._regl._gl.canvas.width=i,this._regl._gl.canvas.height=s,this.brpc)try{const t=P.a.alloc();t.type=P.c.savedModel,t.from=P.b.voxelEditor,t.data.type="savedResult";const i=t.data.data=P.f.alloc();i.previewHash=n,i.projectHash=r,i.name=this.veState.projectInfo.dispaly_name,this._sensorsReport(),this.veState.gameEditorSource.postMessage(t,this.veState.gameEditorOrigin),e({projectHash:r,previewHash:n})}catch(e){this._sensorsReport(!1,!1,e),R.a.error(I.e("saveProjectError")),this.logger.error(e)}else R.a.error(I.e("rpcServerConnectionError"))})),20)}saveToServer(e,t,i){const s=this.getProjectData();this.boundaryBox.show=!1;const o=this._regl._gl.canvas.width,n=this._regl._gl.canvas.height;this._regl._gl.canvas.width=window.innerWidth,this._regl._gl.canvas.height=window.innerHeight,setTimeout(()=>W(this,null,(function*(){const r=this.veState.projectInfo.content_id;if(Object(S.f)(this._regl._gl.canvas),this.boundaryBox.show=!0,this._regl._gl.canvas.width=o,this._regl._gl.canvas.height=n,this.veState.projectInfo.dispaly_name=e,this.brpc)try{const e=(yield this.brpc.auth.api.online({entry:D.c.edit})).data;if(!e)throw new Error("unauthorized");const i=yield Object(S.b)(),o=yield this.content.storeImageBuffer(i,"jpeg");if(-1===r||void 0===r)try{const i=yield this.brpc.content.api.addVoxel({name:this.veState.projectInfo.dispaly_name,projectData:JSON.stringify(s),image:o,describe:"",author_id:e.id,engine_version:""});i.content_id&&(this.veState.projectInfo.content_id=i.content_id),this._sensorsReport(!0),t()}catch(e){this._sensorsReport(!0,!1,e),R.a.error(I.e("saveProjectError")),this.logger.error(e)}else this.brpc.content.api.updateVoxel({content_id:r,projectData:JSON.stringify(s),image:o,name:this.veState.projectInfo.dispaly_name,describe:this.veState.projectInfo.description,author_id:e.id,engine_version:""}).then(e=>{this._sensorsReport(!1),t()}).catch(e=>{this._sensorsReport(!0,!1,e),R.a.error(I.e("saveProjectError")),this.logger.error(e)})}catch(e){i(),R.a.error(I.e("pleaseLoginFirst")),this.logger.error(e)}else R.a.error(I.e("rpcServerConnectionError"))})),20)}download(){const e=this.getProjectData();e.fileName=this.veState.projectInfo.dispaly_name,Object(S.a)(this.veState.projectInfo.dispaly_name+".vd",JSON.stringify(e))}loadProject(e,t){try{const t=e,{destModel:i,editingModel:s,selectionModel:n}=this;for(let e=0;e<4;e++)this.paletteManager.colorTables[e].initWithExistColors(t.HEXCOLORS[e]),this.paletteManager.colorTables[e].setPbrArray(t.PBRATTRBS[e]),t.TR&&t.TR[e]&&this.paletteManager.colorTables[e].setTRArray(t.TR[e]);null!=t.CURRENTCOLORINDEX&&"number"==typeof t.CURRENTCOLORINDEX&&this.paletteManager.choiceColorTable(t.CURRENTCOLORINDEX),this.emit(b.a.REBUILDCOLORTABLE);let a=0,h=0,c=0;if(void 0!==t.ENCODEVOXELS){const e=new o.b(new Uint8Array(t.ENCODEVOXELS));if(a=e.readInt32(),h=e.readInt32(),c=e.readInt32(),a!==i.voxels.shape[0]||h!==i.voxels.shape[1]||c!==i.voxels.shape[2])Object(f.c)(i.voxels),Object(f.c)(s.voxels),Object(f.c)(n.voxels),i.voxels=Object(m.h)(a,h,c),s.voxels=Object(m.h)(a,h,c),n.voxels=Object(m.h)(a,h,c);else for(let e=0;e0&&(e[0]=Math.min(i,e[0]),e[1]=Math.min(s,e[1]),e[2]=Math.min(o,e[2]),t[0]=Math.max(i,t[0]),t[1]=Math.max(s,t[1]),t[2]=Math.max(o,t[2])),this.editingModel.voxels.setVoxel(i,s,o,n)}const s=t[0]-e[0]+1,o=t[1]-e[1]+1,n=t[2]-e[2]+1;if((s!=this.destModel.voxels.shape[0]||o!=this.destModel.voxels.shape[1]||n!=this.destModel.voxels.shape[2])&&!(s<0||o<0||n<0)){this.saveHistory(),Object(f.c)(this.destModel.voxels),Object(f.c)(this.selectionModel.voxels),this.destModel.voxels=Object(m.h)(s,o,n),this.selectionModel.voxels=Object(m.h)(s,o,n);for(let i=0,s=e[0];s<=t[0];i++,s++)for(let o=0,n=e[1];n<=t[1];o++,n++)for(let r=0,a=e[2];a<=t[2];r++,a++)this.destModel.voxels.setVoxel(i,o,r,this.editingModel.voxels.getVoxel(s,n,a));Object(f.c)(this.editingModel.voxels),this.editingModel.voxels=Object(m.h)(s,o,n),this.destModel.resizeWorkerVoxel([s,o,n]),this.editingModel.resizeWorkerVoxel([s,o,n]),this.selectionModel.resizeWorkerVoxel([s,o,n]),this.editingModel.syncWorkerVoxelData(),this.selectionModel.syncWorkerVoxelData(),this.destModel.syncWorkerVoxelData(),this.destModel.bakeData(),Object(l.b)(this.boundaryBox,[s,o,n],"111111"),Object(r.c)([s,o,n]),this.veState.basicConfig.workspaceSize[0]=s,this.veState.basicConfig.workspaceSize[1]=o,this.veState.basicConfig.workspaceSize[2]=n,this.camera.setPosition(this.veState.basicConfig.workspaceSize),this.emit(b.a.CHANGESIZE),console.log("changeSize",i,"to",[s,o,n]),this.saveHistory()}}resize(e,t,i){const{destModel:s,editingModel:o,selectionModel:n}=this;if(e==s.voxels.shape[0]&&t==s.voxels.shape[1]&&i==s.voxels.shape[2])return;const a=Object(m.h)(e,t,i);let h,c,d,p,u,g,v;e>s.voxels.shape[0]?(h=Math.floor((e-s.voxels.shape[0])/2),d=0,u=s.voxels.shape[0]):e==s.voxels.shape[0]?(h=d=0,u=s.voxels.shape[0]):es.voxels.shape[2]?(c=Math.floor((i-s.voxels.shape[2])/2),p=0,v=s.voxels.shape[2]):i==s.voxels.shape[2]?(c=p=0,v=s.voxels.shape[2]):i{const n=new a.a(e,s);this.previewMesh.addTriMesh(n),this.previewMesh.fitPosSize(n),t&&t(n)})}importVDModel(e){Object(S.e)(e,e=>{this.loadProject(e,{name:e.fileName,contentId:-1})})}importVoxModel(e){Object(S.d)(e,({voxels:e,colors:t})=>{const i=e.shape;this.updateSpaceSize(i[0],i[1],i[2]),Object(f.c)(this.destModel.voxels),this.destModel.voxels=e,this.paletteManager.colorTables[0].initWithExistColors(t),this.emit(b.a.REBUILDCOLORTABLE),this.destModel.syncWorkerVoxelData(),this.destModel.bakeData()})}importTwoViewImage(e,t){let i,s;const o=this,n=this.destModel.voxels.shape;function r(){o.destModel.clearVoxel(),o.selectionModel.clearVoxel(),o.paletteManager.choiceColorTable(3);let e=i.height,t=i.width,r=i.height,a=i.width;a*=e/r,r=e;const l=Math.max(a,r,t),h=Math.max(n[0],n[1],n[2]);a=a/l*h,r=e=r/l*h,t=t/l*h,i.setRow(Math.max(t,r)),s.setRow(Math.max(r,a));let c=i.getColorArray(),d=0;a=Math.floor(s.width),e=Math.floor(i.height),t=Math.floor(i.width);for(let i=e-1;i>=0;i--)for(let e=t-1;e>=0;e--){const t=c[d];if("transparent"===t){d++;continue}const s=t.split(",").map(e=>parseInt(e));let n=Object(k.c)(s)+1;256===n&&(n=255);for(let t=0;t=0;i--)for(let e=a-1;e>=0;e--){const s=c[d];if("transparent"===s){d++;continue}if(void 0===s)return;const n=s.split(",").map(e=>parseInt(e));let r=Object(k.c)(n)+1;256==r&&(r=255);for(let s=0;s{i=e,s&&r()}),Object(g.a)(t,e=>{s=e,i&&r()})}importPixelImage(e,t){const i=this.destModel.voxels.shape,s=Math.max(i[0],i[1],i[2]);Object(g.a)(e,e=>{e.setRow(s);const o=e.getColorArray(),n=Math.floor(e.height),r="x"==t?Math.floor(e.width):i[0],a="x"==t?i[0]:Math.floor(e.width);this.updateSpaceSize(a,n,r),this.paletteManager.choiceColorTable(3);let l=0;const h=k.c,c="x"===t?r-1:a-1;for(let e=n-1;e>=0;e--)for(let i=c;i>=0;i--){const s=o[l];if("transparent"===s){l++;continue}let n=h(s.split(",").map(e=>parseInt(e)))+1;if(256==n&&(n=255),"x"===t)for(let t=0;t{this.selectionModel.voxels.setVoxel(e[0],e[1],e[2],15)}),this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData()}loadPreviewImg(e){return this._voxelEditorClient.loadPreviewImg(e)}prevStep(){const e=this.historyManagerRBTree.getPrevHistory();null!=e&&this.syncData(e)}nextStep(){const e=this.historyManagerRBTree.getNextHistory();null!=e&&this.syncData(e)}saveHistory(e){this.historyManagerRBTree.saveHistory([this.destModel.voxels,this.selectionModel.voxels],e)}syncData(e){e[0].shape[0]===this.destModel.voxels.shape[0]&&e[0].shape[1]===this.destModel.voxels.shape[1]&&e[0].shape[2]===this.destModel.voxels.shape[2]||(this.veState.basicConfig.workspaceSize[0]=e[0].shape[0],this.veState.basicConfig.workspaceSize[1]=e[0].shape[1],this.veState.basicConfig.workspaceSize[2]=e[0].shape[2],Object(l.b)(this.boundaryBox,[e[0].shape[0],e[0].shape[1],e[0].shape[2]],"111111"),Object(r.c)([e[0].shape[0],e[0].shape[1],e[0].shape[2]]),this.camera.setPosition(this.veState.basicConfig.workspaceSize),this.emit(b.a.CHANGESIZE)),Object(f.c)(this.destModel.voxels),this.destModel.voxels=e[0],this.destModel.syncWorkerVoxelData(),this.destModel.bakeData(),null!=e[1]&&(Object(f.c)(this.selectionModel.voxels),this.selectionModel.voxels=e[1],this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData())}}}).call(this,i(257).Buffer)},1502:function(e,t,i){"use strict";var s=i(1503);e.exports=function(e,t,i){"function"==typeof e&&(i=!!t,t=e,e=window);var o=s("ex",e),n=function(e){i&&e.preventDefault();var s=e.deltaX||0,n=e.deltaY||0,r=e.deltaZ||0,a=1;switch(e.deltaMode){case 1:a=o;break;case 2:a=window.innerHeight}if(n*=a,r*=a,(s*=a)||n||r)return t(s,n,r,e)};return e.addEventListener("wheel",n),n}},1503:function(e,t,i){"use strict";var s=i(1504);e.exports=a;var o=r("in",document.body);function n(e,t){var i=s(getComputedStyle(e).getPropertyValue(t));return i[0]*a(i[1],e)}function r(e,t){var i=document.createElement("div");i.style.height="128"+e,t.appendChild(i);var s=n(i,"height")/128;return t.removeChild(i),s}function a(e,t){if(!e)return null;switch(t=t||document.body,e=(e+""||"px").trim().toLowerCase(),t!==window&&t!==document||(t=document.body),e){case"%":return t.clientHeight/100;case"ch":case"ex":return r(e,t);case"em":return n(t,"font-size");case"rem":return n(document.body,"font-size");case"vw":return window.innerWidth/100;case"vh":return window.innerHeight/100;case"vmin":return Math.min(window.innerWidth,window.innerHeight)/100;case"vmax":return Math.max(window.innerWidth,window.innerHeight)/100;case"in":return o;case"cm":return o/2.54;case"mm":return o/25.4;case"pt":return o/72;case"pc":return o/6;case"px":return 1}var i=s(e);if(!isNaN(i[0])&&i[1]){var l=a(i[1],t);return"number"==typeof l?i[0]*l:null}return null}},1504:function(e,t){e.exports=function(e,t){t||(t=[0,""]),e=String(e);var i=parseFloat(e,10);return t[0]=i,t[1]=e.match(/[\d.\-\+]*\s*(.*)/)[1]||"",t}},1505:function(e,t,i){"use strict";function s(e,t,i){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2)+Math.pow(i,2))}function o(e,t,i){return Math.atan2(t,e-i)}function n(e,t,i,s,o){e[0]+=t*i,e[1]+=t*s,e[2]+=t*o}e.exports=function(e,t){for(var i=t.length,r=e.length,a=new Array(i),l=0;le/255);for(let e=0;e0)throw new Error("cwise: pre() block may not reference array args");if(n0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===r)t.scalarArgs.push(n),t.shimArgs.push("scalar"+n);else if("index"===r){if(t.indexArgs.push(n),n0)throw new Error("cwise: pre() block may not reference array index");if(n0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===r){if(t.shapeArgs.push(n),ni.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>i.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>i.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,s(t)}},1508:function(e,t,i){"use strict";var s=i(1509);e.exports=function(e){var t=["'use strict'","var CACHED={}"],i=[],o=e.funcName+"_cwise_thunk";t.push(["return function ",o,"(",e.shimArgs.join(","),"){"].join(""));for(var n=[],r=[],a=[["array",e.arrayArgs[0],".shape"].join("")],l=0;l0,l=[],h=[],c=0,d=0;for(s=0;s=0;--s)c=e[s],l.push(["for(i",s,"=0;i",s,"0&&l.push(["index[",d,"]-=s",d].join("")),l.push(["++index[",c,"]"].join(""))),l.push("}")}return l.join("\n")}function n(e,t,i){for(var s=e.body,o=[],n=[],r=0;r0&&(i=i&&t[s]===t[s-1])}return i?t[0]:t.join("")}e.exports=function(e,t){for(var i=0|t[1].length,a=new Array(e.arrayArgs.length),l=new Array(e.arrayArgs.length),h=["SS"],c=["'use strict'"],d=[],p=0;p0&&d.push("shape=SS.slice(0)"),e.indexArgs.length>0){var f=new Array(i);for(u=0;u3&&c.push(n(e.pre,e,l));var b=n(e.body,e,l),x=function(e){for(var t=0,i=e[0].length;t0,h=[],c=0;c0;){"].join("")),h.push(["if(j",c,"<",a,"){"].join("")),h.push(["s",t[c],"=j",c].join("")),h.push(["j",c,"=0"].join("")),h.push(["}else{s",t[c],"=",a].join("")),h.push(["j",c,"-=",a,"}"].join("")),l&&h.push(["index[",t[c],"]=j",c].join(""));for(c=0;c3&&c.push(n(e.post,e,l)),e.debug&&console.log("Generated cwise routine for ",t,":\n\n",c.join("\n"));var y=[e.funcName||"unnamed","_cwise_loop_",a[0].join("s"),"m",x,r(l)].join("");return new Function(["function ",y,"(",h.join(","),"){",c.join("\n"),"} return ",y].join(""))()}},1510:function(e,t,i){"use strict";var s=i(1511),o=(i(570),i(1401));e.exports=function(e){if(!(e=e||{}).order)throw new Error("greedy-mesher: Missing order field");if(!e.append)throw new Error("greedy-mesher: Missing append field");return function(e,t,i,n,r,a,l){var h,c=[],d=e.length,p=new Array(2*d+1+r);for(f=0;f0?c.push(["var astep",f,"=(stride",f,"-stride",f-1,"*shape",f-1,")|0"].join("")):c.push(["var astep",f,"=stride",f,"|0"].join("")),f>0?c.push(["var vstep",f,"=(vstep",f-1,"*shape",f-1,")|0"].join("")):c.push(["var vstep",f,"=1"].join("")),c.push(["var i",f,"=0,j",f,"=0,k",f,"=0,ustep",f,"=vstep",f,"|0,bstep",f,"=astep",f,"|0"].join(""));for(c.push("var a_ptr=offset>>>0,b_ptr=0,u_ptr=0,v_ptr=0,i=0,d=0,val=0,oval=0"),c.push("var count="+o(d).map((function(e){return"shape"+e})).join("*")),c.push("var visited=mallocUint8(count)"),c.push("for(;i=0;--f)c.push(["for(i",f,"=0;i",f,"=0;--h)c.push(["for(k",h,"=i",h,";k",h,"=0;--f)c.push(["for(k",f,"=i",f,";k",f,"0?i.pop():new ArrayBuffer(e)}function f(e){return new Uint8Array(u(e),0,e)}function m(e){return new Uint16Array(u(2*e),0,e)}function g(e){return new Uint32Array(u(4*e),0,e)}function v(e){return new Int8Array(u(e),0,e)}function b(e){return new Int16Array(u(2*e),0,e)}function x(e){return new Int32Array(u(4*e),0,e)}function y(e){return new Float32Array(u(4*e),0,e)}function _(e){return new Float64Array(u(8*e),0,e)}function E(e){return r?new Uint8ClampedArray(u(e),0,e):f(e)}function M(e){return a?new BigUint64Array(u(8*e),0,e):null}function S(e){return l?new BigInt64Array(u(8*e),0,e):null}function w(e){return new DataView(u(e),0,e)}function C(e){e=s.nextPow2(e);var t=s.log2(e),i=d[t];return i.length>0?i.pop():new n(e)}t.free=function(e){if(n.isBuffer(e))d[s.log2(e.length)].push(e);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(e)&&(e=e.buffer),!e)return;var t=e.length||e.byteLength,i=0|s.log2(t);c[i].push(e)}},t.freeUint8=t.freeUint16=t.freeUint32=t.freeBigUint64=t.freeInt8=t.freeInt16=t.freeInt32=t.freeBigInt64=t.freeFloat32=t.freeFloat=t.freeFloat64=t.freeDouble=t.freeUint8Clamped=t.freeDataView=function(e){p(e.buffer)},t.freeArrayBuffer=p,t.freeBuffer=function(e){d[s.log2(e.length)].push(e)},t.malloc=function(e,t){if(void 0===t||"arraybuffer"===t)return u(e);switch(t){case"uint8":return f(e);case"uint16":return m(e);case"uint32":return g(e);case"int8":return v(e);case"int16":return b(e);case"int32":return x(e);case"float":case"float32":return y(e);case"double":case"float64":return _(e);case"uint8_clamped":return E(e);case"bigint64":return S(e);case"biguint64":return M(e);case"buffer":return C(e);case"data":case"dataview":return w(e);default:return null}return null},t.mallocArrayBuffer=u,t.mallocUint8=f,t.mallocUint16=m,t.mallocUint32=g,t.mallocInt8=v,t.mallocInt16=b,t.mallocInt32=x,t.mallocFloat32=t.mallocFloat=y,t.mallocFloat64=t.mallocDouble=_,t.mallocUint8Clamped=E,t.mallocBigUint64=M,t.mallocBigInt64=S,t.mallocDataView=w,t.mallocBuffer=C,t.clearCache=function(){for(var e=0;e<32;++e)h.UINT8[e].length=0,h.UINT16[e].length=0,h.UINT32[e].length=0,h.INT8[e].length=0,h.INT16[e].length=0,h.INT32[e].length=0,h.FLOAT[e].length=0,h.DOUBLE[e].length=0,h.BIGUINT64[e].length=0,h.BIGINT64[e].length=0,h.UINT8C[e].length=0,c[e].length=0,d[e].length=0}}).call(this,i(187))},1512:function(e,t,i){"use strict";e.exports=function(e,t){switch(void 0===t&&(t=0),typeof e){case"number":if(e>0)return function(e,t){var i,s;for(i=new Array(e),s=0;s0){var n=o[o.length-1];return o.pop(),n}return new ArrayBuffer(e)}switch(t){case"uint8":var m=r[i];return m.length>0?m.pop():new Uint8Array(e);case"uint16":var g=a[i];return g.length>0?g.pop():new Uint16Array(e);case"uint32":var v=l[i];return v.length>0?v.pop():new Uint32Array(e);case"int8":var b=h[i];return b.length>0?b.pop():new Int8Array(e);case"int16":var x=c[i];return x.length>0?x.pop():new Int16Array(e);case"int32":var y=d[i];return y.length>0?y.pop():new Int32Array(e);case"float":case"float32":var _=p[i];return _.length>0?_.pop():new Float32Array(e);case"double":case"float64":var E=u[i];return E.length>0?E.pop():new Float64Array(e);default:return null}return null},t.mallocUint8=function(e){e=s.nextPow2(e);var t=s.log2(e),i=r[t];return i.length>0?i.pop():new Uint8Array(e)},t.mallocUint16=function(e){e=s.nextPow2(e);var t=s.log2(e),i=a[t];return i.length>0?i.pop():new Uint16Array(e)},t.mallocUint32=function(e){e=s.nextPow2(e);var t=s.log2(e),i=l[t];return i.length>0?i.pop():new Uint32Array(e)},t.mallocInt8=function(e){e=s.nextPow2(e);var t=s.log2(e),i=h[t];return i.length>0?i.pop():new Int8Array(e)},t.mallocInt16=function(e){e=s.nextPow2(e);var t=s.log2(e),i=c[t];return i.length>0?i.pop():new Int16Array(e)},t.mallocInt32=function(e){e=s.nextPow2(e);var t=s.log2(e),i=d[t];return i.length>0?i.pop():new Int32Array(e)},t.mallocFloat32=t.mallocFloat=function(e){e=s.nextPow2(e);var t=s.log2(e),i=p[t];return i.length>0?i.pop():new Float32Array(e)},t.mallocFloat64=t.mallocDouble=function(e){e=s.nextPow2(e);var t=s.log2(e),i=u[t];return i.length>0?i.pop():new Float64Array(e)},t.mallocArrayBuffer=function(e){e=s.nextPow2(e);var t=s.log2(e),i=f[t];return i.length>0?i.pop():new ArrayBuffer(e)},t.clearCache=function(){for(var e=0;e<32;++e)r[e].length=0,a[e].length=0,l[e].length=0,h[e].length=0,c[e].length=0,d[e].length=0,p[e].length=0,u[e].length=0,f[e].length=0}}).call(this,i(187))},1514:function(e,t,i){"use strict";function s(e){var t=32;return(e&=-e)&&t--,65535&e&&(t-=16),16711935&e&&(t-=8),252645135&e&&(t-=4),858993459&e&&(t-=2),1431655765&e&&(t-=1),t}t.INT_BITS=32,t.INT_MAX=2147483647,t.INT_MIN=-1<<31,t.sign=function(e){return(e>0)-(e<0)},t.abs=function(e){var t=e>>31;return(e^t)-t},t.min=function(e,t){return t^(e^t)&-(e65535)<<4,t|=i=((e>>>=t)>255)<<3,t|=i=((e>>>=i)>15)<<2,(t|=i=((e>>>=i)>3)<<1)|(e>>>=i)>>1},t.log10=function(e){return e>=1e9?9:e>=1e8?8:e>=1e7?7:e>=1e6?6:e>=1e5?5:e>=1e4?4:e>=1e3?3:e>=100?2:e>=10?1:0},t.popCount=function(e){return 16843009*((e=(858993459&(e-=e>>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)>>>24},t.countTrailingZeros=s,t.nextPow2=function(e){return e+=0===e,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,(e|=e>>>16)+1},t.prevPow2=function(e){return e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,(e|=e>>>16)-(e>>>1)},t.parity=function(e){return e^=e>>>16,e^=e>>>8,e^=e>>>4,27030>>>(e&=15)&1};var o=new Array(256);!function(e){for(var t=0;t<256;++t){var i=t,s=t,o=7;for(i>>>=1;i;i>>>=1)s<<=1,s|=1&i,--o;e[t]=s<>>8&255]<<16|o[e>>>16&255]<<8|o[e>>>24&255]},t.interleave2=function(e,t){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))<<1},t.deinterleave2=function(e,t){return(e=65535&((e=16711935&((e=252645135&((e=858993459&((e=e>>>t&1431655765)|e>>>1))|e>>>2))|e>>>4))|e>>>16))<<16>>16},t.interleave3=function(e,t,i){return e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2),(e|=(t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2))<<1)|(i=1227133513&((i=3272356035&((i=251719695&((i=4278190335&((i&=1023)|i<<16))|i<<8))|i<<4))|i<<2))<<2},t.deinterleave3=function(e,t){return(e=1023&((e=4278190335&((e=251719695&((e=3272356035&((e=e>>>t&1227133513)|e>>>2))|e>>>4))|e>>>8))|e>>>16))<<22>>22},t.nextCombination=function(e){var t=e|e-1;return t+1|(~t&-~t)-1>>>s(e)+1}},1515:function(e,t,i){"use strict";e.exports=function(e,t){switch(void 0===t&&(t=0),typeof e){case"number":if(e>0)return function(e,t){var i,s;for(i=new Array(e),s=0;s{},this.positions=[],this.elements=[],this._VERef=t,this.p=s["0,0,-1"]}update(e,t,i,n){if(this._absolutedPos=e,o(t,this._prevVoxelPos)&&o(i,this._prevNormal)&&n==this._prevHitBoundary)return;const r=function(e,t,i,o){let n,r;if(0==i[0]&&i[0]==i[1]&&i[1]==i[2]&&(0==e[0]&&(i[0]=-1),0==e[1]&&(i[1]=-1),0==e[2]&&(i[2]=-1)),0==o){n=[[0,1,2],[0,2,3]];const e=`${i[0]},${i[1]},${i[2]}`;if(!s[e])return;r=s[e].map(e=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]])}else{const e=[i[0],i[1],i[2]].map(e=>0==e?0:-1*e).join();if(!s[e])return;try{r=s[e].map(e=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]]),n=[[2,1,0],[3,2,0]]}catch(e){console.error(e)}}return{positions:r,elements:n,normal:i}}(e,t,i,n);r&&(this.p=r.positions,this.indecs=r.elements,this.positions=r.positions,this.elements=r.elements,this._quadPosition=r.positions,this._quadNormal=r.normal,this._prevVoxelPos=[t[0],t[1],t[2]],this._prevNormal=[i[0],i[1],i[2]],this._prevHitBoundary=n,this.onPositionChangeHook(t))}getAbsolutedPos(){return[this._absolutedPos[0],this._absolutedPos[1],this._absolutedPos[2]]}getNormal(){return[this._quadNormal[0],this._quadNormal[1],this._quadNormal[2]]}getVoxelPos(){return[this._prevVoxelPos[0],this._prevVoxelPos[1],this._prevVoxelPos[2]]}getPosition(){return this._quadPosition}}},1517:function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));class s{constructor(e,t,i){this.colorHub={},this.row=e,this.loadCallback=i,this.reader=this.createReader(),this.setSource(this.reader,t)}createReader(){const e=document.createElement("img"),t=document.createElement("canvas"),i=t.getContext("2d");return e.crossOrigin="Anonymous",e.onload=this.onLoad.bind(this),{canvas:t,context:i,image:e}}onLoad(){this.updateReader(this.reader),this.loadCallback(this.setRow.bind(this),this.getColorArray.bind(this))}setSource(e,t){e.image.src=t}updateReader(e){let t,i;e.image.heightnew Promise((s,o)=>{var n=e=>{try{a(i.next(e))}catch(e){o(e)}},r=e=>{try{a(i.throw(e))}catch(e){o(e)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(n,r);a((i=i.apply(e,t)).next())});class r{constructor(e){this.requestId=0,this.callBackHub={},this._content=e.content,e.client&&(this.protocol=e.client.protocol(s.g),this.protocol.configure({message:{saveDataEcho:e=>{const t=s.h.clone(e),i=t.requestId;i&&this.callBackHub[i]?this.callBackHub[i].resolve(t):console.log(i,"not exist in",this.callBackHub)}},ready:()=>{}}))}fetchModelList(){const e={},t=[];return Object.keys(e).map(i=>{t.push({author:e[i].author,name:e[i].name,modelProjectHash:e[i].modelProjectHash,previewHash:e[i].previewHash})}),t}fetchModelMeshData(e){return n(this,null,(function*(){return yield this._content.retrieve(e)}))}fetchModelProjectData(e){return n(this,null,(function*(){const t=yield this._content.retrieve(e);return t?Object(o.e)(t):""}))}loadPreviewImg(e){return n(this,null,(function*(){const t=yield this._content.retrieve(e);return t?Object(o.e)(t):""}))}}},1538:function(e,t,i){"use strict";i.d(t,"a",(function(){return E}));const s=Math.max,o=Math.min;function n(e,t,i){let s=e,o=s;return to&&(o=t),io&&(o=i),{min:s,max:o}}function r(e,t,i){const s=(e+(e<0?-1:1)*t*.5)/t;return(i?Math.floor(s):Math.ceil(s))*t}function a(e,t){e[0]-=t[0],e[1]-=t[1],e[2]-=t[2]}function l(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function h(e,t){e[0]=t[0],e[1]=t[1],e[2]=t[2]}const c=[0,0,0],d=[0,0,0],p=[0,0,0],u=[0,0,0],f=[0,0,0],m=[0,0,0];function g(e,t,i){let s,o,r,g,v,b,x,y;if(h(c,i.vertices[0]),h(d,i.vertices[1]),h(p,i.vertices[2]),a(c,e),a(d,e),a(p,e),h(u,d),h(f,p),h(m,c),a(u,c),a(f,d),a(m,p),s=function(e,t){const i=[0,0,0];return i[0]=e[1]*t[2]-e[2]*t[1],i[1]=e[2]*t[0]-e[0]*t[2],i[2]=e[0]*t[1]-e[1]*t[0],i}(u,f),g=-l(s,c),!function(e,t,i){const s=[0,0,0],o=[0,0,0];for(let t=0;t<=2;t++)e[t]>0?(s[t]=-i[t],o[t]=i[t]):(s[t]=i[t],o[t]=-i[t]);return!(l(e,s)+t>0)&&l(e,o)+t>=0}(s,g,t))return!1;let _=Math.abs(u[0]),E=Math.abs(u[1]),M=Math.abs(u[2]),S=u[2],w=u[1],C=M,P=E;if(v=S*c[1]-w*c[2],x=S*p[1]-w*p[2],vy||r<-y)return!1;if(S=u[2],w=u[0],C=M,P=_,v=-S*c[0]+w*c[2],x=-S*p[0]+w*p[2],vy||r<-y)return!1;if(S=u[1],w=u[0],C=E,P=_,b=S*d[0]-w*d[1],x=S*p[0]-w*p[1],xy||r<-y)return!1;if(_=Math.abs(f[0]),E=Math.abs(f[1]),M=Math.abs(f[2]),S=f[2],w=f[1],C=M,P=E,v=S*c[1]-w*c[2],x=S*p[1]-w*p[2],vy||r<-y)return!1;if(S=f[2],w=f[0],C=M,P=_,v=-S*c[0]+w*c[2],x=-S*p[0]+w*p[2],vy||r<-y)return!1;if(S=f[1],w=f[0],C=E,P=_,v=S*c[0]-w*c[1],b=S*d[0]-w*d[1],vy||r<-y)return!1;if(_=Math.abs(m[0]),E=Math.abs(m[1]),M=Math.abs(m[2]),S=m[2],w=m[1],C=M,P=E,v=S*c[1]-w*c[2],b=S*d[1]-w*d[2],vy||r<-y)return!1;if(S=m[2],w=m[0],C=M,P=_,v=-S*c[0]+w*c[2],b=-S*d[0]+w*d[2],vy||r<-y)return!1;if(S=m[1],w=m[0],C=E,P=_,b=S*d[0]-w*d[1],x=S*p[0]-w*p[1],xy||r<-y)return!1;let k=n(c[0],d[0],p[0]);return o=k.min,r=k.max,!(o>t[0]||r<-t[0])&&(k=n(c[1],d[1],p[1]),o=k.min,r=k.max,!(o>t[1]||r<-t[1])&&(k=n(c[2],d[2],p[2]),o=k.min,r=k.max,!(o>t[2]||r<-t[2])))}const v=[0,0,0],b=[0,0,0];function x(e){h(v,e.vertices[1]),h(b,e.vertices[2]),a(v,e.vertices[0]),a(b,e.vertices[0]);const t=v[1]*b[2]-v[2]*b[1],i=v[2]*b[0]-v[0]*b[2],s=v[0]*b[1]-v[1]*b[0];return.5*Math.sqrt(Math.pow(t,2)+Math.pow(i,2)+Math.pow(s,2))}function y(e){const t={min:[0,0,0],max:[0,0,0]};!function(e){e.max[0]=e.max[1]=e.max[2]=-1/0,e.min[0]=e.min[1]=e.min[2]=1/0}(t);for(let i=0;i<3;++i)for(let n=0;n<3;++n)t.max[i]=s(t.max[i],e.vertices[n][i]),t.min[i]=o(t.min[i],e.vertices[n][i]);return t}function _(e){return[.5*Math.abs(e.max[0]-e.min[0]),.5*Math.abs(e.max[1]-e.min[1]),.5*Math.abs(e.max[2]-e.min[2])]}function E(e,t,i,s,o,n){const a=[t,i,s],l=a.slice(0);var c,d;d=.5,(c=l)[0]*=d,c[1]*=d,c[2]*=d,function(e,t,i,s,o,n){const a={vertices:[[0,0,0],[0,0,0],[0,0,0]],colors:[[0,0,0],[0,0,0],[0,0,0]]},l={min:[0,0,0],max:[0,0,0]};for(let o=0;o0){this.cmData=e,this.cmBuffer=this._regl.buffer(e),this.vertCount=e.length/8;const t=n.e.fromValues(512,512,512),i=n.e.fromValues(-512,-512,-512);for(let s=0;s p.y) {\n return vec3(0, 0, 0);\n }\n p.y = min(p.y, raySphereIntersect(r0, r, rPlanet).x);\n float iStepSize = (p.y - p.x) / float(iSteps);\n\n // Initialize accumulators for Rayleigh and Mie scattering.\n vec3 totalRlh = vec3(0, 0, 0);\n vec3 totalMie = vec3(0, 0, 0);\n\n // Initialize optical depth accumulators for the primary ray.\n // optical depth is the average atmospheric density across the ray from point Pa to point Pb multiplied by the length of the ray\n float iOdRlh = 0.0;\n float iOdMie = 0.0;\n\n // since pSun and r are normolized, mu is the cos(theta) of two vector,\n float mu = dot(r, pSun);\n float mumu = mu * mu;\n float gg = g * g;\n float pRlh = 3.0 / (16.0 * PI) * (1.0 + mumu);\n float pMie = 3.0 / (8.0 * PI) * ((1.0 - gg) * (mumu + 1.0)) / (pow(1.0 + gg - 2.0 * mu * g, 1.5) * (2.0 + gg));\n\n for (int i = 0; i < iSteps; i++) {\n vec3 iPos = r0 + r * (iStepSize * (float(i) + 0.5));\n float iHeight = length(iPos) - rPlanet;\n float odStepRlh = exp(-iHeight / shRlh) * iStepSize;\n float odStepMie = exp(-iHeight / shMie) * iStepSize;\n\n // \n iOdRlh += odStepRlh;\n iOdMie += odStepMie;\n\n float jStepSize = raySphereIntersect(iPos, pSun, rAtmos).y / float(jSteps);\n float jOdRlh = 0.0;\n float jOdMie = 0.0;\n for (int j = 0; j < jSteps; j++) {\n vec3 jPos = iPos + pSun * (jStepSize * (float(j) + 0.5));\n\n float jHeight = length(jPos) - rPlanet;\n jOdRlh += exp(-jHeight / shRlh) * jStepSize;\n jOdMie += exp(-jHeight / shMie) * jStepSize;\n }\n\n vec3 attn = exp(-(kMie * (iOdMie + jOdMie) + kRlh * (iOdRlh + jOdRlh)));\n totalRlh += odStepRlh * attn;\n totalMie += odStepMie * attn;\n }\n\n return iSun * (pRlh * kRlh * totalRlh + pMie * kMie * totalMie);\n}\n\nvec3 atmosphere(vec3 r, vec3 r0, vec3 pSun, float iSun, float rPlanet, float rAtmos, vec3 kRlh, float kMie, float shRlh, float shMie, float g) {\n // Normalize the sun and view directions.\n pSun = normalize(pSun);\n r = normalize(r);\n\n // Calculate the step size of the primary ray.\n vec2 p = raySphereIntersect(r0, r, rAtmos);\n if (p.x > p.y) return vec3(0,0,0);\n p.y = min(p.y, raySphereIntersect(r0, r, rPlanet).x);\n float iStepSize = (p.y - p.x) / float(iSteps);\n\n // Initialize the primary ray time.\n float iTime = 0.0;\n\n // Initialize accumulators for Rayleigh and Mie scattering.\n vec3 totalRlh = vec3(0,0,0);\n vec3 totalMie = vec3(0,0,0);\n\n // Initialize optical depth accumulators for the primary ray.\n float iOdRlh = 0.0;\n float iOdMie = 0.0;\n\n // Calculate the Rayleigh and Mie phases.\n float mu = dot(r, pSun);\n float mumu = mu * mu;\n float gg = g * g;\n float pRlh = 3.0 / (16.0 * PI) * (1.0 + mumu);\n float pMie = 3.0 / (8.0 * PI) * ((1.0 - gg) * (mumu + 1.0)) / (pow(1.0 + gg - 2.0 * mu * g, 1.5) * (2.0 + gg));\n\n // Sample the primary ray.\n for (int i = 0; i < iSteps; i++) {\n\n // Calculate the primary ray sample position.\n vec3 iPos = r0 + r * (iTime + iStepSize * 0.5);\n // Calculate the height of the sample.\n float iHeight = length(iPos) - rPlanet;\n // Calculate the optical depth of the Rayleigh and Mie scattering for this step.\n float odStepRlh = exp(-iHeight / shRlh) * iStepSize;\n float odStepMie = exp(-iHeight / shMie) * iStepSize;\n // Accumulate optical depth.\n iOdRlh += odStepRlh;\n iOdMie += odStepMie;\n\n // Calculate the step size of the secondary ray.\n float jStepSize = raySphereIntersect(iPos, pSun, rAtmos).y / float(jSteps);\n\n // Initialize the secondary ray time.\n float jTime = 0.0;\n\n // Initialize optical depth accumulators for the secondary ray.\n float jOdRlh = 0.0;\n float jOdMie = 0.0;\n\n // Sample the secondary ray.\n for (int j = 0; j < jSteps; j++) {\n // Calculate the secondary ray sample position.\n vec3 jPos = iPos + pSun * (jTime + jStepSize * 0.5);\n // vec3 jPos = iPos + pSun * (jStepSize * (float(j) + 0.5));\n\n // Calculate the height of the sample.\n float jHeight = length(jPos) - rPlanet;\n // Accumulate the optical depth.\n jOdRlh += exp(-jHeight / shRlh) * jStepSize;\n jOdMie += exp(-jHeight / shMie) * jStepSize;\n\n // Increment the secondary ray time.\n jTime += jStepSize;\n }\n\n // Calculate attenuation.\n vec3 attn = exp(-(kMie * (iOdMie + jOdMie) + kRlh * (iOdRlh + jOdRlh)));\n\n // Accumulate scattering.\n totalRlh += odStepRlh * attn;\n totalMie += odStepMie * attn;\n\n // Increment the primary ray time.\n iTime += iStepSize;\n\n }\n // Calculate and return the final color.\n return iSun * (pRlh * kRlh * totalRlh + pMie * kMie * totalMie);\n}\n\n// #pragma glslify: getAtmosphereBruteForce = require(../../../engine/gl/glsl/atmosphere_scatter_brute_force.glsl);\n\nvoid main() {\n vec3 color = atmosphere2(\n normalize(pos),\n vec3(0, 6372e3, 0),\n normalize(sundir),\n 22.0,\n 6371e3,\n 6471e3,\n vec3(5.5e-6, 13.0e-6, 22.4e-6),\n 21e-6,\n 8e3,\n 1.2e3,\n 0.758\n );\n\n // vec3 color = getAtmosphereBruteForce(normalize(pos),normalize(sundir));\n gl_FragColor = vec4(color, 1);\n}\n\n// color = 1.0 - exp(-1.0 * color);"},1541:function(e,t){e.exports="precision highp float;\n#define GLSLIFY 1\n\nuniform vec3 sundir;\nvarying vec2 uv;\n\n#define PI 3.1415926535\n#define iSteps 16\n#define jSteps 8\n\nvec2 raySphereIntersect(vec3 r0, vec3 rd, float sr) {\n float a = dot(rd, rd);\n float b = 2.0 * dot(rd, r0);\n float c = dot(r0, r0) - (sr * sr);\n float d = (b * b) - 4.0 * a * c;\n if (d < 0.0) return vec2(1e5,-1e5);\n return vec2((-b - sqrt(d))/(2.0*a), (-b + sqrt(d))/(2.0*a));\n}\n\n// r - normalized ray direction\n// r0 - ray origin (eye)\n// pSun - position of the sun\n// intensity - intensity of the sun\n// rPlanet - radius of the planet in meters\n// rAtmos - radius of the atmosphere in meters\n// kRlh - Rayleigh scattering coefficient\n// kMie - Mie scattering coefficient\n// shRlh - Rayleigh scale height\n// shMie - Mie scale height\n// g - Mie preferred scattering direction\nvec3 atmosphere2(vec3 r, vec3 r0, vec3 pSun, float iSun, float rPlanet, float rAtmos, vec3 kRlh, float kMie, float shRlh, float shMie, float g) {\n pSun = normalize(pSun);\n r = normalize(r);\n\n vec2 p = raySphereIntersect(r0, r, rAtmos);\n if (p.x > p.y) {\n return vec3(0, 0, 0);\n }\n p.y = min(p.y, raySphereIntersect(r0, r, rPlanet).x);\n float iStepSize = (p.y - p.x) / float(iSteps);\n\n // Initialize accumulators for Rayleigh and Mie scattering.\n vec3 totalRlh = vec3(0, 0, 0);\n vec3 totalMie = vec3(0, 0, 0);\n\n // Initialize optical depth accumulators for the primary ray.\n // optical depth is the average atmospheric density across the ray from point Pa to point Pb multiplied by the length of the ray\n float iOdRlh = 0.0;\n float iOdMie = 0.0;\n\n // since pSun and r are normolized, mu is the cos(theta) of two vector,\n float mu = dot(r, pSun);\n float mumu = mu * mu;\n float gg = g * g;\n float pRlh = 3.0 / (16.0 * PI) * (1.0 + mumu);\n float pMie = 3.0 / (8.0 * PI) * ((1.0 - gg) * (mumu + 1.0)) / (pow(1.0 + gg - 2.0 * mu * g, 1.5) * (2.0 + gg));\n\n for (int i = 0; i < iSteps; i++) {\n vec3 iPos = r0 + r * (iStepSize * (float(i) + 0.5));\n float iHeight = length(iPos) - rPlanet;\n float odStepRlh = exp(-iHeight / shRlh) * iStepSize;\n float odStepMie = exp(-iHeight / shMie) * iStepSize;\n\n // \n iOdRlh += odStepRlh;\n iOdMie += odStepMie;\n\n float jStepSize = raySphereIntersect(iPos, pSun, rAtmos).y / float(jSteps);\n float jOdRlh = 0.0;\n float jOdMie = 0.0;\n for (int j = 0; j < jSteps; j++) {\n vec3 jPos = iPos + pSun * (jStepSize * (float(j) + 0.5));\n\n float jHeight = length(jPos) - rPlanet;\n jOdRlh += exp(-jHeight / shRlh) * jStepSize;\n jOdMie += exp(-jHeight / shMie) * jStepSize;\n }\n\n vec3 attn = exp(-(kMie * (iOdMie + jOdMie) + kRlh * (iOdRlh + jOdRlh)));\n totalRlh += odStepRlh * attn;\n totalMie += odStepMie * attn;\n }\n\n return iSun * (pRlh * kRlh * totalRlh + pMie * kMie * totalMie);\n}\n\nvec3 atmosphere(vec3 r, vec3 r0, vec3 pSun, float iSun, float rPlanet, float rAtmos, vec3 kRlh, float kMie, float shRlh, float shMie, float g) {\n // Normalize the sun and view directions.\n pSun = normalize(pSun);\n r = normalize(r);\n\n // Calculate the step size of the primary ray.\n vec2 p = raySphereIntersect(r0, r, rAtmos);\n if (p.x > p.y) return vec3(0,0,0);\n p.y = min(p.y, raySphereIntersect(r0, r, rPlanet).x);\n float iStepSize = (p.y - p.x) / float(iSteps);\n\n // Initialize the primary ray time.\n float iTime = 0.0;\n\n // Initialize accumulators for Rayleigh and Mie scattering.\n vec3 totalRlh = vec3(0,0,0);\n vec3 totalMie = vec3(0,0,0);\n\n // Initialize optical depth accumulators for the primary ray.\n float iOdRlh = 0.0;\n float iOdMie = 0.0;\n\n // Calculate the Rayleigh and Mie phases.\n float mu = dot(r, pSun);\n float mumu = mu * mu;\n float gg = g * g;\n float pRlh = 3.0 / (16.0 * PI) * (1.0 + mumu);\n float pMie = 3.0 / (8.0 * PI) * ((1.0 - gg) * (mumu + 1.0)) / (pow(1.0 + gg - 2.0 * mu * g, 1.5) * (2.0 + gg));\n\n // Sample the primary ray.\n for (int i = 0; i < iSteps; i++) {\n\n // Calculate the primary ray sample position.\n vec3 iPos = r0 + r * (iTime + iStepSize * 0.5);\n // Calculate the height of the sample.\n float iHeight = length(iPos) - rPlanet;\n // Calculate the optical depth of the Rayleigh and Mie scattering for this step.\n float odStepRlh = exp(-iHeight / shRlh) * iStepSize;\n float odStepMie = exp(-iHeight / shMie) * iStepSize;\n // Accumulate optical depth.\n iOdRlh += odStepRlh;\n iOdMie += odStepMie;\n\n // Calculate the step size of the secondary ray.\n float jStepSize = raySphereIntersect(iPos, pSun, rAtmos).y / float(jSteps);\n\n // Initialize the secondary ray time.\n float jTime = 0.0;\n\n // Initialize optical depth accumulators for the secondary ray.\n float jOdRlh = 0.0;\n float jOdMie = 0.0;\n\n // Sample the secondary ray.\n for (int j = 0; j < jSteps; j++) {\n // Calculate the secondary ray sample position.\n vec3 jPos = iPos + pSun * (jTime + jStepSize * 0.5);\n // vec3 jPos = iPos + pSun * (jStepSize * (float(j) + 0.5));\n\n // Calculate the height of the sample.\n float jHeight = length(jPos) - rPlanet;\n // Accumulate the optical depth.\n jOdRlh += exp(-jHeight / shRlh) * jStepSize;\n jOdMie += exp(-jHeight / shMie) * jStepSize;\n\n // Increment the secondary ray time.\n jTime += jStepSize;\n }\n\n // Calculate attenuation.\n vec3 attn = exp(-(kMie * (iOdMie + jOdMie) + kRlh * (iOdRlh + jOdRlh)));\n\n // Accumulate scattering.\n totalRlh += odStepRlh * attn;\n totalMie += odStepMie * attn;\n\n // Increment the primary ray time.\n iTime += iStepSize;\n\n }\n // Calculate and return the final color.\n return iSun * (pRlh * kRlh * totalRlh + pMie * kMie * totalMie);\n}\n\nvec3 paraboloidToNormal (mediump vec2 screen) {\n float K = 2. / (dot(screen, screen) + 1.);\n return vec3(K * screen.x, K - 1., K * screen.y);\n}\n\nvoid main() {\n vec2 newUV = vec2(fract(uv.x)*2.0 - 1., uv.y);\n vec3 r = normalize(paraboloidToNormal(newUV));\n r.y *= sign(uv.x);\n vec3 color = atmosphere2(\n r,\n vec3(0, 6372e3, 0),\n normalize(sundir),\n 22.0,\n 6371e3,\n 6471e3,\n vec3(5.5e-6, 13.0e-6, 22.4e-6),\n 21e-6,\n 8e3,\n 1.2e3,\n 0.758\n );\n gl_FragColor = vec4(color, 1);\n}"},1542:function(e,t){e.exports="precision highp float;\n#define GLSLIFY 1\n\nuniform sampler2D tRGB, tRMET, tRi, tIndex, t2Sphere, t3Sphere, tUniform2, tUniform1, source;\n\nuniform sampler2D tSky;\n\nuniform mat4 invpv;\nuniform vec3 eye, bounds, lightPosition, groundColor;\nuniform vec2 res, tOffset, invResRand;\nuniform float resStage, lightRadius, groundRoughness, groundMetalness, dofDist, dofMag, lightIntensity;\n\nconst float epsilon = 0.0001;\nconst int nBounces = 5;\n\nvec2 normalToParaboloid (vec3 n) {\n return n.xz * (0.5 / (1. + n.y)) + 0.5;\n}\n// 生成随机数的方法\nfloat randUniform1(inout vec2 randOffset) {\n float r = texture2D(tUniform1, randOffset + tOffset).r;\n randOffset += r;\n return r;\n}\n\nvec2 randUniform2(inout vec2 randOffset) {\n vec2 r = texture2D(tUniform2, randOffset + tOffset).ra;\n randOffset += r;\n return r;\n}\n\nvec3 rand2Sphere(inout vec2 randOffset) {\n vec3 r = texture2D(t2Sphere, randOffset + tOffset).xyz;\n randOffset += r.xy;\n return r;\n}\n\nvec3 rand3Sphere(inout vec2 randOffset) {\n vec3 r = texture2D(t3Sphere, randOffset + tOffset).xyz;\n randOffset += r.xy;\n return r;\n}\nbool inBounds(vec3 p) {\n return all(greaterThanEqual(p, vec3(0.0))) && all(lessThan(p, bounds));\n}\n\nbool rayAABB(vec3 origin, vec3 direction, vec3 bMin, vec3 bMax, out float t0) {\n vec3 invDir = 1.0 / direction;\n vec3 omin = (bMin - origin) * invDir;\n vec3 omax = (bMax - origin) * invDir;\n vec3 imax = max(omax, omin);\n vec3 imin = min(omax, omin);\n float t1 = min(imax.x, min(imax.y, imax.z));\n t0 = max(imin.x, max(imin.y, imin.z));\n t0 = max(t0, 0.0);\n return t1 > t0;\n}\n\nvec3 rayAABBNorm(vec3 p, vec3 v) {\n vec3 d = p - (v + 0.5);\n vec3 dabs = abs(d);\n if (dabs.x > dabs.y) {\n if (dabs.x > dabs.z) {\n return vec3(sign(d.x), 0.0, 0.0);\n } else {\n return vec3(0, 0, sign(d.z));\n }\n } else {\n if (dabs.y > dabs.z) {\n return vec3(0.0, sign(d.y), 0.0);\n } else {\n return vec3(0.0, 0.0, sign(d.z));\n }\n }\n}\n\nvec2 samplePoint(vec3 v) {\n float invResStage = 1.0 / resStage;\n float i = v.y * bounds.x * bounds.z + v.z * bounds.x + v.x;\n i = i * invResStage;\n float y = floor(i);\n float x = fract(i) * resStage;\n x = (x + 0.5) * invResStage;\n y = (y + 0.5) * invResStage;\n return vec2(x, y);\n}\n\nstruct VoxelData {\n vec3 xyz;\n vec3 rgb;\n vec2 index;\n float roughness;\n float metalness;\n float emission;\n float transparent;\n float ri;\n};\n\nVoxelData floorData(vec3 v) {\n return VoxelData(v, groundColor, vec2(1.0 / 255.0, 0.0), groundRoughness, groundMetalness, 0.0, 0.0, 1.0);\n}\n\nVoxelData airData(vec3 v) {\n return VoxelData(v, vec3(1.0), vec2(0.0), 0.0, 0.0, 0.0, 1.0, 1.0);\n}\n\nVoxelData getVoxelData(vec3 v) {\n VoxelData vd;\n vd.xyz = v;\n if (v.y == -1.0) {\n return floorData(v);\n }\n if (!inBounds(v)) {\n return airData(v);\n }\n vec2 s = samplePoint(v);\n vd.index = texture2D(tIndex, s).ra;\n if (vd.index == vec2(0.0)) {\n return airData(v);\n }\n vd.rgb = texture2D(tRGB, vd.index).rgb;\n vec4 rmet = texture2D(tRMET, vd.index);\n vd.roughness = rmet.r;\n vd.metalness = rmet.g;\n vd.emission = rmet.b * 4.0;\n vd.transparent = rmet.a;\n vd.ri = texture2D(tRi, vd.index).r * 2.0;\n return vd;\n}\n\nVoxelData intersectFloor(vec3 r0, vec3 r) {\n vec3 v = floor(r0 + r * -r0.y / r.y);\n v.y = -1.0;\n return floorData(v);\n}\n\nfloat raySphereIntersect(vec3 r0, vec3 rd, vec3 s0, float sr) {\n float a = dot(rd, rd);\n vec3 s0_r0 = r0 - s0;\n float b = 2.0 * dot(rd, s0_r0);\n float c = dot(s0_r0, s0_r0) - (sr * sr);\n if (b*b - 4.0*a*c < 0.0) {\n return -1.0;\n }\n return (-b - sqrt((b*b) - 4.0*a*c))/(2.0*a);\n}\n\nvec3 skyColor(vec3 r0, vec3 r, float sunScale) {\n if (r.y < 0.0) {\n return vec3(0.0);\n }\n vec2 envUV = normalToParaboloid(vec3(r.x, abs(r.y), r.z));\n envUV.x = 0.5 * (envUV.x + step(0., r.y));\n vec3 sky = texture2D(tSky, envUV).rgb;\n\n if (raySphereIntersect(r0, r, lightPosition, lightRadius) > 0.0) {\n sky += vec3(lightIntensity) * sunScale;\n }\n return sky;\n}\n\nbool intersect(vec3 r0, vec3 r, inout VoxelData vd) {\n float tBounds = 0.0;\n vec3 v = vec3(0.0);\n if (!inBounds(r0)) {\n // 类似 rayMarching, 先让 ray 前进到 bound 范围内,这样 ray 起点的坐标就可以直接用来判断 voxel 的值\n if (!rayAABB(r0, r, vec3(0.0), bounds, tBounds)) {\n if (r.y >= 0.0) {\n return false;\n }\n vd = intersectFloor(r0, r);\n return true;\n }\n r0 = r0 + r * tBounds + r * epsilon;\n }\n v = floor(r0);\n vec3 stp = sign(r);\n vec3 tDelta = 1.0 / abs(r);\n vec3 tMax = step(0.0, r) * (1.0 - fract(r0)) + (1.0 - step(0.0, r)) * fract(r0);\n tMax = tMax / abs(r);\n for (int i = 0; i < 8192; i++) {\n if (!inBounds(v)) {\n if (r.y >= 0.0) {\n return false;\n }\n vd = intersectFloor(r0, r);\n return true;\n }\n vec2 lastIndex = vd.index;\n vd = getVoxelData(v);\n // 如果不是空气\n if (lastIndex != vd.index) {\n return true;\n }\n // 还没有击中 voxel,继续前进\n vec3 s = vec3(\n step(tMax.x, tMax.y) * step(tMax.x, tMax.z),\n step(tMax.y, tMax.x) * step(tMax.y, tMax.z),\n step(tMax.z, tMax.x) * step(tMax.z, tMax.y)\n );\n v += s * stp;\n tMax += s * tDelta;\n }\n return false;\n}\n\nvoid main() {\n vec4 src = texture2D(source, gl_FragCoord.xy / res);\n vec2 randOffset = vec2(0.0);\n\n vec2 jitter = randUniform2(randOffset) - 0.5;\n vec4 ndc = vec4(\n // 如果没 jitter 的话,画面会有锯齿感(可以理解为画面进行了平滑处理)\n 2.0 * (gl_FragCoord.xy + jitter) / res - 1.0,\n 2.0 * gl_FragCoord.z - 1.0,\n 1.0\n );\n\n // 其实很类似 rayMarching 的第一步\n vec4 clip = invpv * ndc;\n vec3 p3d = clip.xyz / clip.w;\n\n vec3 ray = normalize(p3d - eye);\n vec3 r0 = eye;\n\n float ddof = dofDist * length(bounds) + length(0.5 * bounds - eye) - length(bounds) * 0.5;\n vec3 tdof = r0 + ddof * ray;\n r0 += rand2Sphere(randOffset) * dofMag;\n ray = normalize(tdof - r0);\n\n vec3 mask = vec3(1.0);\n vec3 accm = vec3(0.0);\n\n // floor 函数其实就将世界 体素化 了\n VoxelData vd = airData(floor(r0));\n\n bool reflected = false;\n for (int b = 0; b < nBounces; b++) {\n bool refracted = false;\n float lastRi = vd.ri;\n if (intersect(r0, ray, vd)) {\n if (vd.emission > 0.0) {\n accm += mask * vd.emission * vd.rgb;\n break;\n }\n float tVoxel = 0.0;\n rayAABB(r0, ray, vd.xyz, vd.xyz + 1.0, tVoxel);\n vec3 r1 = r0 + tVoxel * ray;\n vec3 n = rayAABBNorm(r1, vd.xyz);\n vec3 m = normalize(n + rand3Sphere(randOffset) * vd.roughness);\n vec3 diffuse = normalize(m + rand2Sphere(randOffset));\n vec3 ref = reflect(ray, m);\n if (randUniform1(randOffset) <= vd.metalness) {\n //ray = ref;\n ray = ref;\n reflected = true;\n mask *= vd.rgb;\n } else {\n // nonmetallic\n const float F0 = 0.0;\n float F = F0 + (1.0 - F0) * pow(1.0 - dot(-ray, n), 5.0);\n if (randUniform1(randOffset) <= F) {\n // reflect\n ray = ref;\n reflected = true;\n } else {\n // diffuse\n mask *= vd.rgb;\n if (randUniform1(randOffset) <= vd.transparent) {\n // attempt refraction\n ray = refract(ray, m, lastRi / vd.ri);\n if (ray != vec3(0.0)) {\n // refracted\n ray = normalize(ray);\n refracted = true;\n reflected = false;\n } else {\n // total internal refraction, use reflection.\n ray = ref;\n refracted = false;\n reflected = true;\n }\n } else {\n // diffuse reflection\n ray = diffuse;\n refracted = false;\n }\n }\n }\n if (!refracted && dot(ray, n) < 0.0) {\n accm = vec3(0.0);\n break;\n }\n r0 = r1 + ray * epsilon;\n vd = getVoxelData(floor(r0));\n if (ray == diffuse) {\n // Perform next event estimation when a diffuse bounce occurs.\n vec3 pLight = lightPosition + rand2Sphere(randOffset) * lightRadius;\n vec3 rLight = normalize(pLight - r0);\n VoxelData _vd;\n if (!intersect(r0, rLight, _vd)) {\n accm += mask * skyColor(r0, rLight, 0.5) * clamp(dot(rLight, m), 0.0, 1.0);\n }\n }\n } else {\n accm += mask * skyColor(r0, ray, b == 0 ? 1.0 : 0.0).rgb;\n break;\n }\n }\n gl_FragColor = vec4(accm, 1) + src;\n}"},1543:function(e,t,i){"use strict";i.d(t,"a",(function(){return l}));var s=i(1357),o=i(113),n=i(248);const r=i(1544);class a{constructor(e,t,i,s){this.para=[],this.destTree=e,this.selectTree=t,this.para=i,this.paletteRecord=s}}class l{constructor(e){this.stackPrev=[],this.stackNext=[],this.VERef=e}hasPrevHistory(){return this.stackPrev.length>1}hasNextHistory(){return this.stackNext.length>0}emptyHistory(){this.stackPrev=[],this.stackNext=[]}getPrevHistory(){if(this.hasPrevHistory()){let e=this.stackPrev[this.stackPrev.length-1];return this.stackPrev.pop(),this.stackNext.push(e),e=this.stackPrev[this.stackPrev.length-1],void 0!==e.paletteRecord&&(this.VERef.paletteManager.updateColorValue(e.paletteRecord.cidx,e.paletteRecord.value),1===e.paletteRecord.step&&this.stackPrev.length&&(e=this.stackPrev[this.stackPrev.length-1],this.stackPrev.pop(),this.stackNext.push(e))),this.historyToVoxelView(e)}}getNextHistory(){if(this.hasNextHistory()){let e=this.stackNext[this.stackNext.length-1];return this.stackNext.pop(),this.stackPrev.push(e),void 0!==e.paletteRecord&&(1===e.paletteRecord.step&&this.stackNext.length&&(e=this.stackNext[this.stackNext.length-1],this.stackNext.pop(),this.stackPrev.push(e)),void 0!==e.paletteRecord&&this.VERef.paletteManager.updateColorValue(e.paletteRecord.cidx,e.paletteRecord.value)),this.historyToVoxelView(e)}}saveHistory(e,t){const i=this.encodeBoxes(e[0]),s=this.encodeBoxes(e[1]),n=[e[0].shape[0],e[0].shape[1],e[0].shape[2],e[0].offset];if(0==this.stackPrev.length){let e=r(o.d),l=r(o.d);for(let t=0;t>>0,D=0,V=0,B=0,A=0,L=0,z=0,H=0;const U=d*v*C;for(;A0&&(n=s(o.key,o.value)))return n}if(a>0&&o.right)return d(e,t,i,s,o.right)}function p(e,t){this.tree=e,this._stack=t}Object.defineProperty(l,"keys",{get:function(){var e=[];return this.forEach((function(t,i){e.push(t)})),e}}),Object.defineProperty(l,"values",{get:function(){var e=[];return this.forEach((function(t,i){e.push(i)})),e}}),Object.defineProperty(l,"length",{get:function(){return this.root?this.root._count:0}}),l.insert=function(e,t){for(var i=this._compare,o=this.root,l=[],h=[];o;){var c=i(e,o.key);l.push(o),h.push(c),o=c<=0?o.left:o.right}l.push(new s(0,e,t,null,null,1));for(var d=l.length-2;d>=0;--d){o=l[d];h[d]<=0?l[d]=new s(o._color,o.key,o.value,l[d+1],o.right,o._count+1):l[d]=new s(o._color,o.key,o.value,o.left,l[d+1],o._count+1)}for(d=l.length-1;d>1;--d){var p=l[d-1];o=l[d];if(1===p._color||1===o._color)break;var u=l[d-2];if(u.left===p)if(p.left===o){if(!(f=u.right)||0!==f._color){if(u._color=0,u.left=p.right,p._color=1,p.right=u,l[d-2]=p,l[d-1]=o,r(u),r(p),d>=3)(m=l[d-3]).left===u?m.left=p:m.right=p;break}p._color=1,u.right=n(1,f),u._color=0,d-=1}else{if(!(f=u.right)||0!==f._color){if(p.right=o.left,u._color=0,u.left=o.right,o._color=1,o.left=p,o.right=u,l[d-2]=o,l[d-1]=p,r(u),r(p),r(o),d>=3)(m=l[d-3]).left===u?m.left=o:m.right=o;break}p._color=1,u.right=n(1,f),u._color=0,d-=1}else if(p.right===o){if(!(f=u.left)||0!==f._color){if(u._color=0,u.right=p.left,p._color=1,p.left=u,l[d-2]=p,l[d-1]=o,r(u),r(p),d>=3)(m=l[d-3]).right===u?m.right=p:m.left=p;break}p._color=1,u.left=n(1,f),u._color=0,d-=1}else{var f;if(!(f=u.left)||0!==f._color){var m;if(p.left=o.right,u._color=0,u.right=o.left,o._color=1,o.right=p,o.left=u,l[d-2]=o,l[d-1]=p,r(u),r(p),r(o),d>=3)(m=l[d-3]).right===u?m.right=o:m.left=o;break}p._color=1,u.left=n(1,f),u._color=0,d-=1}}return l[0]._color=1,new a(i,l[0])},l.forEach=function(e,t,i){if(this.root)switch(arguments.length){case 1:return h(e,this.root);case 2:return c(t,this._compare,e,this.root);case 3:if(this._compare(t,i)>=0)return;return d(t,i,this._compare,e,this.root)}},Object.defineProperty(l,"begin",{get:function(){for(var e=[],t=this.root;t;)e.push(t),t=t.left;return new p(this,e)}}),Object.defineProperty(l,"end",{get:function(){for(var e=[],t=this.root;t;)e.push(t),t=t.right;return new p(this,e)}}),l.at=function(e){if(e<0)return new p(this,[]);for(var t=this.root,i=[];;){if(i.push(t),t.left){if(e=t.right._count)break;t=t.right}return new p(this,[])},l.ge=function(e){for(var t=this._compare,i=this.root,s=[],o=0;i;){var n=t(e,i.key);s.push(i),n<=0&&(o=s.length),i=n<=0?i.left:i.right}return s.length=o,new p(this,s)},l.gt=function(e){for(var t=this._compare,i=this.root,s=[],o=0;i;){var n=t(e,i.key);s.push(i),n<0&&(o=s.length),i=n<0?i.left:i.right}return s.length=o,new p(this,s)},l.lt=function(e){for(var t=this._compare,i=this.root,s=[],o=0;i;){var n=t(e,i.key);s.push(i),n>0&&(o=s.length),i=n<=0?i.left:i.right}return s.length=o,new p(this,s)},l.le=function(e){for(var t=this._compare,i=this.root,s=[],o=0;i;){var n=t(e,i.key);s.push(i),n>=0&&(o=s.length),i=n<0?i.left:i.right}return s.length=o,new p(this,s)},l.find=function(e){for(var t=this._compare,i=this.root,s=[];i;){var o=t(e,i.key);if(s.push(i),0===o)return new p(this,s);i=o<=0?i.left:i.right}return new p(this,[])},l.remove=function(e){var t=this.find(e);return t?t.remove():this},l.get=function(e){for(var t=this._compare,i=this.root;i;){var s=t(e,i.key);if(0===s)return i.value;i=s<=0?i.left:i.right}};var u=p.prototype;function f(e,t){e.key=t.key,e.value=t.value,e.left=t.left,e.right=t.right,e._color=t._color,e._count=t._count}function m(e,t){return et?1:0}Object.defineProperty(u,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(u,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),u.clone=function(){return new p(this.tree,this._stack.slice())},u.remove=function(){var e=this._stack;if(0===e.length)return this.tree;var t=new Array(e.length),i=e[e.length-1];t[t.length-1]=new s(i._color,i.key,i.value,i.left,i.right,i._count);for(var l=e.length-2;l>=0;--l){(i=e[l]).left===e[l+1]?t[l]=new s(i._color,i.key,i.value,t[l+1],i.right,i._count):t[l]=new s(i._color,i.key,i.value,i.left,t[l+1],i._count)}if((i=t[t.length-1]).left&&i.right){var h=t.length;for(i=i.left;i.right;)t.push(i),i=i.right;var c=t[h-1];t.push(new s(i._color,c.key,c.value,i.left,i.right,i._count)),t[h-1].key=i.key,t[h-1].value=i.value;for(l=t.length-2;l>=h;--l)i=t[l],t[l]=new s(i._color,i.key,i.value,i.left,t[l+1],i._count);t[h-1].left=t[h]}if(0===(i=t[t.length-1])._color){var d=t[t.length-2];d.left===i?d.left=null:d.right===i&&(d.right=null),t.pop();for(l=0;l=0;--l){if(t=e[l],0===l)return void(t._color=1);if((i=e[l-1]).left===t){if((s=i.right).right&&0===s.right._color){if(a=(s=i.right=o(s)).right=o(s.right),i.right=s.left,s.left=i,s.right=a,s._color=i._color,t._color=1,i._color=1,a._color=1,r(i),r(s),l>1)(h=e[l-2]).left===i?h.left=s:h.right=s;return void(e[l-1]=s)}if(s.left&&0===s.left._color){if(a=(s=i.right=o(s)).left=o(s.left),i.right=a.left,s.left=a.right,a.left=i,a.right=s,a._color=i._color,i._color=1,s._color=1,t._color=1,r(i),r(s),r(a),l>1)(h=e[l-2]).left===i?h.left=a:h.right=a;return void(e[l-1]=a)}if(1===s._color){if(0===i._color)return i._color=1,void(i.right=n(0,s));i.right=n(0,s);continue}s=o(s),i.right=s.left,s.left=i,s._color=i._color,i._color=0,r(i),r(s),l>1&&((h=e[l-2]).left===i?h.left=s:h.right=s),e[l-1]=s,e[l]=i,l+11)(h=e[l-2]).right===i?h.right=s:h.left=s;return void(e[l-1]=s)}if(s.right&&0===s.right._color){if(a=(s=i.left=o(s)).right=o(s.right),i.left=a.right,s.right=a.left,a.right=i,a.left=s,a._color=i._color,i._color=1,s._color=1,t._color=1,r(i),r(s),r(a),l>1)(h=e[l-2]).right===i?h.right=a:h.left=a;return void(e[l-1]=a)}if(1===s._color){if(0===i._color)return i._color=1,void(i.left=n(0,s));i.left=n(0,s);continue}var h;s=o(s),i.left=s.right,s.right=i,s._color=i._color,i._color=0,r(i),r(s),l>1&&((h=e[l-2]).right===i?h.right=s:h.left=s),e[l-1]=s,e[l]=i,l+10)return this._stack[this._stack.length-1].key},enumerable:!0}),Object.defineProperty(u,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0}),Object.defineProperty(u,"index",{get:function(){var e=0,t=this._stack;if(0===t.length){var i=this.tree.root;return i?i._count:0}t[t.length-1].left&&(e=t[t.length-1].left._count);for(var s=t.length-2;s>=0;--s)t[s+1]===t[s].right&&(++e,t[s].left&&(e+=t[s].left._count));return e},enumerable:!0}),u.next=function(){var e=this._stack;if(0!==e.length){var t=e[e.length-1];if(t.right)for(t=t.right;t;)e.push(t),t=t.left;else for(e.pop();e.length>0&&e[e.length-1].right===t;)t=e[e.length-1],e.pop()}},Object.defineProperty(u,"hasNext",{get:function(){var e=this._stack;if(0===e.length)return!1;if(e[e.length-1].right)return!0;for(var t=e.length-1;t>0;--t)if(e[t-1].left===e[t])return!0;return!1}}),u.update=function(e){var t=this._stack;if(0===t.length)throw new Error("Can't update empty node!");var i=new Array(t.length),o=t[t.length-1];i[i.length-1]=new s(o._color,o.key,e,o.left,o.right,o._count);for(var n=t.length-2;n>=0;--n)(o=t[n]).left===t[n+1]?i[n]=new s(o._color,o.key,o.value,i[n+1],o.right,o._count):i[n]=new s(o._color,o.key,o.value,o.left,i[n+1],o._count);return new a(this.tree._compare,i[0])},u.prev=function(){var e=this._stack;if(0!==e.length){var t=e[e.length-1];if(t.left)for(t=t.left;t;)e.push(t),t=t.right;else for(e.pop();e.length>0&&e[e.length-1].left===t;)t=e[e.length-1],e.pop()}},Object.defineProperty(u,"hasPrev",{get:function(){var e=this._stack;if(0===e.length)return!1;if(e[e.length-1].left)return!0;for(var t=e.length-1;t>0;--t)if(e[t-1].right===e[t])return!0;return!1}})},1603:function(e,t,i){"use strict";i.d(t,"a",(function(){return We}));var s=i(1),o=i(552);const n="coloItem",r=i(1521);class a extends s.Component{constructor(e){super(e),this.tapedTwice=!1,this.colorItemRef=s.createRef(),this._onColorItemUpdate=()=>{this.forceUpdate()},this._onContextMenu=e=>{if(e.target){const t=this.props.idx;this.props.VERef.paletteManager.setCurentColor(t),this.props.VERef.emit(o.a.SHOWCOLORPICKER,{idx:t,hexColor:this.props.VERef.paletteManager.getHexColorById(this.props.idx),x:e.target.getBoundingClientRect().left,y:e.target.getBoundingClientRect().top})}e.stopPropagation(),e.preventDefault()},this._tapHandler=e=>{if(!this.tapedTwice)return this.tapedTwice=!0,void setTimeout(()=>{this.tapedTwice=!1},300);this._onContextMenu(e),e.preventDefault()},this.colorIdx=this.props.idx,this.state={showColorPicker:!1}}componentDidMount(){const e=this.colorItemRef.current;e&&(e.addEventListener("contextmenu",this._onContextMenu,{passive:!1}),e.addEventListener("touchstart",this._tapHandler,{passive:!1})),this.props.VERef.on(this.colorIdx+"-UPDATE",this._onColorItemUpdate)}componentWillUnmount(){const e=this.colorItemRef.current;e&&(e.removeEventListener("contextmenu",this._onContextMenu),e.removeEventListener("touchstart",this._tapHandler)),this.props.VERef.removeListener(this.colorIdx+"-UPDATE",this._onColorItemUpdate)}render(){const e=this.props.VERef.paletteManager.getCurrentColorIndex(),t=this.colorIdx,i=this.props.VERef.paletteManager.getHexColorById(t);return s.createElement("div",{"data-idx":t,ref:this.colorItemRef,className:r.colorPickButton+" "+(e==t?r.picked:""),"data-color":"#"+i,style:{borderColor:e==t?"#fff":"rgba(0, 0, 0, 0)"},onMouseOver:()=>this.props.VERef.emit(o.a.ONINFOTEXTCHANGE,n),onClick:e=>{this.props.VERef.paletteManager.setCurentColor(t),this.props.VERef.emit(o.a.CLOSECOLORPICKER)}},s.createElement("i",{className:r.color,"data-idx":t,style:{background:"#"+i}}))}}function l(e){e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,t,i,s){return t+t+i+i+s+s}));const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:null}function h(e,t,i){e/=360,e*=6,t/=100,i/=100;const s=Math.floor(e),o=e-s,n=i*(1-t),r=i*(1-o*t),a=i*(1-(1-o)*t),l=s%6,h=[i,r,n,n,a,i][l],c=[a,i,i,r,n,n][l],d=[n,n,a,i,i,r][l];return[Math.round(255*h),Math.round(255*c),Math.round(255*d)]}function c(e){var t=Number(e).toString(16);return t.length<2&&(t="0"+t),t}function d(e,t,i){return"#"+c(Math.round(e))+c(Math.round(t))+c(Math.round(i))}var p=Object.defineProperty,u=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,g=(e,t,i)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;const v=i(1522);class b extends s.Component{constructor(e){super(e),this.saturateWidth=0,this.saturateHeight=0,this._onSaturatePanelDown=e=>{if(e.target){document.body.addEventListener("mousemove",this._onSaturatePanelMove,{passive:!1}),document.body.addEventListener("mouseup",this._onSaturatePanelUp),document.body.addEventListener("touchmove",this._onSaturatePanelMove,{passive:!1}),document.body.addEventListener("touchend",this._onSaturatePanelUp);const t=this.calculateChange(e,this._saturateRef.current);this.props.onChange(t.RGB)}},this._onSaturatePanelMove=e=>{e.preventDefault();const t=this.calculateChange(e,this._saturateRef.current);this.props.onChange(t.RGB),e.stopPropagation()},this._onSaturatePanelUp=e=>{this.props.onChangeEnd(),document.body.removeEventListener("mousemove",this._onSaturatePanelMove),document.body.removeEventListener("mouseup",this._onSaturatePanelUp),document.body.removeEventListener("touchmove",this._onSaturatePanelMove),document.body.removeEventListener("touchend",this._onSaturatePanelUp)},this._onSaturatSlideDown=()=>{document.body.addEventListener("mousemove",this._onSaturatSlideMove,{passive:!1}),document.body.addEventListener("mouseup",this._onSaturatSlideUp),document.body.addEventListener("touchmove",this._onSaturatSlideMove,{passive:!1}),document.body.addEventListener("touchend",this._onSaturatSlideUp)},this._onSaturatSlideMove=e=>{if(e.preventDefault(),this._slideRef.current){const t=this._slideRef.current.parentElement;if(!t)return;const i="number"==typeof e.pageX?e.pageX:e.touches[0].pageX;"number"==typeof e.pageY?e.pageY:e.touches[0].pageY;let s=i-(t.getBoundingClientRect().left+window.pageXOffset);s<0?s=0:s>t.getBoundingClientRect().width&&(s=t.getBoundingClientRect().width);const o=s/t.getBoundingClientRect().width*360,n=[o,this.state.hsv[1],this.state.hsv[2]],r=[o,this.state.hsl[1],this.state.hsl[2]],a=h(n[0],n[1],n[2]),l=d(a[0],a[1],a[2]);this.setState({hsv:n,hsl:r,RGB:a,hex:l,displayHex:l,displayRGB:[a[0]+"",a[1]+"",a[2]+""]}),this.props.onChange(a)}},this._onSaturatSlideUp=()=>{this.props.onChangeEnd(),document.body.removeEventListener("mousemove",this._onSaturatSlideMove),document.body.removeEventListener("mouseup",this._onSaturatSlideUp),document.body.removeEventListener("touchmove",this._onSaturatSlideMove),document.body.removeEventListener("touvhend",this._onSaturatSlideUp)},this.state=((e,t)=>{for(var i in t||(t={}))f.call(t,i)&&g(e,i,t[i]);if(u)for(var i of u(t))m.call(t,i)&&g(e,i,t[i]);return e})({inputFormat:1},this.calcState(this.props.hexColor)),this._saturateRef=s.createRef(),this._slideRef=s.createRef(),this._pointerRef=s.createRef()}componentDidMount(){if(this._saturateRef.current){const e=this._saturateRef.current.getBoundingClientRect();this.saturateWidth=e.width,this.saturateHeight=e.height}}componentWillUnmount(){}newInput(e){const t=this.calcState(e);this.setState(t),this.props.onChange(t.RGB)}calcState(e,t){const i=l(e)||[0,0,0],s=function(e,t,i){e/=255,t/=255,i/=255;const s=Math.max(e,t,i),o=Math.min(e,t,i);let n,r=0;const a=(s+o)/2;if(s==o)r=n=0;else{const l=s-o;switch(n=a>.5?l/(2-s-o):l/(s+o),s){case e:r=(t-i)/l+(ti&&(r=i),a<0?a=0:a>s&&(a=s);const l=100*r/i,c=-100*a/s+100,p=[Math.round(this.state.hsv[0]),Math.round(l),Math.round(c)],u=h(p[0],p[1],p[2]),f=function(e,t,i){let s=(2-(t/=100))*(i/=100),o=t*i;return o/=s<=1?s:2-s,s/=2,[e,o,s]}(p[0],p[1],p[2]),m=d(u[0],u[1],u[2]),g={hex:m,oldHue:f[0]<=0?this.state.oldHue:f[0],RGB:u,hsl:f,hsv:p,displayHex:m,displayRGB:[u[0]+"",u[1]+"",u[2]+""]};return this.setState(g),g}onHexInputChange(e){this.setState({displayHex:e.target.value})}validateHexValue(){const e=l(this.state.displayHex);if(null!=e){const t=d(e[0],e[1],e[2]);this.newInput(t),this.props.onChangeEnd()}else this.setState({displayHex:this.state.hex})}onRGBInputChange(e,t){const i=this.state.displayRGB;i[t]=e.target.value,this.setState({displayRGB:i})}validateRGBValue(){let e=Number(this.state.displayRGB[0]),t=Number(this.state.displayRGB[1]),i=Number(this.state.displayRGB[2]);("NaN"==e.toString()||"number"!=typeof e||e<0||e>255)&&(e=this.state.RGB[0]),("NaN"==t.toString()||"number"!=typeof t||t<0||t>255)&&(t=this.state.RGB[1]),("NaN"==i.toString()||"number"!=typeof i||i<0||i>255)&&(i=this.state.RGB[2]);const s=d(Math.round(e),Math.round(t),Math.round(i));this.newInput(s),this.props.onChangeEnd()}render(){return s.createElement("div",{className:[v.customPicker,v.dark,this.props.isTouchDevice?v.touchDevice:""].join(" "),style:this.props.style},s.createElement("div",{className:v.saturationWraper},s.createElement("div",{ref:this._saturateRef,onMouseDown:this._onSaturatePanelDown,onTouchStart:this._onSaturatePanelDown,className:v.saturationBackground,style:{background:"hsl("+(this.state.hsl[0]<=0?this.state.oldHue:this.state.hsl[0])+",100%, 50%)"}},s.createElement("div",{className:v.saturationWhite},s.createElement("div",{className:v.saturationBlack}),s.createElement("div",{ref:this._pointerRef,className:v.pointer,style:{transform:`translate(${this.state.hsv[1]/100*this.saturateWidth}px, ${(1-this.state.hsv[2]/100)*this.saturateHeight}px)`}},s.createElement("div",{className:v.pointerDot}))))),s.createElement("div",{className:v.toggleWraper},s.createElement("div",{className:v.flexboxFix},s.createElement("div",{style:{width:"32px"}},s.createElement("div",{style:{width:"16px",height:"16px",borderRadius:"8px",position:"relative",overflow:"hidden"}},s.createElement("div",{className:v.colorDot,style:{background:this.state.hex}}))),s.createElement("div",{style:{flex:"1",marginTop:"2px"}},s.createElement("div",{style:{height:"10px",position:"relative"}},s.createElement("div",{style:{position:"absolute",top:"0px",right:"0px",bottom:"0px",left:"0px"}},s.createElement("div",{className:v.hueHorizontal,style:{padding:"0px 2px",position:"relative",height:"100%"}},s.createElement("div",{ref:this._slideRef,onMouseDown:this._onSaturatSlideDown,onTouchStart:this._onSaturatSlideDown,style:{position:"absolute",left:this.state.hsl[0]/360*100+"%"}},s.createElement("div",{className:v.saturateDotBtn}))))))),s.createElement("div",{className:v.flexboxFix,style:{paddingTop:"16px",display:"flex"}},s.createElement("div",{className:v.flexboxFix,style:{flex:"1 1 0%",display:"flex",marginLeft:"-6px"}},s.createElement("div",{style:{paddingLeft:"6px",width:"100%"}},1==this.state.inputFormat?s.createElement("div",{style:{position:"relative"}},s.createElement("input",{className:v.hexInput+" "+v.inputDark,value:this.state.displayHex,onBlur:()=>{this.validateHexValue()},onKeyPress:e=>{13==e.charCode&&this.validateHexValue()},onChange:e=>{this.onHexInputChange(e)}}),s.createElement("span",{className:v.inputSpan},"hex")):s.createElement("div",{className:v.inputRGBWrap},s.createElement("div",{className:v.rgbItem},s.createElement("div",{style:{position:"relative"}},s.createElement("input",{className:v.rgbItemInput+" "+v.inputDark,value:this.state.displayRGB[0],onBlur:()=>{this.validateRGBValue()},onKeyPress:e=>{13==e.charCode&&this.validateRGBValue()},onChange:e=>{this.onRGBInputChange(e,0)}}),s.createElement("span",{className:v.rgbItemTag},"r"))),s.createElement("div",{className:v.rgbItem},s.createElement("div",{style:{position:"relative"}},s.createElement("input",{className:v.rgbItemInput+" "+v.inputDark,value:this.state.displayRGB[1],onBlur:()=>{this.validateRGBValue()},onKeyPress:e=>{13==e.charCode&&this.validateRGBValue()},onChange:e=>{this.onRGBInputChange(e,1)}}),s.createElement("span",{className:v.rgbItemTag},"g"))),s.createElement("div",{className:v.rgbItem},s.createElement("div",{style:{position:"relative"}},s.createElement("input",{className:v.rgbItemInput+" "+v.inputDark,value:this.state.displayRGB[2],onBlur:()=>{this.validateRGBValue()},onKeyPress:e=>{13==e.charCode&&this.validateRGBValue()},onChange:e=>{this.onRGBInputChange(e,2)}}),s.createElement("span",{className:v.rgbItemTag},"b")))))),s.createElement("div",{style:{width:"32px",textAlign:"right",position:"relative"}},s.createElement("div",{style:{marginRight:"-4px",marginTop:"12px",cursor:"pointer",position:"relative"}},s.createElement("svg",{className:v.clickSwitch,onClick:()=>{this.setState({inputFormat:1-this.state.inputFormat})},viewBox:"0 0 24 24"},s.createElement("path",{fill:"#333",d:"M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z"}),s.createElement("path",{fill:"#333",d:"M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15Z"})))))))}}var x=i(1357);const y=i(1402);class _ extends s.Component{constructor(e){super(e),this._slideActive=!1,this._slideElementPosX=0,this._slideElementWidth=0,this.state={value:this.props.initValue,displayValue:this.props.initValue},this._slideMouseUp=this._slideMouseUp.bind(this),this._onSlide=this._onSlide.bind(this)}_getOffset(e){const t=e.getBoundingClientRect();return{left:t.left+window.scrollX,top:t.top+window.scrollY}}_slideMouseUp(e){this._slideActive=!1}componentDidMount(){window.addEventListener("mousemove",this._onSlide),window.addEventListener("mouseup",this._slideMouseUp)}componentWillUnmount(){window.removeEventListener("mousemove",this._onSlide),window.addEventListener("mouseup",this._slideMouseUp)}componentWillReceiveProps(e){this.setState({value:e.initValue})}_onSlide(e){if(!this._slideActive||!e.target)return;let t=Math.max(0,e.clientX-this._slideElementPosX)/this._slideElementWidth*(this.props.maxValue-this.props.minValue)+this.props.minValue;t=Math.min(Math.max(this.props.minValue,Number(t.toFixed(this.props.precision))),this.props.maxValue),t!==this.state.value&&(this.setState({value:t,displayValue:t}),this.props.onChange(t))}_checkValue(){if("NaN"!=Number(this.state.displayValue).toString()){let e=Number(Number(this.state.displayValue).toFixed(this.props.precision));e=Math.min(this.props.maxValue,Math.max(this.props.minValue,e)),this.setState({value:e,displayValue:e}),this.props.onChange(e)}}_onInputChange(e){this.setState({displayValue:e.target.value})}render(){const e=this.state.value,t=this.props.maxValue,i=this.props.minValue;return s.createElement("div",{className:y.tagInputSlider},s.createElement("span",{className:y.propertyName},this.props.tag),s.createElement("div",{className:y.propertyField},s.createElement("div",null,s.createElement("input",{type:"text",value:this.state.displayValue,onChange:e=>{this._onInputChange(e)},onKeyPress:e=>{13==e.charCode&&this._checkValue()},onBlur:e=>{this._checkValue()},onKeyDown:e=>{if(38===e.keyCode){const s=Math.min(t,Math.max(i,Number((this.state.value+1/Math.pow(10,this.props.precision)).toFixed(this.props.precision))));this.setState({value:s,displayValue:s}),this.props.onChange(s),e.preventDefault()}else if(40===e.keyCode){const s=Math.min(t,Math.max(i,Number((this.state.value-1/Math.pow(10,this.props.precision)).toFixed(this.props.precision))));this.setState({value:s,displayValue:s}),this.props.onChange(s),e.preventDefault()}}})),s.createElement("div",{className:y.slider,onMouseDown:e=>{this._slideActive=!0,this._slideElementWidth=e.target.offsetWidth,this._slideElementPosX=Object(x.r)(e.target).x,this._onSlide(e),e.stopPropagation()}},s.createElement("div",{className:y.sliderFg,style:{pointerEvents:"none",width:(e-i)/(t-i)*100+"%"}}))))}}var E=i(2);const M=i(1523);class S extends s.Component{constructor(e){super(e),this.handleChange=this.handleChange.bind(this);const t=this.props.VERef.paletteManager,i=t.getCurrentColorIndex(),s=t.getPBRPropertiesById(i);this._metalness=s[0],this._smoothness=s[1],this._emissive=s[2];const o=t.getTRPropertiesById(i);this._transparent=o[0],this._refract=o[1];const n=this;this._pbrPannelUpdate=function(){n.forceUpdate()}}componentDidMount(){this.props.VERef.on(o.a.SELECTCOLOR,this._pbrPannelUpdate)}handleChange(){const e=this.props.VERef.paletteManager,t=e.getCurrentColorIndex(),i=[this._metalness,this._smoothness,this._emissive];e.updatePBRProperties(t,i),e.updateTRProperties(t,[this._transparent,this._refract])}componentWillUnmount(){this.props.VERef.removeListener(o.a.SELECTCOLOR,this._pbrPannelUpdate)}render(){const e=this.props.VERef.paletteManager,t=e.getPBRPropertiesById(this.props.VERef.paletteManager.getCurrentColorIndex()),i=e.getTRPropertiesById(this.props.VERef.paletteManager.getCurrentColorIndex());return s.createElement("div",{className:M.MSE},s.createElement("div",null,s.createElement(_,{tag:Object(E.e)("metalness"),minValue:0,maxValue:255,initValue:t[0],precision:0,onChange:e=>{this._metalness=e,this.handleChange()}}),s.createElement(_,{tag:Object(E.e)("roughness"),minValue:0,maxValue:255,initValue:255-t[1],precision:0,onChange:e=>{this._smoothness=255-e,this.handleChange()}}),s.createElement(_,{tag:Object(E.e)("emissive"),minValue:0,maxValue:255,initValue:t[2],precision:0,onChange:e=>{this._emissive=e,this.handleChange()}}),s.createElement("div",{style:{height:"30px",lineHeight:"30px",width:"100%",color:"#FF9800",fontSize:"15px"}},":) Only work in voxel editor"),s.createElement(_,{tag:Object(E.e)("transparent"),minValue:0,maxValue:255,initValue:i[0],precision:0,onChange:e=>{this._transparent=e,this.handleChange()}}),s.createElement(_,{tag:Object(E.e)("refract"),minValue:0,maxValue:255,initValue:i[1],precision:0,onChange:e=>{this._refract=e,this.handleChange()}})))}}const w=i(1524);class C extends s.Component{constructor(e){super(e),this.pickerInitColor="#000",this.pickerPos={x:0,y:0},this.targetIdx=0,this._onCloseColorPicker=()=>{this.setState({showColorPicker:!1})},this._onShowColorPicker=e=>{if(window.innerWidth>=500&&window.innerHeight>=530){const{idx:t,hexColor:i,x:s,y:o}=e;if(t===this.targetIdx&&this.state.showColorPicker)return void this._onCloseColorPicker();this.targetIdx=t,this.pickerInitColor="#"+i,this.pickerPos.x=s-227,window.innerHeight-o<227?this.pickerPos.y=o-215:this.pickerPos.y=o,this.setState({showColorPicker:!0}),this._pickerRef.current&&this._pickerRef.current.newInput(this.pickerInitColor)}},this._pickerRef=s.createRef(),this.state={showColorPicker:!1,currentTab:0}}componentDidMount(){this.props.VERef.on(o.a.SHOWCOLORPICKER,this._onShowColorPicker),this.props.VERef.on(o.a.CLOSECOLORPICKER,this._onCloseColorPicker)}componentWillUnmount(){this.props.VERef.removeListener(o.a.SHOWCOLORPICKER,this._onShowColorPicker),this.props.VERef.removeListener(o.a.CLOSECOLORPICKER,this._onCloseColorPicker)}render(){const e=this.props.VERef.paletteManager;return this.state.showColorPicker?s.createElement("div",{style:{position:"fixed",zIndex:3,top:this.pickerPos.y,left:this.pickerPos.x,paddingTop:this.props.isTouchDevice?"0":"24px"}},s.createElement("div",null,this.props.isTouchDevice?null:s.createElement("div",{className:w.tabBtnGroup},s.createElement("div",{className:[w.tabBtn,0===this.state.currentTab?w.current:""].join(" "),onClick:()=>{this.setState({currentTab:0})}},"RGB"),s.createElement("div",{className:[w.tabBtn,1===this.state.currentTab?w.current:""].join(" "),onClick:()=>{this.setState({currentTab:1})}},"PBR")),0===this.state.currentTab||this.props.isTouchDevice?s.createElement(b,{ref:this._pickerRef,isTouchDevice:this.props.isTouchDevice,onChange:t=>{e.updateColorValue(this.targetIdx,t.map(e=>e/255))},onChangeEnd:()=>{if(this.pickerInitColor!=="#"+e.getHexColorById(this.targetIdx)){const t=Object(x.s)(this.pickerInitColor).map(e=>e/255),i=e.getRgbColorById(this.targetIdx);this.props.VERef.saveHistory({cidx:this.targetIdx,value:t,step:1}),this.props.VERef.saveHistory({cidx:this.targetIdx,value:i,step:2})}},hexColor:this.pickerInitColor}):s.createElement("div",{style:{width:"225px",background:"rgba(0,0,0,0.7)",height:"225px",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.35), 0 0 5px #263f99, 0 0 10px #000000"}},s.createElement(S,{VERef:this.props.VERef})))):""}}var P=i(593),k=i.n(P);const R=new Array;for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t=1&t?-306674912^t>>1&2147483647:t>>1&2147483647;R[e]=t}function I(e,t,i){let s=-1;for(var o=4;o>8&16777215;O(e,t+i-4,-1^s)}function O(e,t,i){return e[t++]=i>>24&255,e[t++]=i>>16&255,e[t++]=i>>8&255,e[t++]=255&i,t}function j(e,t,i){return e[t++]=255&i,e[t++]=i>>8&255,t}function T(e,t,i){for(let s=0,o=i.length;s>8&255,e[t++]=255&i}(n,this.idat_offs+8,a);for(let e=0;(e<<16)-1=0?s:255)<<8|e)<<8|t)<<8|i;if(void 0===this.palette[o]){if(this.pindex==this.depth)return 0;const n=this.plte_offs+8+3*this.pindex;this.buffer[n+0]=e,this.buffer[n+1]=t,this.buffer[n+2]=i,this.buffer[this.trns_offs+8+this.pindex]=s,this.palette[o]=this.pindex++}return this.palette[o]}getBase64(){return this.deflate(),k.a.fromByteArray(new Uint8Array(this.buffer.buffer))}deflate(){const{width:e,height:t,buffer:i}=this;let s=1,o=0,n=5552;const r=this.idat_offs+8+2+5;for(let a=0;as.createElement(a,{key:t+1,veState:this.props.veState,idx:t+1,VERef:this.props.VERef,colorString:e}))),s.createElement(C,{VERef:this.props.VERef,isTouchDevice:this.props.isTouchDevice}),s.createElement("div",{className:D.colorPanelTools},s.createElement("div",{className:D.colorpaletteChoicer},s.createElement("div",{className:D.colorpaletteItem+" "+D.item_1+" "+(0==t?D.selected:""),onClick:()=>{e.paletteManager.choiceColorTable(0),this.forceUpdate()}},"1"),s.createElement("div",{className:D.colorpaletteItem+" "+D.item_2+" "+(1==t?D.selected:""),onClick:()=>{e.paletteManager.choiceColorTable(1),this.forceUpdate()}},"2"),s.createElement("div",{className:D.colorpaletteItem+" "+D.item_3+" "+(2==t?D.selected:""),onClick:()=>{e.paletteManager.choiceColorTable(2),this.forceUpdate()}},"3"),s.createElement("div",{className:D.colorpaletteItem+" "+D.item_4+" "+(3==t?D.selected:""),onClick:()=>{e.paletteManager.choiceColorTable(3),this.forceUpdate()}},"4"))))}}var B=i(52);const A=JSON.parse('{"1":"QmQt3tp5QkdhYqE7jNDzQCWFTRHhNoiTqeUTA2GC9y7ZLV.png","2":"QmbwT3TQMkZgqMU2GY88DmnKL4enMfvYbs2cdXVZYJNX3N.png","3":"QmUkV2BFB7KjCs1X5RoPfJ5BMZ1h89V5YtMUxwuX3kw3jS.png","bucket":"QmTQPJx64heizdMQ5S3nSwh7cAQJiNfegVamirQPnUgEAH.png","builder":"QmVzKgjpqSvueUJDfPezKPqyQZGeut1nrihauyasnwRatJ.svg","cone":"QmaZFVMnxS97UA1saJLYFqWvrjp7Mdoip111u5wAvbabcU.jpg","ellipsoid":"QmPCLLyYXNMByVRLnjwv5EEkrwGfJpRcDPyyuU8YcMqueY.jpg","favorite":"QmPv5xqGLTjJGbFff42ZGFMDRZi1xpAix6UqvccKKfQ2D7.ico","flower":"QmddxgmKGB9HpEwnZjLKQZULnu48pWase3HrxJDiaPdyVp.jpg","heart":"QmRrPvVdpDA2KEkPnTbeYcbaTGiY92qaee2P1TwK2Qoc2H.jpg","hexprisma":"QmQ3EfW8dZyUqxGyHbg89j7NFC95PXgDuE8RP6RTpxDK99.jpg","modeling":"Qmb4TaUNPcvAr8oDdMe5gVE2ddnJ7HYimb4thWFqvNqJin.svg","polishing":"QmWQqFx9PYU8TzCeKdAhYpCLH9VXgPBR8oEvq9Y7pRVbgb.svg","pyramid":"QmfLv5dDw9G91emJVwJegZha9vFRwJZedVoLESbffE6zzv.jpg","roundbox":"QmXMaX1mtFjCxKwxAzyYLb7dymx7JZBSoCSqB8PZWrria2.jpg","skull":"QmVTpUAFcNaF5px5cNJysWZY8ebPvGSCp9icXkH3oSzuTY.jpg","sphere":"QmVQYFAC3o73icHGdCV3vAMCAVjTmxj5cBzFanCuR2kJn2.jpg","sprite":"QmRu799ppwW2pBZn5chvVKS7iB1ju8ujLXueqn21PrqYBj.svg","torus":"QmbcqUi7bjXp9AsNm17hsemDNdVLMrxrr7TziiPWJgXvVi.jpg","torus88":"QmbTyyXakZezALqh6FRag3yA9dpHSK82dHjd3gLeV9rjhU.jpg","triprism":"QmXqJWXmKSC5iiKF2GS9kh99siKya3KQAxKo5fQi2bHMho.jpg","voxel":{"VoxelIcon":"QmcbTnEhnZqWVqDm6SsiP2nAEqzSrpGGWa2J8hW9PJqt9y.svg","alpha":"QmdAsyRbsBKr8pXMpftuFj9CuQWffDxFNAkA71rstooyzn.png","hue":"QmbRy6BL8AkifGoykU66K5C1QHHZ97gy7kutoPYSyXwHJd.png","saturation":"QmXa6mDLhvt2ij8i3rMtYTa3zS9gaCnEfZTBfSRcjfhbJr.png"}}'),L=i(1526);class z extends s.Component{constructor(e){super(e),this.state={sphere_param:{r:9},cone_param:{c:[30,10],displayValue:"30 10"},pyramid_param:{c:[20,10],displayValue:"20 10"},torus_param:{c:[15,3],displayValue:"15 3"},torus88_param:{c:[15,3],displayValue:"15 3"},ellipsoid_param:{r:[6,8,10],displayValue:"6 8 10"},roundbox_param:{b:[4,7,3],b_displayValue:"4 7 3",r:3},hexprism_param:{h:[10,1],displayValue:"10 1"},triprism_param:{h:[10,1],displayValue:"10 1"},skull_param:{scale:12},heart_param:{scale:5},flower_param:{scale:8}}}onSphereInputChange(e){const t=this.props.veState.basicConfig.workspaceSize,i=Math.min(t[0],t[1],t[2]),s=e.target.value;if("NaN"!=Number(s).toString()){const e=Number(s);if(e>i/2||e<0||e%1>0)return;this.setState({sphere_param:{r:Number(s)}})}}onSkullInputChange(e){const t=e.target.value;if("NaN"!=Number(t).toString()){const e=Number(t);if(e<0||e%1>0)return;this.setState({skull_param:{scale:Number(t)}})}}onHeartInputChange(e){const t=e.target.value;if("NaN"!=Number(t).toString()){if(Number(t)<0)return;this.setState({heart_param:{scale:Number(t)}})}}onFlowerInputChange(e){const t=e.target.value;if("NaN"!=Number(t).toString()){if(Number(t)<0)return;this.setState({flower_param:{scale:Number(t)}})}}setConeParamState(e,t){e=void 0===e?this.state.cone_param.displayValue:e,t=void 0===t?this.state.cone_param.c:t,this.setState({cone_param:{displayValue:e,c:t}})}setEllipsoidParamState(e,t){e=void 0===e?this.state.ellipsoid_param.displayValue:e,t=void 0===t?this.state.ellipsoid_param.r:t,this.setState({ellipsoid_param:{displayValue:e,r:t}})}setPyramidParamState(e,t){e=void 0===e?this.state.pyramid_param.displayValue:e,t=void 0===t?this.state.pyramid_param.c:t,this.setState({pyramid_param:{displayValue:e,c:t}})}setTorusParamState(e,t){e=void 0===e?this.state.torus_param.displayValue:e,t=void 0===t?this.state.torus_param.c:t,this.setState({torus_param:{displayValue:e,c:t}})}setTorus88ParamState(e,t){e=void 0===e?this.state.torus88_param.displayValue:e,t=void 0===t?this.state.torus88_param.c:t,this.setState({torus88_param:{displayValue:e,c:t}})}setRoundboxParamState(e,t,i){e=void 0===e?this.state.roundbox_param.b_displayValue:e,t=void 0===t?this.state.roundbox_param.b:t,i=void 0===i?this.state.roundbox_param.r:i,this.setState({roundbox_param:{b_displayValue:e,b:t,r:i}})}setHexPrismState(e,t){e=void 0===e?this.state.hexprism_param.displayValue:e,t=void 0===t?this.state.hexprism_param.h:t,this.setState({hexprism_param:{displayValue:e,h:t}})}setTriPrismState(e,t){e=void 0===e?this.state.triprism_param.displayValue:e,t=void 0===t?this.state.triprism_param.h:t,this.setState({triprism_param:{displayValue:e,h:t}})}onEllipsoidInputChange(e,t){if(0==t)return this.setEllipsoidParamState(e.target.value,this.state.ellipsoid_param.r),!1;if(1==t){const e=this.state.ellipsoid_param.displayValue.split(" ").map(e=>Number(e)).splice(0,3);if(3!=e.length)return this.setEllipsoidParamState(this.state.ellipsoid_param.r.join(" "),this.state.ellipsoid_param.r),!1;for(let t=0;t<3;t++)if("number"!=typeof e[t]||"NaN"==e[t].toString())return this.setEllipsoidParamState(this.state.ellipsoid_param.r.join(" "),this.state.ellipsoid_param.r),!1;return this.setEllipsoidParamState(e.join(" "),e),e}return!1}onConeInputChange(e,t){if(0==t)return this.setConeParamState(e.target.value,this.state.cone_param.c),!1;if(1==t){const e=this.state.cone_param.displayValue.split(" ").map(e=>Number(e)).splice(0,2);if(2!=e.length)return this.setConeParamState(this.state.cone_param.c.join(" "),this.state.cone_param.c),!1;for(let t=0;t<2;t++)if("number"!=typeof e[t]||"NaN"==e[t].toString())return this.setConeParamState(this.state.cone_param.c.join(" "),this.state.cone_param.c),!1;return this.setConeParamState(e.join(" "),e),e}return!1}onRoundbox_size_InputChange(e,t){if(0==t)return this.setRoundboxParamState(e.target.value,void 0,void 0),!1;if(1==t){const e=this.state.roundbox_param.b_displayValue.split(" ").map(e=>Number(e)).splice(0,3);if(3!=e.length)return this.setRoundboxParamState(this.state.roundbox_param.b.join(" "),this.state.roundbox_param.b,void 0),!1;for(let t=0;t<3;t++)if("number"!=typeof e[t]||"NaN"==e[t].toString())return this.setRoundboxParamState(this.state.roundbox_param.b.join(" "),this.state.roundbox_param.b,void 0),!1;return this.setRoundboxParamState(e.join(" "),e,void 0),e}return!1}onRoundbox_r_InputChange(e){const t=e.target.value;if("NaN"!=Number(t).toString()){const e=Number(t);if(e<0||e%1>0)return;this.setRoundboxParamState(void 0,void 0,e)}}onPyramidInputChange(e,t){if(0==t)return this.setPyramidParamState(e.target.value,this.state.pyramid_param.c),!1;if(1==t){const e=this.state.pyramid_param.displayValue.split(" ").map(e=>Number(e)).splice(0,2);if(2!=e.length)return this.setPyramidParamState(this.state.pyramid_param.c.join(" "),this.state.pyramid_param.c),!1;for(let t=0;t<2;t++)if("number"!=typeof e[t]||"NaN"==e[t].toString())return this.setPyramidParamState(this.state.pyramid_param.c.join(" "),this.state.pyramid_param.c),!1;return this.setPyramidParamState(e.join(" "),e),e}return!1}onTorusInputChange(e,t){if(0==t)return this.setTorusParamState(e.target.value,this.state.torus_param.c),!1;if(1==t){const e=this.state.torus_param.displayValue.split(" ").map(e=>Number(e)).splice(0,2);if(2!=e.length)return this.setTorusParamState(this.state.torus_param.c.join(" "),this.state.torus_param.c),!1;for(let t=0;t<2;t++)if("number"!=typeof e[t]||"NaN"==e[t].toString())return this.setTorusParamState(this.state.torus_param.c.join(" "),this.state.torus_param.c),!1;return this.setTorusParamState(e.join(" "),e),e}return!1}onTorus88InputChange(e,t){if(0==t)return this.setTorus88ParamState(e.target.value,this.state.torus88_param.c),!1;if(1==t){const e=this.state.torus88_param.displayValue.split(" ").map(e=>Number(e)).splice(0,2);if(2!=e.length)return this.setTorus88ParamState(this.state.torus88_param.c.join(" "),this.state.torus88_param.c),!1;for(let t=0;t<2;t++)if("number"!=typeof e[t]||"NaN"==e[t].toString())return this.setTorus88ParamState(this.state.torus88_param.c.join(" "),this.state.torus88_param.c),!1;return this.setTorus88ParamState(e.join(" "),e),e}return!1}onHexPrismInputChange(e,t){if(0==t)return this.setHexPrismState(e.target.value,this.state.hexprism_param.h),!1;if(1==t){const e=this.state.hexprism_param.displayValue.split(" ").map(e=>Number(e)).splice(0,2);if(2!=e.length)return this.setHexPrismState(this.state.hexprism_param.h.join(" "),this.state.hexprism_param.h),!1;for(let t=0;t<2;t++)if("number"!=typeof e[t]||"NaN"==e[t].toString())return this.setHexPrismState(this.state.hexprism_param.h.join(" "),this.state.hexprism_param.h),!1;return this.setHexPrismState(e.join(" "),e),e}return!1}onTriPrismInputChange(e,t){if(0==t)return this.setTriPrismState(e.target.value,this.state.triprism_param.h),!1;if(1==t){const e=this.state.triprism_param.displayValue.split(" ").map(e=>Number(e)).splice(0,2);if(2!=e.length)return this.setTriPrismState(this.state.triprism_param.h.join(" "),this.state.triprism_param.h),!1;for(let t=0;t<2;t++)if("number"!=typeof e[t]||"NaN"==e[t].toString())return this.setTriPrismState(this.state.triprism_param.h.join(" "),this.state.triprism_param.h),!1;return this.setTriPrismState(e.join(" "),e),e}return!1}sphereShape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.sphere)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem},s.createElement("div",{className:L.paramTitle},"Radius"),s.createElement("input",{type:"text",value:this.state.sphere_param.r,onChange:e=>{this.onSphereInputChange(e)}}))),s.createElement("div",{className:L.addBtn,onClick:()=>{this.props.VERef.veController.addSphere(this.state.sphere_param.r)}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}coneShape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.cone)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem},s.createElement("div",{className:L.paramTitle},"Angle - Tall"),s.createElement("input",{type:"text",value:this.state.cone_param.displayValue,onKeyPress:e=>{13==e.charCode&&this.onConeInputChange(e,1)},onBlur:e=>{this.onConeInputChange(e,1)},onChange:e=>{this.onConeInputChange(e,0)}}))),s.createElement("div",{className:L.addBtn,onClick:e=>{const t=this.onConeInputChange(e,1);t&&this.props.VERef.veController.addCone(t)}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}pyramidShape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.pyramid)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem},s.createElement("div",{className:L.paramTitle},"Angle - Radius"),s.createElement("input",{type:"text",value:this.state.pyramid_param.displayValue,onKeyPress:e=>{13==e.charCode&&this.onPyramidInputChange(e,1)},onBlur:e=>{this.onPyramidInputChange(e,1)},onChange:e=>{this.onPyramidInputChange(e,0)}}))),s.createElement("div",{className:L.addBtn,onClick:e=>{const t=this.onPyramidInputChange(e,1);t&&this.props.VERef.veController.addPyramid(t)}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}torusShape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.torus)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem},s.createElement("div",{className:L.paramTitle},"Radius - radius"),s.createElement("input",{type:"text",value:this.state.torus_param.displayValue,onKeyPress:e=>{13==e.charCode&&this.onTorusInputChange(e,1)},onBlur:e=>{this.onTorusInputChange(e,1)},onChange:e=>{this.onTorusInputChange(e,0)}}))),s.createElement("div",{className:L.addBtn,onClick:e=>{const t=this.onTorusInputChange(e,1);t&&this.props.VERef.veController.addTorus(t)}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}torus88Shape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.torus88)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem},s.createElement("div",{className:L.paramTitle},"Radius - radius"),s.createElement("input",{type:"text",value:this.state.torus88_param.displayValue,onKeyPress:e=>{13==e.charCode&&this.onTorus88InputChange(e,1)},onBlur:e=>{this.onTorus88InputChange(e,1)},onChange:e=>{this.onTorus88InputChange(e,0)}}))),s.createElement("div",{className:L.addBtn,onClick:e=>{const t=this.onTorus88InputChange(e,1);t&&this.props.VERef.veController.addTorus88(t)}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}ellipsoidShape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.ellipsoid)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem},s.createElement("div",{className:L.paramTitle},"Radius - radius"),s.createElement("input",{type:"text",value:this.state.ellipsoid_param.displayValue,onKeyPress:e=>{13==e.charCode&&this.onEllipsoidInputChange(e,1)},onBlur:e=>{this.onEllipsoidInputChange(e,1)},onChange:e=>{this.onEllipsoidInputChange(e,0)}}))),s.createElement("div",{className:L.addBtn,onClick:e=>{const t=this.onEllipsoidInputChange(e,1);t&&this.props.VERef.veController.addEllipsoid(t)}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}roundboxShape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.roundbox)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem,style:{width:"60%"}},s.createElement("div",{className:L.paramTitle},"Size"),s.createElement("input",{type:"text",value:this.state.roundbox_param.b_displayValue,onKeyPress:e=>{13==e.charCode&&this.onRoundbox_size_InputChange(e,1)},onBlur:e=>{this.onRoundbox_size_InputChange(e,1)},onChange:e=>{this.onRoundbox_size_InputChange(e,0)}})),s.createElement("div",{className:L.paramItem,style:{width:"39%",marginLeft:"1%"}},s.createElement("div",{className:L.paramTitle},"radius"),s.createElement("input",{type:"text",value:this.state.roundbox_param.r,onChange:e=>{this.onRoundbox_r_InputChange(e)}}))),s.createElement("div",{className:L.addBtn,onClick:e=>{const t=this.onRoundbox_size_InputChange(e,1);t&&this.props.VERef.veController.addRoundbox(t,this.state.roundbox_param.r)}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}hexPrismShape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.hexprisma)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem},s.createElement("div",{className:L.paramTitle},"Radius - Length"),s.createElement("input",{type:"text",value:this.state.hexprism_param.displayValue,onKeyPress:e=>{13==e.charCode&&this.onHexPrismInputChange(e,1)},onBlur:e=>{this.onHexPrismInputChange(e,1)},onChange:e=>{this.onHexPrismInputChange(e,0)}}))),s.createElement("div",{className:L.addBtn,onClick:e=>{const t=this.onHexPrismInputChange(e,1);t&&this.props.VERef.veController.addHexPrism(t)}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}triPrismShape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.triprism)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem},s.createElement("div",{className:L.paramTitle},"Radius - Length"),s.createElement("input",{type:"text",value:this.state.triprism_param.displayValue,onKeyPress:e=>{13==e.charCode&&this.onTriPrismInputChange(e,1)},onBlur:e=>{this.onTriPrismInputChange(e,1)},onChange:e=>{this.onTriPrismInputChange(e,0)}}))),s.createElement("div",{className:L.addBtn,onClick:e=>{const t=this.onTriPrismInputChange(e,1);t&&this.props.VERef.veController.addTriPrism(t)}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}skullShape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.skull)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem},s.createElement("div",{className:L.paramTitle},"Scale"),s.createElement("input",{type:"text",value:this.state.skull_param.scale,onChange:e=>{this.onSkullInputChange(e)}}))),s.createElement("div",{className:L.addBtn,onClick:()=>{const e=this.state.skull_param.scale;this.props.VERef.veController.addSkull([e,e,e])}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}heartShape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.heart)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem},s.createElement("div",{className:L.paramTitle},"Scale"),s.createElement("input",{type:"text",value:this.state.heart_param.scale,onChange:e=>{this.onHeartInputChange(e)}}))),s.createElement("div",{className:L.addBtn,onClick:()=>{const e=this.state.heart_param.scale;this.props.VERef.veController.addHeart([e,e,e])}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}flowerShape(){return s.createElement("div",{className:L.geometryShapeItem},s.createElement("div",{className:L.shapeIcon,style:{background:`url(${Object(B.a)(A.flower)})`,backgroundSize:"40px 40px"}}),s.createElement("div",{className:L.shapeParams},s.createElement("div",{className:L.paramItem},s.createElement("div",{className:L.paramTitle},"Scale"),s.createElement("input",{type:"text",value:this.state.flower_param.scale,onChange:e=>{this.onFlowerInputChange(e)}}))),s.createElement("div",{className:L.addBtn,onClick:()=>{const e=this.state.flower_param.scale;this.props.VERef.veController.addFlower([e,e,e])}},s.createElement("div",{className:L.addBtnStick_1}),s.createElement("div",{className:L.addBtnStick_2})))}render(){return s.createElement("div",{className:L.geometryShapesPanel},s.createElement("div",{className:L.geometryShapesList},this.sphereShape(),this.coneShape(),this.pyramidShape(),this.torusShape(),this.ellipsoidShape(),this.roundboxShape(),this.hexPrismShape(),this.triPrismShape(),this.torus88Shape(),this.skullShape(),this.heartShape(),this.flowerShape()))}}const H=i(1527);class U extends s.Component{constructor(e){super(e),this.state={currentPanel:0,miniPanel:!1}}renderMiniColorPalette(){const e=this.props.VERef.paletteManager.getCurrentColorTable().getHexColors();return e.shift(),s.createElement("div",{className:H.rightPanelQuickTool,style:{filter:this.props.blurOut?"blur(6px)":"initial"}},s.createElement("div",{className:H.colorPanelWrapper},e.map((e,t)=>s.createElement(a,{key:t+1,veState:this.props.veState,idx:t+1,VERef:this.props.VERef,colorString:e}))))}render(){const e=this.state.currentPanel;return s.createElement("div",{className:[H.rightPanel,this.props.importingMesh?H.hide:"",this.state.miniPanel?H.mini:"",this.props.isTouchDevice?H.touchDevice:""].join(" "),style:{filter:this.props.blurOut?"blur(6px)":"initial"}},s.createElement("div",{className:H.rightPanelHeader,onClick:()=>this.setState({miniPanel:!this.state.miniPanel})},s.createElement("div",{className:H.minimizeBtn})),s.createElement("div",{className:H.rightPanelWrap},s.createElement("div",{className:H.tabs},s.createElement("div",{className:[H.tab,0===e?H.current:""].join(" "),onClick:()=>{this.setState({currentPanel:0})}},"Colors"),s.createElement("div",{className:[H.tab,1===e?H.current:""].join(" "),onClick:()=>{this.setState({currentPanel:1})}},"Models")),s.createElement("div",{className:H.rightPanelInnerWrap},0===this.state.currentPanel?s.createElement(V,{VERef:this.props.VERef,veState:this.props.veState,isTouchDevice:this.props.isTouchDevice}):s.createElement(z,{VERef:this.props.VERef,veState:this.props.veState}))),this.state.miniPanel?this.renderMiniColorPalette():null)}}i(1528);var F=(e=>(e[e.EditingMode=0]="EditingMode",e[e.colorSelectOptions=1]="colorSelectOptions",e))(F||{});s.Component;const G=i(1529);class W extends s.Component{constructor(e){super(e),this.dragableElement=s.createRef(),this.resizing=()=>{const e=this.dragableElement.current;e&&(window.innerHeight-e.offsetTop<=87&&(e.style.top=window.innerHeight-87+"px"),e.offsetTop<=48&&(e.style.top="48px"),e.offsetLeft<=0&&(e.style.left="0px"),e.offsetLeft+e.offsetWidth>=window.innerWidth&&(e.style.left=window.innerWidth-e.offsetWidth+"px"))},this.pos1=0,this.pos2=0,this.pos3=0,this.pos4=0,this.dragPointerDown=e=>{e.preventDefault(),e.stopPropagation(),this.pos3=e.clientX,this.pos4=e.clientY,document.body.addEventListener("mouseup",this.closeDragElement,{passive:!1}),document.body.addEventListener("mousemove",this.elementDrag,{passive:!1})},this.closeDragElement=e=>{const t=e||window.event;t&&(t.preventDefault(),t.stopPropagation()),document.body.removeEventListener("mouseup",this.closeDragElement),document.body.removeEventListener("mousemove",this.elementDrag)},this.elementDrag=e=>{if(!this.dragableElement.current)return;const t=e||window.event;if(t){t.preventDefault(),t.stopPropagation(),this.pos1=this.pos3-t.clientX,this.pos2=this.pos4-t.clientY,this.pos3=t.clientX,this.pos4=t.clientY;const e=this.dragableElement.current;this.dragableElement.current.style.top=this.dragableElement.current.offsetTop-this.pos2+"px",this.dragableElement.current.style.left=this.dragableElement.current.offsetLeft-this.pos1+"px",window.innerHeight-e.offsetTop<=87&&(e.style.top=window.innerHeight-87+"px"),e.offsetTop<=48&&(e.style.top="48px"),e.offsetLeft<=0&&(e.style.left="0px"),e.offsetLeft+e.offsetWidth>=window.innerWidth&&(e.style.left=window.innerWidth-e.offsetWidth+"px"),t.stopPropagation()}}}componentDidMount(){window.addEventListener("resize",this.resizing)}componentWillUnmount(){window.removeEventListener("resize",this.resizing)}renderTouchUI(){return s.createElement("div",{className:[G.toolBar,G.touchDevice,this.props.importingMesh?G.hide:""].join(" "),style:{filter:this.props.blurOut?"blur(6px)":"none"}},s.createElement("div",{className:[G.btn,G.paste].join(" "),onClick:()=>{this.props.VERef.veController.pasetSelection(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.merge].join(" "),onClick:()=>{this.props.VERef.veController.deSelect(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.delete].join(" "),onClick:()=>{this.props.VERef.veController.deleteSelectBlocks(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.subtract].join(" "),onClick:()=>{this.props.VERef.veController.subtractSelection(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.intersect].join(" "),onClick:()=>{this.props.VERef.veController.intersectSelection(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.prev].join(" "),onClick:()=>{this.props.VERef.prevStep()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.next].join(" "),onClick:()=>{this.props.VERef.nextStep()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.empty].join(" "),onClick:()=>{this.props.VERef.veController.clearAllModels(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon})))}renderDesktopUI(){return s.createElement("div",{className:[G.toolBar,this.props.importingMesh?G.hide:""].join(" "),ref:this.dragableElement,id:"ve-dragable",onMouseDown:this.dragPointerDown,style:{filter:this.props.blurOut?"blur(6px)":"none",top:"51px",left:window.innerWidth/2-198+"px"}},s.createElement("div",{className:[G.toolSetA,G.toolSet].join(" ")},s.createElement("div",{className:[G.btn,G.paste].join(" "),onClick:()=>{this.props.VERef.veController.pasetSelection(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.merge].join(" "),onClick:()=>{this.props.VERef.veController.deSelect(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.delete].join(" "),onClick:()=>{this.props.VERef.veController.deleteSelectBlocks(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon}))),s.createElement("div",{className:[G.toolSetB,G.toolSet].join(" ")},s.createElement("div",{className:[G.btn,G.subtract].join(" "),onClick:()=>{this.props.VERef.veController.subtractSelection(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.intersect].join(" "),onClick:()=>{this.props.VERef.veController.intersectSelection(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon}))),s.createElement("div",{className:[G.toolSetC,G.toolSet].join(" ")},s.createElement("div",{className:[G.btn,G.prev].join(" "),onClick:()=>{this.props.VERef.prevStep()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.next].join(" "),onClick:()=>{this.props.VERef.nextStep()}},s.createElement("div",{className:G.btnIcon})),s.createElement("div",{className:[G.btn,G.empty].join(" "),onClick:()=>{this.props.VERef.veController.clearAllModels(),this.props.VERef.saveHistory()}},s.createElement("div",{className:G.btnIcon}))))}render(){return this.props.isTouchDevice?this.renderTouchUI():this.renderDesktopUI()}}var Y=i(1367);const X=i(1530);var q=(e=>(e[e.warn=0]="warn",e[e.success=1]="success",e[e.error=2]="error",e[e.message=3]="message",e))(q||{});class Z{constructor(e){this.genre=null!=e.genre&&e.genre>=0&&e.genre<=4?e.genre:3,this.life=null!=e.life&&e.life>.5&&e.life<=10?e.life:1.212,this.text=null!=e.text?e.text:q[this.genre]+" : ",this.id=e.id}}class K extends s.Component{constructor(e){super(e),this.state={show:!1}}componentDidMount(){setTimeout(()=>{this.setState({show:!0})},200)}render(){return s.createElement("div",{className:[X.notify,X[q[this.props.genre]],X[this.state.show]].join(" ")},s.createElement("div",{className:[X.text].join(" ")},this.props.text))}}class Q extends s.Component{constructor(e){super(e),this.notifys=[],this.count=0,this.state={updateCount:0}}componentDidMount(){}onRemoveItem(e){for(let t=0;ts.createElement(K,{key:e.id,genre:e.genre,text:e.text,life:e.life,id:e.id})))}}var J=i(19);const $=i(1371);class ee extends s.Component{constructor(e){super(e),this.state={solid:!1,isSaving:!1,modelname:this.props.veState.projectInfo.dispaly_name},this.notifyContainer=s.createRef()}componentDidMount(){setTimeout(()=>{this.setState({solid:!0})},20)}saveToGameEditor(){new Blob([this.props.veState.projectInfo.dispaly_name]).size>this.props.VERef.maxNameLen?J.a.warning(Object(E.e)("fileNameLenLimit")):(this.setState({isSaving:!0}),this.props.VERef.saveToGameEditor(()=>{this.setState({isSaving:!1}),this._close()}))}saveModel(){new Blob([this.props.veState.projectInfo.dispaly_name]).size>this.props.VERef.maxNameLen?J.a.warning(Object(E.e)("fileNameLenLimit")):(this.setState({isSaving:!0}),this.props.VERef.saveToServer(this.state.modelname,()=>{this.setState({isSaving:!1}),this._close()},()=>{window.alert(Object(E.e)("unauthorized"))}))}_close(){setTimeout(()=>{this.setState({solid:!1})},0),setTimeout(()=>{this.props.veState.setDialogState({show:!1,dialog:Y.b.none}),this.props.VERef.emit(o.a.UPDATEDIALOGSTATE)},200)}_renderLoadingSpiner(){return s.createElement("div",{className:$.ldsRingWrapper},s.createElement("div",{className:$.ldsRing},s.createElement("div",null),s.createElement("div",null),s.createElement("div",null),s.createElement("div",null)))}render(){return s.createElement("div",{className:[$.VE_saving_dialog,$.VE_dialog].join(" ")},s.createElement("div",{className:$.mainWindow+" "+(this.state.solid?$.solid:""),style:{width:"388px",background:"#3C454C",boxShadow:"0 2px 8px 0 rgba(0,0,0,0.50)",borderRadius:"2px"}},s.createElement("div",{className:[$.dialogContent,this.props.VERef.connectedToGameEditor?$.inGameEditor:""].join(" "),style:{minHeight:"150px",padding:"0 20px",justifyContent:"center",display:"flex",textAlign:"center"}},s.createElement("div",{className:"dialog-contentText",style:{alignItems:"center",justifyContent:"center",display:"flex",lineHeight:"32px",color:"#969696"}},this.props.VERef.connectedToGameEditor?Object(E.e)("Save$$ToText",{name:this.props.veState.projectInfo.dispaly_name}):Object(E.e)("SaveText")),this.state.isSaving?this._renderLoadingSpiner():""),this.props.VERef.connectedToGameEditor?s.createElement("div",{className:$.dialogActions},s.createElement("div",{className:$.dialogBtn,style:{color:"#FFAF00"},onClick:()=>{this.state.isSaving||this.saveToGameEditor()}},Object(E.e)("game")," "),s.createElement("div",{className:$.dialogBtn,style:{color:"#969696"},onClick:()=>{this._close()}},Object(E.e)("cancel"))):s.createElement("div",{className:$.dialogActions},s.createElement("div",{className:$.dialogBtn,style:{color:"#FFAF00"},onClick:()=>{this.state.isSaving||this.saveModel()}},Object(E.e)("save")),s.createElement("div",{className:$.dialogBtn,style:{color:"#969696"},onClick:()=>{this._close()}},Object(E.e)("cancel")))),s.createElement("div",null,s.createElement(Q,{ref:this.notifyContainer})))}}const te=i(1371);class ie extends s.Component{constructor(e){super(e),this.unmount=!0,this.state={imgSrc:""}}UNSAFE_componentWillReceiveProps(e){e.previewHash!==this.props.previewHash&&this.setState({imgSrc:Object(B.a)(e.previewHash)})}componentDidMount(){this.unmount=!1,this.setState({imgSrc:Object(B.a)(this.props.previewHash)})}componentWillUnmount(){this.unmount=!0}render(){return s.createElement("div",{className:te.previewItem,onClick:()=>{this.props.editDelete||this.props.itemOnClick(this.props)}},s.createElement("div",{className:te.innerBorder}),""==this.state.imgSrc?s.createElement("div",{className:te.loader+" "+te.loader_2+" "+te.center},s.createElement("span",null)):"",s.createElement("img",{className:te.previewImage,src:this.state.imgSrc}),s.createElement("div",{className:te.previewDescription},s.createElement("span",{className:"file-name"},this.props.name)),s.createElement("div",{className:[te.deleteBtn,this.props.editDelete?te.actived:""].join(" "),onClick:()=>{this.props.VERef.brpc&&this.props.VERef.brpc.content.api.delete(this.props.contentId).then(()=>{this.props.veState.projectInfo.content_id===this.props.contentId&&(this.props.veState.projectInfo.content_id=-1),this.props.removePreviewItem(this.props.contentId)}).catch(e=>console.error(e))}},s.createElement("div",{className:te.deletStick1}),s.createElement("div",{className:te.deletStick2})))}}const se=i(1371);class oe extends s.Component{constructor(e){super(e),this.state={previewList:this.props.veState.getPreviewList(),editDelete:!1,solid:!1};const t=this;this._previewListUpdate=function(){t.setState({previewList:t.props.veState.getPreviewList()})}}componentDidMount(){setTimeout(()=>{this.setState({solid:!0})},20),this.props.VERef.on(o.a.PREVIEWLISTUPDATE,this._previewListUpdate)}componentWillUnmount(){this.props.VERef.removeListener(o.a.PREVIEWLISTUPDATE,this._previewListUpdate)}removePreviewItem(e){this.props.veState.removePreviewListItemById(e),this._previewListUpdate()}renderPreviewItem(){return this.state.previewList.map((e,t)=>s.createElement(ie,{VERef:this.props.VERef,veState:this.props.veState,itemOnClick:this.props.itemOnClick,key:t,name:e.name,authorId:e.author,contentId:void 0!==e.contentId?e.contentId:-1,describe:void 0!==e.describe?e.describe:"",modelProjectHash:e.modelProjectHash,previewHash:e.previewHash,editDelete:this.state.editDelete,removePreviewItem:this.removePreviewItem.bind(this)}))}render(){return s.createElement("div",{className:[se.VE_library_dialog,se.VE_dialog].join(" "),style:{}},s.createElement("div",{className:se.mainWindow+" "+(this.state.solid?se.solid:"")},s.createElement("div",{className:se.dialogHeader},s.createElement("div",{className:se.dialogBtn+" "+se.closeBtn,onClick:()=>{setTimeout(()=>{this.setState({solid:!1})},0),setTimeout(()=>{this.props.veState.setDialogState({show:!1,dialog:Y.b.none}),this.props.VERef.emit(o.a.UPDATEDIALOGSTATE)},200)}},s.createElement("div",{className:se.stickWrap},s.createElement("div",{className:se.stick_1}),s.createElement("div",{className:se.stick_2}))),s.createElement("div",{className:se.dialogBtn+" "+se.editBtn,onClick:()=>{this.setState({editDelete:!this.state.editDelete})}},"edit")),s.createElement("div",{className:se.dialogContent},this.renderPreviewItem())))}}const ne=i(1371);class re extends s.Component{constructor(e){super(e),this._fontImgInput=s.createRef(),this._sideImgInput=s.createRef(),this._fontImg=s.createRef(),this._sideImg=s.createRef(),this.state={solid:!1,stage:0}}componentDidMount(){setTimeout(()=>{this.setState({solid:!0})},20)}_processImgChange(e,t){this._loadImg(e,e=>{this._fontImg.current&&this._sideImg.current&&(t&&(t.src=e),""!==this._fontImg.current.src&&""!==this._sideImg.current.src&&this._fontImg.current.src!==location.href&&this._sideImg.current.src!==location.href?this.setState({stage:2}):""!==this._fontImg.current.src&&this._fontImg.current.src!==location.href||""!==this._sideImg.current.src&&this._sideImg.current.src!==location.href?this.setState({stage:1}):this.setState({stage:0}))})}_loadImg(e,t){if(!e)return!1;if(!e.files)return!1;if(1!==e.files.length)return!1;const i=e.files[0];if(!i)return!1;if(!i.type.match(/image/))return!1;const s=new FileReader;return s.onload=e=>{t(e.target.result)},s.readAsDataURL(i),!0}_close(){setTimeout(()=>{this.setState({solid:!1})},0),setTimeout(()=>{this.props.veState.setDialogState({show:!1,dialog:Y.b.none}),this.props.VERef.emit(o.a.UPDATEDIALOGSTATE)},200)}render(){return s.createElement("div",{className:[ne.VE_ImportImg_dialog,ne.VE_dialog].join(" ")},s.createElement("div",{className:ne.mainWindow+" "+(this.state.solid?ne.solid:""),style:{width:"512px",height:"394px",background:"#3C454C",boxShadow:"0 2px 8px 0 rgba(0,0,0,0.50)",borderRadius:"2px"}},s.createElement("div",{className:ne.dialogTitle},s.createElement("div",{className:ne.dialogTitleText},"Import images"),s.createElement("div",{className:ne.dialogTitleCloseBtn,onClick:()=>this._close()},s.createElement("div",{style:{height:"34px",width:"2px",transform:"translateX(880%)"}}),s.createElement("div",{style:{width:"34px",height:"2px"}}))),s.createElement("div",{className:ne.dialogContent,style:{padding:"2px",justifyContent:"center",display:"flex",textAlign:"center"}},s.createElement("div",{className:ne.imgInput},s.createElement("img",{className:ne.previewImg,ref:this._fontImg}),s.createElement("input",{ref:this._fontImgInput,accept:"image/png, image/jpeg, image/svg",style:{visibility:"hidden"},type:"file",onChange:e=>{this._fontImgInput.current&&this._processImgChange(this._fontImgInput.current,this._fontImg.current)}}),s.createElement("div",{className:ne.plusBtn,onClick:()=>{this._fontImgInput.current&&this._fontImgInput.current.click()}},s.createElement("div",{className:[ne.stick,ne.stick_1].join(" ")}),s.createElement("div",{className:[ne.stick,ne.stick_2].join(" ")})),s.createElement("div",{className:ne.deleteBtn,onClick:()=>{this._fontImg.current&&this._sideImg.current&&(this._fontImg.current.src="",""!==this._sideImg.current.src&&this._sideImg.current.src!==location.href?this.setState({stage:1}):this.setState({stage:0}))}}),s.createElement("div",{className:ne.imgAlt},"Front")),s.createElement("div",{className:ne.imgInput},s.createElement("img",{className:ne.previewImg,ref:this._sideImg}),s.createElement("input",{ref:this._sideImgInput,accept:"image/png, image/jpeg, image/svg",style:{visibility:"hidden"},type:"file",onChange:e=>{this._sideImgInput.current&&this._processImgChange(this._sideImgInput.current,this._sideImg.current)}}),s.createElement("div",{className:ne.plusBtn,onClick:()=>{this._sideImgInput.current&&this._sideImgInput.current.click()}},s.createElement("div",{className:[ne.stick,ne.stick_1].join(" ")}),s.createElement("div",{className:[ne.stick,ne.stick_2].join(" ")})),s.createElement("div",{className:ne.deleteBtn,onClick:()=>{this._fontImg.current&&this._sideImg.current&&(this._sideImg.current.src="",""!==this._fontImg.current.src&&this._fontImg.current.src!==location.href?this.setState({stage:1}):this.setState({stage:0}))}}),s.createElement("div",{className:ne.imgAlt},"Side"))),s.createElement("div",{className:ne.dialogActions},s.createElement("div",{className:[ne.confirmBtn].join(" "),onClick:()=>{this._fontImg.current&&this._sideImg.current&&(2===this.state.stage?this.props.VERef.importTwoViewImage(this._fontImg.current.src,this._sideImg.current.src):1===this.state.stage&&(""===this._fontImg.current.src||this._fontImg.current.src===location.href?this.props.VERef.importPixelImage(this._sideImg.current.src,"z"):this.props.VERef.importPixelImage(this._fontImg.current.src,"x")),this._close())},style:{display:0===this.state.stage?"none":"initial",color:2===this.state.stage?"#FFAF00":"#969696"}},1===this.state.stage?"Import":"Generate"))))}}var ae=i(62),le=Object.defineProperty,he=Object.defineProperties,ce=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,fe=(e,t,i)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;const me=i(1371);class ge extends s.Component{constructor(e){super(e),this.isPublishing=!1,this.state={solid:!1,modelname:this.props.veState.projectInfo.dispaly_name,description:this.props.veState.projectInfo.description}}componentDidMount(){setTimeout(()=>{this.setState({solid:!0})},20)}_sensorsReport(e){const t=new ae.a,i=((e,t)=>he(e,ce(t)))(((e,t)=>{for(var i in t||(t={}))pe.call(t,i)&&fe(e,i,t[i]);if(de)for(var i of de(t))ue.call(t,i)&&fe(e,i,t[i]);return e})({},e),{voxel_name:this.state.modelname,voxel_id:this.props.veState.projectInfo.content_id});t.track(ae.c.VOXEL_PUBLISH,i)}toPublish(){return"new_model"===this.state.modelname?(J.a.warning(Object(E.e)("pleaseNameTheFile")),void this._sensorsReport({is_success:!1,fail_reason:"不满足发布规范"})):this.isPublishing?(J.a.warning(Object(E.e)("doNotRepeatPublish")),void this._sensorsReport({is_success:!1,fail_reason:"不满足发布规范"})):new Blob([this.props.veState.projectInfo.dispaly_name]).size>this.props.VERef.maxNameLen?(J.a.warning(Object(E.e)("fileNameLenLimit")),void this._sensorsReport({is_success:!1,fail_reason:"不满足发布规范"})):(this.isPublishing=!0,J.a.info(Object(E.e)("modelIsPublishing")),void this.props.VERef.prePublish(()=>{this.isPublishing=!1,J.a.success(Object(E.e)("modelPublishSuccessed")),this._sensorsReport({is_success:!0,fail_reason:""}),this.close()}).catch(e=>{J.a.error(Object(E.e)("errorOccurredWhenPublishing")),console.error(e),this.isPublishing=!1,this._sensorsReport({is_success:!1,fail_reason:e.toString()})}))}close(){setTimeout(()=>{this.setState({solid:!1})},0),setTimeout(()=>{this.props.veState.setDialogState({show:!1,dialog:Y.b.none}),this.props.VERef.emit(o.a.UPDATEDIALOGSTATE)},200)}render(){return s.createElement("div",{className:[me.VE_dialog,me.VE_publis_dialog].join(" ")},s.createElement("div",{className:me.mainWindow+" "+(this.state.solid?me.solid:"")},s.createElement("div",{className:me.dialogHeader},s.createElement("div",{className:me.publishBtn,onClick:()=>this.toPublish()},Object(E.e)("publish")),s.createElement("div",{className:me.dialogBtn+" "+me.closeBtn,style:{right:0},onClick:()=>{this.close()}},s.createElement("div",{className:me.stickWrap},s.createElement("div",{className:me.stick_1}),s.createElement("div",{className:me.stick_2})))),s.createElement("div",{className:me.dialogContent},s.createElement("div",{className:me.publishLeft},s.createElement("div",{style:{marginBottom:"10px"}},s.createElement("div",{className:me.inputName},Object(E.e)("Title"),s.createElement("sup",null,"*")),s.createElement("input",{type:"text",className:me.inputContent,maxLength:50,placeholder:"new_model",value:"new_model"===this.state.modelname?"":this.state.modelname,onChange:e=>{this.setState({modelname:e.target.value}),this.props.veState.projectInfo.dispaly_name=e.target.value,this.props.VERef.emit(o.a.PROJECTINFOCHANGE)}})),s.createElement("div",null,s.createElement("div",{className:me.inputName},Object(E.e)("Description")),s.createElement("textarea",{className:me.inputContent,maxLength:150,value:this.state.description,onChange:e=>{this.setState({description:e.target.value}),this.props.veState.projectInfo.description=e.target.value}}))),s.createElement("div",{className:me.publishRight},s.createElement("div",{className:me.imageWrapper},s.createElement("img",{src:this.props.veState.projectInfo.preview}))))))}}const ve=i(1531);class be extends s.Component{constructor(e){super(e),this.targetIdx=0,this._pickerRef=s.createRef(),this.pickerInitColor="#000",this._onCloseColorPicker=()=>{!0===this.state.showColorPicker&&(this.setState({showColorPicker:!1,show:!1,dialog:Y.b.none}),this.props.VERef.dialogVanish())},this._onShowColorPicker=e=>{if(window.innerWidth<500||window.innerHeight<530){const{idx:t,hexColor:i,x:s,y:o}=e;if(t===this.targetIdx&&this.state.showColorPicker)return void this._onCloseColorPicker();this.targetIdx=t,this.pickerInitColor="#"+i,this.setState({showColorPicker:!0,show:!0,dialog:Y.b.colorPicker}),this._pickerRef.current&&this._pickerRef.current.newInput(this.pickerInitColor),this.props.VERef.dialogPopout()}};const t=this.props.veState.getDialogState();this.state={show:t.show,showColorPicker:!1,dialog:t.dialog};const i=this;this._onDialogContainerUpdate=function(e){i.updateState()}}updateState(){const e=this.props.veState.getDialogState();this.setState({show:e.show,dialog:e.dialog}),e.show?this.props.VERef.dialogPopout():this.props.VERef.dialogVanish()}componentDidMount(){this.props.VERef.on(o.a.UPDATEDIALOGSTATE,this._onDialogContainerUpdate),this.props.VERef.on(o.a.SHOWCOLORPICKER,this._onShowColorPicker),this.props.VERef.on(o.a.CLOSECOLORPICKER,this._onCloseColorPicker)}componentWillUnmount(){this.props.VERef.removeListener(o.a.UPDATEDIALOGSTATE,this._onDialogContainerUpdate),this.props.VERef.removeListener(o.a.SHOWCOLORPICKER,this._onShowColorPicker),this.props.VERef.removeListener(o.a.CLOSECOLORPICKER,this._onCloseColorPicker)}renderDialog(e){switch(e){case Y.b.colorPicker:const e=this.props.VERef.paletteManager;return s.createElement("div",{className:ve.colorPickerDialog},s.createElement("div",{className:ve.closeBtn,onClick:()=>{this._onCloseColorPicker()}},"Done"),s.createElement(b,{ref:this._pickerRef,style:{boxShadow:"none"},isTouchDevice:this.props.isTouchDevice,onChange:t=>{e.updateColorValue(this.targetIdx,t.map(e=>e/255))},onChangeEnd:()=>{if(this.pickerInitColor!=="#"+e.getHexColorById(this.targetIdx)){const t=Object(x.s)(this.pickerInitColor).map(e=>e/255),i=e.getRgbColorById(this.targetIdx);this.props.VERef.saveHistory({cidx:this.targetIdx,value:t,step:1}),this.props.VERef.saveHistory({cidx:this.targetIdx,value:i,step:2})}},hexColor:this.pickerInitColor}));case Y.b.savingDialog:return s.createElement(ee,{onHandleLogin:this.props.onHandleLogin,VERef:this.props.VERef,veState:this.props.veState});case Y.b.libraryDialog:return s.createElement(oe,{VERef:this.props.VERef,veState:this.props.veState,itemOnClick:e=>{const t=this.props.voxelEditorClient.fetchModelProjectData(e.modelProjectHash);this.props.VERef.onProjectLoadingStart(),t.then(t=>{this.props.VERef.onProjectLoadingFinished(),this.props.VERef.loadProject(JSON.parse(t),e)},e=>{this.props.VERef.onProjectLoadingFinished(),console.log(e)})}});case Y.b.importImgDialog:return s.createElement(re,{VERef:this.props.VERef,veState:this.props.veState});case Y.b.publish:return s.createElement(ge,{VERef:this.props.VERef,veState:this.props.veState});case Y.b.none:default:return""}}render(){return s.createElement("div",{style:{display:this.state.show?"initial":"none",position:"fixed",top:0,bottom:0,left:0,right:0,zIndex:21,pointerEvents:"initial"}},this.renderDialog(this.state.dialog))}}const xe=i(1532);class ye extends s.Component{constructor(e){if(super(e),this.props.isTouchDevice){const e=this.props.veState.bgSchemes[6];this.props.veState.bg.cA[0]=e[0][0],this.props.veState.bg.cA[1]=e[0][1],this.props.veState.bg.cA[2]=e[0][2],this.props.veState.bg.cB[0]=e[1][0],this.props.veState.bg.cB[1]=e[1][1],this.props.veState.bg.cB[2]=e[1][2]}this.state={model_name:this.props.veState.projectInfo.dispaly_name,hitVoxelPos:["-","-","-"],showColorSchemaList:!1,vc:{wire:this.props.veState.viewConfig.blockWireframe,grid:this.props.veState.viewConfig.boundaryCheckboard},ccs:[this.props.veState.bg.cA,this.props.veState.bg.cB]};const t=this;this._onProjectInfoChange=function(){t.setState({model_name:t.props.veState.projectInfo.dispaly_name})}}componentWillReceiveProps(e){!0===e.isTouchDevice&&!1===this.props.isTouchDevice&&this.setBackgroundColorSchema(6)}componentDidMount(){const e=document.getElementById("coord-x"),t=document.getElementById("coord-y"),i=document.getElementById("coord-z");this.props.VERef.on(o.a.PROJECTINFOCHANGE,this._onProjectInfoChange),this.props.VERef.pointer.onPositionChangeHook=function(s){e&&(e.innerText="x:"+s[0]),t&&(t.innerText="y:"+s[1]),i&&(i.innerText="z:"+s[2])}}componentWillUnmount(){this.props.VERef.removeListener(o.a.PROJECTINFOCHANGE,this._onProjectInfoChange),this.props.VERef.pointer.onPositionChangeHook=()=>{}}setBackgroundColorSchema(e){const t=this.props.veState.bgSchemes[e];this.props.veState.bg.cA[0]=t[0][0],this.props.veState.bg.cA[1]=t[0][1],this.props.veState.bg.cA[2]=t[0][2],this.props.veState.bg.cB[0]=t[1][0],this.props.veState.bg.cB[1]=t[1][1],this.props.veState.bg.cB[2]=t[1][2],this.setState({ccs:t})}renderBgColorList(){return this.props.veState.bgSchemes.map((e,t)=>{const i=e[0].map(e=>255*e),o=e[1].map(e=>255*e);return s.createElement("div",{className:"colorSchemeItem",key:t,"data-itemid":t,style:{width:"50px",height:"25px",background:"linear-gradient(to right, rgb("+i.join(",")+") 0%, rgb("+o.join(",")+") 100%)",margin:"1px"},onClick:e=>{const t=Number(e.target.getAttribute("data-itemid"));this.setBackgroundColorSchema(t)}})})}render(){const e=this.state.vc.wire,t=this.state.vc.grid;return s.createElement("div",{className:[xe.statusBarWrap,this.props.isTouchDevice?xe.touchDevice:""].join(" "),style:{pointerEvents:this.props.importingMesh?"none":"all",filter:this.props.blurOut?"blur(6px)":"none"}},s.createElement("div",{className:xe.statusBar},this.props.isTouchDevice?s.createElement("div",{className:xe.cursorOptionBtn,onClick:()=>{0===this.props.cursorDirection?this.props.setCursorDirection(1):this.props.setCursorDirection(0)}},s.createElement("div",{className:[xe.arrowWrapper,0===this.props.cursorDirection?xe.left:xe.right].join(" ")},s.createElement("div",{className:xe.arrow}))):s.createElement("div",{className:xe.screenSnap,onClick:()=>{this.props.VERef.getScreenShot((e,t)=>{const i=document.createElement("a");i.href=e,i.download=this.props.veState.projectInfo.dispaly_name+".jpg",function(e){const t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}(i)},"image/jpeg")}},s.createElement("div",{className:xe.btnIcon})),s.createElement("div",{className:xe.coordinateColorData},s.createElement("div",{className:xe.coordinate,id:"coord-x"},"x:",this.state.hitVoxelPos[0]),s.createElement("div",{className:xe.coordinate,id:"coord-y",style:{margin:this.props.isTouchDevice?"0 9px":"0 12px"}},"y:",this.state.hitVoxelPos[1]),s.createElement("div",{className:xe.coordinate,id:"coord-z"},"z:",this.state.hitVoxelPos[2])),this.props.isTouchDevice?s.createElement("div",{style:{flex:1}}):s.createElement("div",{className:xe.filenameWrap},s.createElement("input",{type:"text",value:this.state.model_name,onChange:()=>{}})),s.createElement("div",{className:xe.viewConfig},s.createElement("div",{className:xe.bgColorSchemeBtn,onClick:()=>{this.setState({showColorSchemaList:!this.state.showColorSchemaList})},style:{background:"linear-gradient(to right, rgb("+this.state.ccs[0].map(e=>255*e).join(",")+") 0%, rgb("+this.state.ccs[1].map(e=>255*e).join(",")+") 100%)"}}),s.createElement("div",{className:[xe.colorSchemeList,this.state.showColorSchemaList?xe.on:""].join(" ")},this.renderBgColorList()),s.createElement("div",{className:xe.observation,onClick:()=>{this.props.VERef.resetCameraPosition()}}),s.createElement("div",{className:xe.gridBtn+" "+(t?xe.on:""),onClick:()=>{this.setState({vc:{wire:e,grid:!t}}),this.props.VERef.updateBoxGridState(!t)}}),s.createElement("div",{className:xe.wireBtn+" "+(e?xe.on:""),onClick:()=>{this.setState({vc:{wire:!e,grid:t}}),this.props.VERef.updateBlockWireState(!e)}}))))}}const _e=i(1402);var Ee=(e=>(e[e.Integer=0]="Integer",e[e.Float=1]="Float",e))(Ee||{}),Me=(e=>(e[e.Dimension=0]="Dimension",e[e.Volume=1]="Volume",e))(Me||{});class Se extends s.Component{constructor(e){super(e),this.state={value:this.props.initValue,displayValue:this.props.initValue.join(" ")},this._value=this.props.initValue}updateState(){this.setState({value:this.props.initValue,displayValue:this.props.initValue.join(" ")})}_checkValue(){const{minValue:e,maxValue:t,type:i}=this.props,s=this.state.displayValue.split(" ").map(e=>Number(e)).splice(0,3);if(1==s.length&&(s[1]=s[2]=s[0]),3==s.length){if(0==this.props.bounderType)for(let o=0;o<3;o++){if("number"!=typeof s[o]||"NaN"==s[o].toString())return void this.setState({displayValue:this.state.value.join(" ")});s[o]=s[o]t[o]?t[o]:s[o],0==i&&(s[o]=Math.floor(s[o]))}else{for(let e=0;e<3;e++)if("number"!=typeof s[e]||"NaN"==s[e].toString())return void this.setState({displayValue:this.state.value.join(" ")});s[0]*s[1]*s[2]>t[0]*t[1]*t[2]&&(s[0]=s[0]t[0]?t[0]:s[0],s[1]=s[1]t[1]?t[1]:s[1],s[2]=s[2]t[2]?t[2]:s[2]),0==i&&(s[0]=Math.floor(s[0]),s[1]=Math.floor(s[1]),s[2]=Math.floor(s[2]))}this._value=s,this.setState({value:this._value,displayValue:this._value.join(" ")}),this.props.onChange(s)}else this.setState({displayValue:this.state.value.join(" ")})}_onInputChange(e){this.setState({displayValue:e.target.value})}render(){return s.createElement("div",{className:_e.vector3Input},this.props.tag?s.createElement("span",{className:_e.tag,onClick:()=>this.props.onTagClick()},this.props.tag):"",s.createElement("div",{className:_e.inputWrap,style:this.props.style},s.createElement("input",{type:"text",value:this.state.displayValue,onBlur:e=>{this._checkValue()},onKeyPress:e=>{13==e.charCode&&this._checkValue()},onChange:e=>{this._onInputChange(e)}})))}}var we=i(23),Ce=i(58),Pe=Object.defineProperty,ke=Object.defineProperties,Re=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,Te=(e,t,i)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;const Ne=i(1533);class De extends s.Component{constructor(e){super(e),this._fileNameEle=s.createRef(),this._inputFile=s.createRef(),this.state={modelname:this.props.veState.projectInfo.dispaly_name,fileMemuOpen:!1,SIZE:this.props.veState.basicConfig.workspaceSize,currentProcess:this.props.veState.pbrPreviewMode?"polishing":"modeling",showTouchUIMenu:!1},this.sizeInputRef=s.createRef();const t=this;this._forceUpdate=function(){t.forceUpdate()},this._basicConfigPanelUpdate=function(){t.setState({SIZE:t.props.veState.basicConfig.workspaceSize}),t.sizeInputRef.current&&t.sizeInputRef.current.updateState()},this._modelNameUpdate=function(){t.setState({modelname:t.props.veState.projectInfo.dispaly_name})}}componentDidMount(){this.props.VERef.on(o.a.CHANGESIZE,this._basicConfigPanelUpdate),this.props.VERef.on(o.a.PROJECTINFOCHANGE,this._modelNameUpdate),this.props.VERef.on(o.a.FORCEUPDATETOPBAR,this._forceUpdate)}componentWillUnmount(){this.props.VERef.removeListener(o.a.CHANGESIZE,this._basicConfigPanelUpdate),this.props.VERef.removeListener(o.a.PROJECTINFOCHANGE,this._modelNameUpdate),this.props.VERef.removeListener(o.a.FORCEUPDATETOPBAR,this._forceUpdate)}_openFileClick(e){if(null===e.files)return;if(1===e.files.length){const t=e.files[0];if(!t)return;const i=t.name.split(".");i.length>1&&"txt"===i[i.length-1]&&i.pop();switch(i[i.length-1]){case"vd":this.props.VERef.importVDModel(t);break;case"vox":this.props.VERef.importVoxModel(t);break;case"obj":this.props.VERef.importTriangleMesh(t,e=>{this.props.VERef.previewMesh.focusMesh=e,this.props.startImportMesh()})}}e.files=null,e.value=""}_handleSizeInputChange(e){this.props.VERef.updateSpaceSize(e[0],e[1],e[2]),this.props.VERef.saveHistory()}_sensorsReport(e){const t=new ae.a,i=((e,t)=>ke(e,Re(t)))(((e,t)=>{for(var i in t||(t={}))Oe.call(t,i)&&Te(e,i,t[i]);if(Ie)for(var i of Ie(t))je.call(t,i)&&Te(e,i,t[i]);return e})({},e),{voxel_name:this.props.veState.projectInfo.dispaly_name,voxel_id:""+this.props.veState.projectInfo.content_id});t.track(ae.c.MAP_PUBLISH,i)}publish(){if(this.props.VERef.destModel.isEmpty())return J.a.warning(Object(E.e)("NoEmptyModelWarnning")),void this._sensorsReport({is_success:!1,fail_reason:"不满足发布规范"});this.props.VERef.getScreenShot((e,t)=>{this.props.veState.projectInfo.preview=e,this.props.veState.projectInfo.content_id=t,this.props.veState.setDialogState({show:!0,dialog:Y.b.publish}),this.props.VERef.emit(o.a.UPDATEDIALOGSTATE)})}checkNameContainInvalidSymbol(e){for(let t=0;t<'<>:"/\\|?*`'.length;t++)if(e.indexOf('<>:"/\\|?*`'[t])>-1)return!0;return!1}openLibrary(){const{brpc:e}=this.props.VERef;if(e)e.auth.api.online({entry:Ce.c.website}).then(({data:t})=>{if(t&&t.id){e.content.api.list({type:we.a.ContentType.asset,limit:200,isPublic:!1,offset:0,sort:we.a.ContentOrder.updated,filter:void 0,authorId:void 0,recommendByContentId:void 0,status:void 0,noCache:void 0}).then(e=>{if(!e)return;const t=e.rows.reverse(),i=[];for(let e=0;econsole.error(e))}}).catch(e=>console.error(e));else{const e=this.props.voxelEditorClient.fetchModelList();this.props.veState.setDialogState({show:!0,dialog:Y.b.libraryDialog}),this.props.VERef.emit(o.a.UPDATEDIALOGSTATE),this.props.veState.setPreviewList(e),this.props.VERef.emit(o.a.PREVIEWLISTUPDATE)}}renderTouchDeviceUI(){const e=this.props.VERef.connectedToGameEditor;return s.createElement("div",{style:{width:"100%"}},this.state.showTouchUIMenu?s.createElement("div",{className:Ne.touchMenuMask,onTouchStart:()=>{this.setState({showTouchUIMenu:!1})}}):null,s.createElement("div",{className:[Ne.topBar,Ne.touchDevice].join(" ")},s.createElement("div",{className:[Ne.fnBtn,Ne.saveBtn].join(" "),onClick:()=>{this.props.VERef.destModel.isEmpty()?J.a.warning(Object(E.e)("NoEmptyModelWarnning")):(this.props.veState.setDialogState({show:!0,dialog:Y.b.savingDialog}),this.props.VERef.emit(o.a.UPDATEDIALOGSTATE))}},s.createElement("div",{className:Ne.btnIcon})),s.createElement("div",{className:Ne.topBarCenter},s.createElement("div",{className:Ne.title},s.createElement("input",{ref:this._fileNameEle,type:"text",value:this.state.modelname,onChange:e=>{if(this.checkNameContainInvalidSymbol(e.target.value))return e.preventDefault(),void J.a.warning(Object(E.e)("containInvalidSymbol")+' <>:"/\\|?*`');this.setState({modelname:e.target.value}),this.props.veState.projectInfo.dispaly_name=e.target.value}})),s.createElement("div",{className:Ne.workspaceSizeInfo},s.createElement(Se,{style:{width:"100px",height:"32px",verticalAlign:"top",marginTop:"2px",marginLeft:"2px"},ref:this.sizeInputRef,bounderType:Me.Volume,type:Ee.Integer,minValue:[1,1,1],maxValue:[96,96,96],initValue:this.state.SIZE,onTagClick:()=>{},onChange:e=>{this._handleSizeInputChange(e)}}),s.createElement("div",{className:Ne.fitbtn,onClick:()=>{this.props.VERef.fitSpaceSize()}},s.createElement("div",{className:Ne.btnIcon})))),e?null:s.createElement("div",{className:Ne.touchDeviceMenu},s.createElement("div",{className:Ne.toggleButton,onClick:()=>{this.setState({showTouchUIMenu:!0})}},Object(E.e)("Menu")),this.state.showTouchUIMenu?s.createElement("div",{className:Ne.menuList},s.createElement("div",{className:Ne.menuItem,onClick:()=>{this.setState({showTouchUIMenu:!1})}},Object(E.e)("Back")),s.createElement("div",{className:Ne.separateLine}),s.createElement("div",{className:Ne.menuItem,onClick:()=>{this.props.VERef.newFile(),this.setState({showTouchUIMenu:!1})}},Object(E.e)("New")),s.createElement("div",{className:Ne.menuItem,onClick:()=>{this.props.VERef.download(),this.setState({showTouchUIMenu:!1})}},Object(E.e)("Download")),s.createElement("div",{className:Ne.menuItem,onClick:()=>{this.publish(),this.setState({showTouchUIMenu:!1})}},Object(E.e)("publish")),s.createElement("div",{className:Ne.menuItem,onClick:()=>{this._inputFile.current&&this._inputFile.current.click()}},Object(E.e)("OpenLocal"),s.createElement("input",{type:"file",style:{visibility:"hidden",height:"0",width:"0",pointerEvents:"none"},ref:this._inputFile,onChange:e=>{this._inputFile.current&&this._openFileClick(this._inputFile.current)}})),s.createElement("div",{className:Ne.menuItem,onClick:()=>{this.openLibrary(),this.setState({showTouchUIMenu:!1})}},Object(E.e)("OpenLibrary")),s.createElement("div",{className:Ne.menuItem,onClick:()=>{const e=window.confirm(Object(E.e)("ExitConfirmText"));this.setState({showTouchUIMenu:!1}),e&&this.props.onClose()}},Object(E.e)("Exit"))):null)))}renderDecktopUI(){const e=this.props.VERef.connectedToGameEditor,t=this.state.fileMemuOpen,i=this.state.currentProcess;return s.createElement("div",{className:[Ne.topBar,this.props.importingMesh?Ne.hide:""].join(" "),style:{filter:this.props.blurOut?"blur(6px)":"none"}},s.createElement("div",{className:Ne.topBarLeft},s.createElement("ul",{className:Ne.tab},s.createElement("li",{className:Ne.modeling+" "+("modeling"===i?Ne.current:""),onClick:()=>{this.props.veState.pbrPreviewMode=!1,this.setState({currentProcess:"modeling"}),this.props.togglePolishingProcess(!1),this.props.VERef.emit(o.a.PROCESSTOGGLE)}},Object(E.e)("Model")),s.createElement("li",{className:Ne.polishing+" "+("polishing"===i?Ne.current:""),onClick:()=>{this.props.veState.pbrPreviewMode=!0,this.setState({currentProcess:"polishing"}),this.props.togglePolishingProcess(!0),this.props.veState.setEditingActions(x.a.PickColor),this.props.VERef.emit(o.a.PROCESSTOGGLE)}},Object(E.e)("Render")))),s.createElement("div",{className:Ne.topBarCenter},this.props.VERef.connectedToGameEditor?"":s.createElement("div",{className:Ne.publishBtn,onClick:()=>{this.publish()}},Object(E.e)("publish")),s.createElement("div",{className:Ne.title},s.createElement("input",{ref:this._fileNameEle,type:"text",value:this.state.modelname,onChange:e=>{if(this.checkNameContainInvalidSymbol(e.target.value))return e.preventDefault(),void J.a.warning(Object(E.e)("containInvalidSymbol")+' <>:"/\\|?*`');this.setState({modelname:e.target.value}),this.props.veState.projectInfo.dispaly_name=e.target.value}})),s.createElement("div",{className:Ne.workspaceSizeInfo},s.createElement(Se,{style:{width:"120px",height:"32px",verticalAlign:"top",marginTop:"2px",marginLeft:"2px"},ref:this.sizeInputRef,bounderType:Me.Volume,type:Ee.Integer,minValue:[1,1,1],maxValue:[96,96,96],initValue:this.state.SIZE,onTagClick:()=>{},onChange:e=>{this._handleSizeInputChange(e)}}),s.createElement("div",{className:Ne.fitbtn,onClick:()=>{this.props.VERef.fitSpaceSize()}},s.createElement("div",{className:Ne.btnIcon})))),s.createElement("div",{className:[Ne.topBarRight,this.props.VERef.connectedToGameEditor?Ne.inGame:""].join(" ")},s.createElement("div",{className:[Ne.fnBtn,Ne.saveBtn].join(" "),onClick:()=>{this.props.VERef.destModel.isEmpty()?J.a.warning(Object(E.e)("NoEmptyModelWarnning")):(this.props.veState.setDialogState({show:!0,dialog:Y.b.savingDialog}),this.props.VERef.emit(o.a.UPDATEDIALOGSTATE))}},s.createElement("div",{className:Ne.btnIcon})),e?"":s.createElement("div",{className:[Ne.fnBtn,Ne.downloadBtn].join(" "),onClick:()=>{this.props.VERef.download()}},s.createElement("div",{className:Ne.btnIcon})),e?"":s.createElement("div",{className:[Ne.fnBtn,Ne.openBtn,t?Ne.on:Ne.off].join(" "),onClick:()=>this.setState({fileMemuOpen:!this.state.fileMemuOpen})},s.createElement("div",{className:Ne.btnIcon}),s.createElement("div",{onMouseLeave:()=>this.setState({fileMemuOpen:!1}),className:Ne.listMenu},s.createElement("div",{className:Ne.listItem,onClick:()=>this.props.VERef.newFile()},Object(E.e)("New")),s.createElement("div",{className:Ne.listItem,onClick:()=>{this._inputFile.current&&this._inputFile.current.click()}},Object(E.e)("OpenLocal"),s.createElement("input",{type:"file",style:{visibility:"hidden",pointerEvents:"none"},ref:this._inputFile,onChange:e=>{this._inputFile.current&&this._openFileClick(this._inputFile.current)}})),s.createElement("div",{className:Ne.listItem,onClick:()=>{this.props.veState.setDialogState({show:!0,dialog:Y.b.importImgDialog}),this.props.VERef.emit(o.a.UPDATEDIALOGSTATE)}},Object(E.e)("ImportImage")),s.createElement("div",{className:Ne.listItem,onClick:()=>{this.openLibrary()}},Object(E.e)("OpenLibrary")))),e?"":s.createElement("div",{className:[Ne.fnBtn,Ne.printBtn].join(" "),onClick:()=>{this.props.VERef.destModel.toStl()}},s.createElement("div",{className:Ne.btnIcon})),e?"":s.createElement("div",{className:[Ne.fnBtn,Ne.exitBtn].join(" "),onClick:()=>{this.props.onClose()}},s.createElement("div",{className:Ne.btnIcon}))))}render(){return this.props.isTouchDevice?this.renderTouchDeviceUI():this.renderDecktopUI()}}const Ve=i(1534);class Be extends s.Component{constructor(e){super(e),this.keyState={},this.state={miniPanel:!1,currentTool:this.props.veState.getCurrentEditingTool(),editingMode:this.props.veState.getEditingMode(),colorSelectOpt:this.props.veState.getColorSelectOption(),mirrorSymmetry:[this.props.veState.basicActionOption.Mirror.X,this.props.veState.basicActionOption.Mirror.Y,this.props.veState.basicActionOption.Mirror.Z],axisSymmetry:[this.props.veState.basicActionOption.Axis.X,this.props.veState.basicActionOption.Axis.Y,this.props.veState.basicActionOption.Axis.Z],fmsOpt:this.props.veState.getFaceModeSelectionOpt()},this.keyState={},this._leftPanelHotKeyDown=this._leftPanelHotKeyDown.bind(this),this._leftPanelHotKeyUp=this._leftPanelHotKeyUp.bind(this)}_leftPanelHotKeyDown(e){if(!(e.target&&"INPUT"===e.target.tagName||e.target&&"TEXTAREA"===e.target.tagName)){if(this.keyState[e.keyCode]=!0,84===e.keyCode)this._setCurrentTool(x.a.Attach);else if(82===e.keyCode)this._setCurrentTool(x.a.Erase);else if(71===e.keyCode)this._setCurrentTool(x.a.Paint);else if(18===e.keyCode)this._previousTool=this.props.veState.getCurrentEditingTool(),this._setCurrentTool(x.a.PickColor);else if(66===e.keyCode)this._setEditingMode(x.c.box);else if(76===e.keyCode)this._setEditingMode(x.c.line);else if(70===e.keyCode)this._setEditingMode(x.c.face);else if(67===e.keyCode)this.keyState[91]?this.keyState[67]&&(this.props.VERef.veController.pasetSelection(),this.props.VERef.saveHistory(),this.keyState[67]=!1):this._setEditingMode(x.c.center);else if(78===e.keyCode)this._setCurrentTool(x.a.Select);else if(77===e.keyCode)this._setCurrentTool(x.a.ColorSelect);else if(90===e.keyCode&&this.keyState[90])this.keyState[91]&&!this.keyState[16]?(this.props.VERef.prevStep(),this.keyState[90]=!1):this.keyState[91]&&this.keyState[16]&&(this.props.VERef.nextStep(),this.keyState[90]=!1);else if(88===e.keyCode&&this.keyState[88])this.keyState[91]&&(this.props.VERef.veController.clearAllModels(),this.keyState[88]=!1);else if(65===e.keyCode&&this.keyState[65])this.keyState[91]&&(this.props.VERef.veController.SelectAll(),this.props.VERef.saveHistory(),this.keyState[65]=!1);else if(68===e.keyCode&&this.keyState[68])this.keyState[91]&&(this.props.VERef.veController.deSelect(),this.props.VERef.saveHistory(),this.keyState[65]=!1,e.preventDefault());else if(8===e.keyCode){if(e.target&&"INPUT"===e.target.tagName)return;this.props.VERef.veController.deleteSelectBlocks(),this.props.VERef.saveHistory(),e.preventDefault()}e.stopPropagation()}}_leftPanelHotKeyUp(e){this.keyState[e.keyCode]=!1,18===e.keyCode&&this._setCurrentTool(this._previousTool)}componentDidMount(){document.body.addEventListener("keydown",this._leftPanelHotKeyDown),document.body.addEventListener("keyup",this._leftPanelHotKeyUp)}componentWillUnmount(){document.body.removeEventListener("keydown",this._leftPanelHotKeyDown),document.body.removeEventListener("keyup",this._leftPanelHotKeyUp)}_setCurrentTool(e){this.props.veState.setEditingActions(e),this.setState({currentTool:e})}_setEditingMode(e){this.props.veState.setEditingMode(e),this.setState({editingMode:e})}_setColorSelectOpt(e){this.props.veState.setColorSelectOption(e),this.setState({colorSelectOpt:e})}render(){const e=this.state.currentTool,t=this.state.editingMode,i=this.state.colorSelectOpt,o=e===x.a.Attach||e===x.a.Erase||e===x.a.Paint,n=this.state.mirrorSymmetry,r=this.state.axisSymmetry,a=this.state.fmsOpt===x.e.colorGeometry;return s.createElement("div",{className:[Ve.leftPanel,this.props.importingMesh?Ve.hide:"",this.state.miniPanel?Ve.mini:"",this.props.isTouchDevice?Ve.touchDevice:""].join(" "),style:{filter:this.props.blurOut?"blur(6px)":"none"}},s.createElement("div",{className:Ve.leftPanelHeader,onClick:()=>this.setState({miniPanel:!this.state.miniPanel})},s.createElement("div",{className:Ve.minimizeBtn})),s.createElement("div",{className:Ve.leftPanelWrap},s.createElement("div",{className:Ve.leftPanelInnerWrap},s.createElement("div",{className:Ve.toolOPtBtnGp},s.createElement("div",{className:Ve.GpTitle},Object(E.e)("Mirror")),s.createElement("div",{className:Ve.btnGp},s.createElement("div",{className:[Ve.btn,this.state.mirrorSymmetry[0]?Ve.current:""].join(" "),onClick:()=>{const e=!n[0];this.props.veState.basicActionOption.Mirror.X=e,this.setState({mirrorSymmetry:[e,n[1],n[2]]})}},"X"),s.createElement("div",{className:[Ve.btn,this.state.mirrorSymmetry[1]?Ve.current:""].join(" "),onClick:()=>{const e=!n[1];this.props.veState.basicActionOption.Mirror.Y=e,this.setState({mirrorSymmetry:[n[0],e,n[2]]})}},"Y"),s.createElement("div",{className:[Ve.btn,this.state.mirrorSymmetry[2]?Ve.current:""].join(" "),onClick:()=>{const e=!n[2];this.props.veState.basicActionOption.Mirror.Z=e,this.setState({mirrorSymmetry:[n[0],n[1],e]})}},"Z"))),s.createElement("div",{className:Ve.toolOPtBtnGp},s.createElement("div",{className:Ve.GpTitle},Object(E.e)("Axis")),s.createElement("div",{className:Ve.btnGp},s.createElement("div",{className:[Ve.btn,this.state.axisSymmetry[0]?Ve.current:""].join(" "),onClick:()=>{const e=!r[0];this.props.veState.basicActionOption.Axis.X=e,this.setState({axisSymmetry:[e,r[1],r[2]]})}},"X"),s.createElement("div",{className:[Ve.btn,this.state.axisSymmetry[1]?Ve.current:""].join(" "),onClick:()=>{const e=!r[1];this.props.veState.basicActionOption.Axis.Y=e,this.setState({axisSymmetry:[r[0],e,r[2]]})}},"Y"),s.createElement("div",{className:[Ve.btn,this.state.axisSymmetry[2]?Ve.current:""].join(" "),onClick:()=>{const e=!r[2];this.props.veState.basicActionOption.Axis.Z=e,this.setState({axisSymmetry:[r[0],r[1],e]})}},"Z"))),s.createElement("div",{className:Ve.buildFnBtnGp},s.createElement("div",{className:Ve.GpTitle},Object(E.e)("Edit")),s.createElement("div",{className:[Ve.btn,Ve.attach,e===x.a.Attach?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.Attach)},s.createElement("div",{className:Ve.btnIcon}),s.createElement("div",{className:Ve.btnTag},Object(E.e)("Attach"))),s.createElement("div",{className:[Ve.btn,Ve.erase,e===x.a.Erase?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.Erase)},s.createElement("div",{className:Ve.btnIcon}),s.createElement("div",{className:Ve.btnTag},Object(E.e)("Erase"))),s.createElement("div",{className:[Ve.btn,Ve.paint,e===x.a.Paint?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.Paint)},s.createElement("div",{className:Ve.btnIcon}),s.createElement("div",{className:Ve.btnTag},Object(E.e)("Paint"))),s.createElement("div",{className:[Ve.btnGp,o?Ve.actived:""].join(" ")},s.createElement("div",{className:[Ve.btn,Ve.box,t===x.c.box?Ve.current:""].join(" "),onClick:()=>this._setEditingMode(x.c.box)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.line,t===x.c.line?Ve.current:""].join(" "),onClick:()=>this._setEditingMode(x.c.line)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.surface,t===x.c.face?Ve.current:""].join(" "),onClick:()=>this._setEditingMode(x.c.face)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.circle,t===x.c.center?Ve.current:""].join(" "),onClick:()=>this._setEditingMode(x.c.center)},s.createElement("div",{className:Ve.btnIcon}))),s.createElement("div",{className:[Ve.btnGp,Ve.faceModeOpts,t===x.c.face?Ve.actived:""].join(" ")},s.createElement("div",{className:[Ve.btn,Ve.colorMode,a?Ve.current:""].join(" "),onClick:()=>{this.props.veState.setFaceModeSelectionOpt(x.e.colorGeometry),this.setState({fmsOpt:x.e.colorGeometry})}},"Color"),s.createElement("div",{className:[Ve.btn,Ve.geometryMode,a?"":Ve.current].join(" "),onClick:()=>{this.props.veState.setFaceModeSelectionOpt(x.e.geometry),this.setState({fmsOpt:x.e.geometry})}},"Geometry"))),s.createElement("div",{className:Ve.editingFnBtnGp},s.createElement("div",{className:Ve.GpTitle},Object(E.e)("Tools")),s.createElement("div",{className:Ve.btnGp},s.createElement("div",{className:[Ve.btn,Ve.translate,e===x.a.Translate?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.Translate)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.select,e===x.a.Select?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.Select)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.magicWand,e===x.a.ColorSelect?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.ColorSelect)},s.createElement("div",{className:Ve.btnIcon}))),s.createElement("div",{className:Ve.btnGp},s.createElement("div",{className:[Ve.btn,Ve.straw,e===x.a.PickColor?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.PickColor)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.chisel,e===x.a.HollowOut?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.HollowOut)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.paintBucket,e===x.a.FillSameColorSpace?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.FillSameColorSpace)},s.createElement("div",{className:Ve.btnIcon}))),s.createElement("div",{className:[Ve.colorSelectionOpt,Ve.btnGp,e===x.a.ColorSelect?Ve.actived:""].join(" ")},s.createElement("div",{className:[Ve.btn,Ve.Face,i===x.l.face?Ve.current:""].join(" "),onClick:()=>this._setColorSelectOpt(x.l.face)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.Volume,i===x.l.volume?Ve.current:""].join(" "),onClick:()=>this._setColorSelectOpt(x.l.volume)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.All,i===x.l.all?Ve.current:""].join(" "),onClick:()=>this._setColorSelectOpt(x.l.all)},s.createElement("div",{className:Ve.btnIcon})))),s.createElement("div",{className:Ve.rotateBtnGp},s.createElement("div",{className:Ve.GpTitle},Object(E.e)("Rotate")),s.createElement("div",{className:Ve.btnGp},s.createElement("div",{className:Ve.btn,onClick:()=>{this.props.VERef.veController.rotateX_90deg()}},"X"),s.createElement("div",{className:Ve.btn,onClick:()=>{this.props.VERef.veController.rotateY_90deg()}},"Y"),s.createElement("div",{className:Ve.btn,onClick:()=>{this.props.VERef.veController.rotateZ_90deg()}},"Z"))),s.createElement("div",{className:Ve.flipBtnGp},s.createElement("div",{className:Ve.GpTitle},Object(E.e)("Flip")),s.createElement("div",{className:Ve.btnGp},s.createElement("div",{className:Ve.btn,onClick:()=>{this.props.VERef.veController.flipX()}},"X"),s.createElement("div",{className:Ve.btn,onClick:()=>{this.props.VERef.veController.flipY()}},"Y"),s.createElement("div",{className:Ve.btn,onClick:()=>{this.props.VERef.veController.flipZ()}},"Z"))))),this.state.miniPanel?s.createElement("div",{className:Ve.leftPanelQuickTool,style:{filter:this.props.blurOut?"blur(6px)":"initial"}},s.createElement("div",{className:Ve.QuickToolRow},s.createElement("div",{className:[Ve.btn,Ve.attach,e===x.a.Attach?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.Attach)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.erase,e===x.a.Erase?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.Erase)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.paint,e===x.a.Paint?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.Paint)},s.createElement("div",{className:Ve.btnIcon}))),s.createElement("div",{className:Ve.QuickToolRow},s.createElement("div",{className:[Ve.btn,Ve.translate,e===x.a.Translate?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.Translate)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.select,e===x.a.Select?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.Select)},s.createElement("div",{className:Ve.btnIcon})),s.createElement("div",{className:[Ve.btn,Ve.paintBucket,e===x.a.FillSameColorSpace?Ve.current:""].join(" "),onClick:()=>this._setCurrentTool(x.a.FillSameColorSpace)},s.createElement("div",{className:Ve.btnIcon})))):null)}}var Ae=i(7),Le=i(94),ze=i(3),He=i(1400);const Ue=i(1535);class Fe extends s.Component{constructor(e){var t,i;super(e),this.rotationHistory=[],this._temp_quat=ze.c.create(),this.initial_quat=ze.c.copy(ze.c.create(),(null==(t=this.props.VERef.previewMesh.focusMesh)?void 0:t.orientation)||ze.c.create()),this.state={euler_x:0,euler_y:0,euler_z:0,rotateHistory:"",scale:(null==(i=this.props.VERef.previewMesh.focusMesh)?void 0:i.scale[0])||32,spaceRequired:[0,0,0]},this.boundBox=function(){const e=.5,t=[],i=[];return t.push([-e,-e,-e],[-e,-e,e],[-e,e,e],[-e,e,-e]),t.push([e,-e,-e],[e,-e,e],[e,e,e],[e,e,-e]),i.push([0,1,2],[2,3,0],[0,4,5],[5,1,0],[0,3,7],[7,4,0],[3,2,6],[6,7,3],[1,5,6],[6,2,1],[4,7,6],[6,5,4]),new He.a(t,i)}(),this.boundBox.opacity=.3,this.props.VERef.previewMesh.triangleMeshs.push(this.boundBox)}componentDidMount(){this.computeBoxDimension()}computeBoxDimension(){const e=this.props.VERef.previewMesh.focusMesh;if(e){const{lo:t,hi:i}=e.calculateTransoformBound();this.boundBox.scale[0]=i[0]-t[0],this.boundBox.scale[1]=i[1]-t[1],this.boundBox.scale[2]=i[2]-t[2],this.boundBox.translate[0]=(i[0]+t[0])/2,this.boundBox.translate[1]=(i[1]+t[1])/2,this.boundBox.translate[2]=(i[2]+t[2])/2,this.boundBox.calculateMatrix(),this.setState({spaceRequired:[Math.ceil(this.boundBox.scale[0]+1),Math.ceil(this.boundBox.scale[1]+1),Math.ceil(this.boundBox.scale[2])+1]})}}_applyEuler(){const e=this.props.VERef.previewMesh.focusMesh;e&&(ze.c.copy(this.initial_quat,e.orientation),this.rotationHistory.push([this.state.euler_x,this.state.euler_y,this.state.euler_z]),this.setState({euler_x:0,euler_y:0,euler_z:0,rotateHistory:this.rotationHistory.join("\n")}))}onEulerChange(){const e=this.props.VERef.previewMesh.focusMesh;e&&(ze.c.fromEuler(this._temp_quat,this.state.euler_x,this.state.euler_y,this.state.euler_z),ze.c.multiply(e.orientation,this.initial_quat,this._temp_quat),ze.c.normalize(e.orientation,e.orientation),e.calculateMatrix(),this.computeBoxDimension())}onScaleChange(e){const t=this.props.VERef.previewMesh.focusMesh;t&&e>=10&&e<=128&&this.setState({scale:e},()=>{t.scale[0]=e,t.scale[1]=e,t.scale[2]=e,t.calculateMatrix(),this.computeBoxDimension()})}applyVoxlization(){const e=this.props.VERef.previewMesh.focusMesh;if(e){e.translate[0]+=this.boundBox.scale[0]/2,e.translate[1]+=this.boundBox.scale[1]/2,e.translate[2]+=this.boundBox.scale[2]/2,e.calculateMatrix(),e.applyPermanentTransform();const[t,i,s]=this.state.spaceRequired;this.props.VERef.updateSpaceSize(t,i,s),this.props.VERef.voxelize(e),this.props.finishImportMesh()}}render(){const e=this.state.spaceRequired[0]*this.state.spaceRequired[1]*this.state.spaceRequired[2];return s.createElement("div",{className:Ue.previewMeshController},s.createElement("div",{className:Ue.rotation},s.createElement("div",{className:Ue.text},Object(E.e)("importMeshInstruction")),s.createElement("div",{className:Ue.text},Object(E.e)("requiredSpace"),this.state.spaceRequired.join(", "),"."),e>884736?s.createElement("div",{className:[Ue.text,Ue.warning].join(" ")},Object(E.e)("sizeExceeded")):"",s.createElement("div",{className:Ue.text},Object(E.e)("EulerAngle")," XYZ"),s.createElement("div",null,s.createElement("div",{className:Ue.label},"X:"),s.createElement("input",{className:Ue.slider,type:"range",min:-180,max:180,value:this.state.euler_x,onChange:e=>{this.setState({euler_x:Math.round(Number(e.target.value))},()=>{this.onEulerChange()})}}),s.createElement("input",{className:Ue.numberInput,type:"number",value:this.state.euler_x,onChange:e=>{this.setState({euler_x:Math.round(Math.min(180,Math.max(-180,Number(e.target.value))))},()=>{this.onEulerChange()})}})),s.createElement("div",null,s.createElement("div",{className:Ue.label},"Y:"),s.createElement("input",{className:Ue.slider,type:"range",min:-180,max:180,value:this.state.euler_y,onChange:e=>{this.setState({euler_y:Math.round(Number(e.target.value))},()=>{this.onEulerChange()})}}),s.createElement("input",{className:Ue.numberInput,type:"number",value:this.state.euler_y,onChange:e=>{this.setState({euler_y:Math.round(Math.min(180,Math.max(-180,Number(e.target.value))))},()=>{this.onEulerChange()})}})),s.createElement("div",null,s.createElement("div",{className:Ue.label},"Z:"),s.createElement("input",{className:Ue.slider,type:"range",min:-180,max:180,value:this.state.euler_z,onChange:e=>{this.setState({euler_z:Math.round(Number(e.target.value))},()=>{this.onEulerChange()})}}),s.createElement("input",{className:Ue.numberInput,type:"number",value:this.state.euler_z,onChange:e=>{this.setState({euler_z:Math.round(Math.min(180,Math.max(-180,Number(e.target.value))))},()=>{this.onEulerChange()})}})),s.createElement("button",{className:Ue.applyBtn,onClick:()=>{this._applyEuler()}},Object(E.e)("applyRotation"))),s.createElement("div",{className:Ue.scale},s.createElement("div",{className:Ue.text},Object(E.e)("Scalefactor")),s.createElement("div",null,s.createElement("input",{className:Ue.slider,type:"range",min:10,max:128,value:this.state.scale,onChange:e=>{this.onScaleChange(Math.round(Number(e.target.value)))}}),s.createElement("input",{className:Ue.numberInput,type:"number",value:this.state.scale,onChange:e=>{this.onScaleChange(Math.round(Number(e.target.value)))}}))),s.createElement("div",{className:Ue.rotateHistory},this.state.rotateHistory),s.createElement("div",{className:Ue.menuBtn},s.createElement("button",{onClick:()=>{this.props.finishImportMesh()}},Object(E.e)("cancelOperation")),s.createElement("button",{className:[e>884736?Ue.disable:""].join(" "),onClick:()=>{this.applyVoxlization()}},Object(E.e)("voxelize"))))}}const Ge=i(1536);class We extends s.Component{constructor(e){super(e),this._virtualCorsorRef=s.createRef(),this._onLoadingStart=()=>{this.setState({isLoading:!0})},this._onLoadingFinished=()=>{this.setState({isLoading:!1})},this._onDialogContainerBlur=()=>{this.setState({blurOut:!0})},this._onDialogContainerClear=()=>{this.setState({blurOut:!1})},this._onresize=()=>{if(this._virtualCorsorRef.current){const e=this._virtualCorsorRef.current.getBoundingClientRect();e.x<=1?this._virtualCorsorRef.current.style.left="1px":e.x+e.width>=window.innerWidth-1&&(this._virtualCorsorRef.current.style.left=window.innerWidth-1-e.width+"px"),e.y<=1?this._virtualCorsorRef.current.style.top="1px":e.y+e.height>=window.innerHeight-1&&(this._virtualCorsorRef.current.style.top=window.innerHeight-1-e.height+"px")}},this.state={isPolishing:this.props.veState.pbrPreviewMode,blurOut:!1,importingMesh:!1,editToolOptType:F.EditingMode,isLoading:this.props.veState.projectLoading,virtualCursorEditEnable:!1,isTouchDevice:Object(Ae.f)(),showTouchUISwitch:!0,cursorDirection:0}}componentDidMount(){this.props.VERef.on(o.a.DIALOGPOPOUT,this._onDialogContainerBlur),this.props.VERef.on(o.a.DIALOGVANISH,this._onDialogContainerClear),this.props.VERef.on(o.a.PROJECTLOADINGSTART,this._onLoadingStart),this.props.VERef.on(o.a.PROJECTLOADINGFINISHED,this._onLoadingFinished),window.addEventListener("resize",this._onresize),document.body.style.overscrollBehavior="contain"}componentWillUnmount(){this.props.VERef.removeListener(o.a.DIALOGPOPOUT,this._onDialogContainerBlur),this.props.VERef.removeListener(o.a.DIALOGVANISH,this._onDialogContainerClear),this.props.VERef.removeListener(o.a.PROJECTLOADINGSTART,this._onLoadingStart),this.props.VERef.removeListener(o.a.PROJECTLOADINGFINISHED,this._onLoadingFinished),window.removeEventListener("resize",this._onresize),document.body.style.overscrollBehavior="initial"}shouldComponentUpdate(e,t){return this.state.blurOut!=t.blurOut||this.state.editToolOptType!=t.editToolOptType||this.state.importingMesh!=t.importingMesh||this.state.isPolishing!=t.isPolishing||this.state.isLoading!=t.isLoading||this.state.virtualCursorEditEnable!=t.virtualCursorEditEnable||this.state.showTouchUISwitch!=t.showTouchUISwitch||this.state.virtualCursorEditEnable!=t.virtualCursorEditEnable||this.state.isTouchDevice!=t.isTouchDevice||this.state.cursorDirection!=t.cursorDirection}togglePolishingProcess(e){this.setState({isPolishing:e}),e&&this.props.VERef.veController.preparePbrRendering()}renderSunAndGroundProperties(){if(void 0===this.props.VERef.pbrRenderer)return"";const e=this.props.VERef.pbrRenderer,t=e.getSun(),i=e.getGround();return s.createElement("div",{style:{position:"relative"}},s.createElement("div",{style:{width:"268px",zIndex:10,display:"inline-block",background:"rgba(0,0,0,0.7)",pointerEvents:"initial",padding:"5px"}},s.createElement("div",{style:{color:"orange",marginTop:"2px"}},"Sun :"),s.createElement(_,{tag:Object(E.e)("time"),minValue:5,maxValue:17,initValue:t.time,precision:2,onChange:t=>{e.setSun({time:t})}}),s.createElement(_,{tag:Object(E.e)("azimuth"),minValue:-10,maxValue:10,initValue:t.azimuth,precision:2,onChange:t=>{e.setSun({azimuth:t})}}),s.createElement(_,{tag:Object(E.e)("radius"),minValue:1,maxValue:20,initValue:t.radius,precision:1,onChange:t=>{e.setSun({radius:t})}}),s.createElement(_,{tag:Object(E.e)("intensity"),minValue:0,maxValue:2,initValue:t.intensity,precision:1,onChange:t=>{e.setSun({intensity:t})}}),s.createElement("div",{style:{color:"orange",marginTop:"2px"}},"Ground :"),s.createElement(_,{tag:Object(E.e)("color"),minValue:0,maxValue:1,initValue:i.color[0],precision:2,onChange:t=>{e.setGround({color:[t,t,t]})}}),s.createElement(_,{tag:Object(E.e)("metalness"),minValue:0,maxValue:1,initValue:i.metal,precision:2,onChange:t=>{e.setGround({metal:t})}}),s.createElement(_,{tag:Object(E.e)("roughness"),minValue:0,maxValue:1,initValue:i.rough,precision:2,onChange:t=>{e.setGround({rough:t})}}),s.createElement("div",{style:{color:"orange",marginTop:"2px"}},"Sample Setting :"),s.createElement(_,{tag:Object(E.e)("samples"),minValue:10,maxValue:2048,initValue:e.totalSamplesCount,precision:0,onChange:t=>{e.totalSamplesCount=t}})),s.createElement("div",{style:{height:"4px",position:"absolute",width:"100%",paddingLeft:"268px",top:0}},s.createElement("div",{id:"sampleProgress",style:{height:"100%",background:"rgb(2, 155, 204)",boxShadow:"rgb(0, 200, 239) 0px 1px 5px"}})))}renderEditorUI(){return s.createElement("div",{style:{height:"100%",width:"100%",pointerEvents:"none",position:"relative"}},s.createElement(De,{VERef:this.props.VERef,blurOut:this.state.blurOut,voxelEditorClient:this.props.voxelEditorClient,importingMesh:this.state.importingMesh,startImportMesh:()=>{this.setState({importingMesh:!0}),this.props.veState.previewMeshMode=!0,this.props.mainCamera.setPosition([0,0,0])},togglePolishingProcess:this.togglePolishingProcess.bind(this),onClose:this.props.onClose,veState:this.props.veState,isTouchDevice:this.state.isTouchDevice}),this.state.isPolishing?this.renderSunAndGroundProperties():"",this.state.isPolishing?"":s.createElement(Be,{importingMesh:this.state.importingMesh,onToolChange:e=>{this.setState({editToolOptType:e})},VERef:this.props.VERef,blurOut:this.state.blurOut,veState:this.props.veState,isTouchDevice:this.state.isTouchDevice}),this.state.isPolishing?"":s.createElement(U,{veState:this.props.veState,VERef:this.props.VERef,importingMesh:this.state.importingMesh,blurOut:this.state.blurOut,isTouchDevice:this.state.isTouchDevice}),this.state.isPolishing?"":s.createElement(ye,{importingMesh:this.state.importingMesh,blurOut:this.state.blurOut,veState:this.props.veState,VERef:this.props.VERef,isTouchDevice:this.state.isTouchDevice,cursorDirection:this.state.cursorDirection,setCursorDirection:e=>{this.setState({cursorDirection:e})}}),this.state.isPolishing?"":s.createElement(W,{importingMesh:this.state.importingMesh,blurOut:this.state.blurOut,veState:this.props.veState,VERef:this.props.VERef,isTouchDevice:this.state.isTouchDevice}),this.state.importingMesh?s.createElement(Fe,{VERef:this.props.VERef,finishImportMesh:()=>{this.props.VERef.previewMesh.clearAllMesh(),this.props.VERef.resetCameraPosition(),this.setState({importingMesh:!1}),this.props.veState.previewMeshMode=!1}}):null)}renderVirtualCursor(){return s.createElement("div",{className:[Ge.virtualCursor,0===this.state.cursorDirection?Ge.left:Ge.right].join(" "),id:"voxelEditor-cursor",ref:this._virtualCorsorRef,style:{top:window.innerHeight/2+"px",left:window.innerWidth/2+"px"}},s.createElement("div",{className:Ge.cursorInnerWrapper},s.createElement("div",{className:Ge.cursorPointer,id:"voxelEditor-cursorPointer"}),s.createElement("div",{className:Ge.cursorLine}),s.createElement("div",{className:Ge.cursorDragger,id:"voxelEditor-cursorDragger"}),s.createElement("div",{className:[Ge.cursorEditLock,this.state.virtualCursorEditEnable?Ge.enabel:""].join(" "),id:"voxelEditor-cursorEditLock",onClick:()=>{this.setState({virtualCursorEditEnable:!this.state.virtualCursorEditEnable},()=>{this.props.VERef.veController.virtualCursorEditLock=!this.state.virtualCursorEditEnable})}})))}renderToggleTouchUISwitch(){return s.createElement("div",{className:Ge.EnableTouchSwitch,onTouchStart:()=>{this.setState({isTouchDevice:!0})},onMouseDown:e=>{2===e.button&&this.setState({isTouchDevice:!1,showTouchUISwitch:!1})}},s.createElement("div",{className:Ge.switchButton},Object(E.e)("TouchDevice?")),s.createElement("div",{className:Ge.mouseDeviceHint},Object(E.e)("HintRemoveText")))}render(){return s.createElement("div",{id:"voxel-editor",className:Ge.voxelEditor,style:{boxSizing:"border-box"}},this.renderEditorUI(),this.state.isTouchDevice?this.renderVirtualCursor():null,!this.state.isTouchDevice&&this.state.showTouchUISwitch?this.renderToggleTouchUISwitch():null,s.createElement(be,{veState:this.props.veState,VERef:this.props.VERef,voxelEditorClient:this.props.voxelEditorClient,onHandleLogin:this.props.onHandleLogin,isTouchDevice:this.state.isTouchDevice}),this.state.isLoading?s.createElement("div",{className:Ge.loadingWrapper},s.createElement(Le.a,null)):null)}}},1604:function(e,t,i){"use strict";var s=i(3),o=i(77),n=function(e,t){const i=Object(o.b)(e);return e({blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:1},equation:{rgb:"add",alpha:"add"},color:[1,1,1,1]},depth:{enable:!0,mask:!1,func:"<="},cull:{enable:!0,face:"back"},uniforms:{workspaceSize:i("workspaceSize").prop,model:i("model").prop,alpha:i("alpha").prop,inflate:i("inflate").prop,checkerBoard:i("checkerBoard").prop,"Lightness[0]":.6,"Lightness[1]":.7,"Lightness[2]":.75,"Lightness[3]":1,"Lightness[4]":.5,"Lightness[5]":.4,"Lightness[6]":.1},attributes:{position:{buffer:i("positions").prop},normal:{buffer:i("normals").prop},color:i("colors").prop},elements:i("elements").prop,frag:"\n precision highp float;\n\n uniform float alpha;\n uniform float maxLightDistance;\n uniform vec3 eye;\n uniform vec3 workspaceSize;\n uniform bool checkerBoard;\n\n varying vec3 vNormal;\n varying vec3 pos;\n varying vec3 vColor;\n varying float distance;\n uniform float Lightness[7];\n\n float PI_2 = 3.14159/2.0;\n float PI_3 = 3.14159/3.0;\n\n float line(in vec3 a, in vec3 b, in vec3 p ) {\n float lenAB = length(a - b);\n float lenPA = length(p - a);\n float lenPB = length(p - b);\n return abs(lenAB - (lenPA + lenPB)) * (1.0 - abs(lenPA - lenPB)/lenAB);\n\n vec3 pa = -p - a;\n vec3 ba = b - a;\n float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n float d = length( length(pa) - length(ba)*h );\n return d;\n // return clamp(((1.0 - d)-0.99)*100.0, 0.0, 1.0);\n }\n\n void main() {\n vec3 color = vColor;\n if (vNormal.x < -0.5) {\n color *= Lightness[0];\n } else if (vNormal.x > 0.5) {\n color *= Lightness[1];\n } else if (vNormal.y < -0.5) {\n color *= Lightness[2];\n } else if (vNormal.y > 0.5) {\n color *= Lightness[3];\n } else if (vNormal.z < -0.5) {\n color *= Lightness[4];\n } else if (vNormal.z > 0.5) {\n color *= Lightness[5];\n }\n color = mix(color, vColor, 0.6);\n float grid = 0.;\n\n float threashod = 0.03 * 0.025 * length(eye - pos);\n if ((pos.x < threashod || (workspaceSize.x-pos.x) < threashod) && ( abs(vNormal.z) == 1.0|| abs(vNormal.y) == 1.0) ) {\n gl_FragColor = vec4(1,1,1,1);\n return;\n }\n if ((pos.z < threashod || (workspaceSize.z-pos.z) < threashod) && ( abs(vNormal.x) == 1.0|| abs(vNormal.y) == 1.0) ) {\n gl_FragColor = vec4(1,1,1,1);\n return;\n }\n if ((pos.y < threashod || (workspaceSize.y-pos.y) < threashod) && ( abs(vNormal.z) == 1.0|| abs(vNormal.x) == 1.0) ) {\n gl_FragColor = vec4(1,1,1,1);\n return;\n }\n\n if (checkerBoard) {\n float gridThreashod = 0.02 * 0.025 * length(eye - pos);\n if (vNormal.x != 0.0) {\n float g = (1.0 - pow(abs(sin(pos.y * PI_3 * 3.0) * cos((pos.z * PI_3 - PI_2) * 3.0)), 0.06125));\n g += (1.0 - pow(abs(sin(pos.y * PI_3) * cos((pos.z * PI_3 - PI_2))), 0.06125));\n color += g * vec3(1);\n gl_FragColor = vec4(color, alpha);\n return;\n }\n\n if (vNormal.y != 0.0) {\n float g = (1.0 - pow(abs(sin(pos.x * PI_3 * 3.0) * cos((pos.z * PI_3 - PI_2) * 3.0)), 0.06125));\n g += (1.0 - pow(abs(sin(pos.x * PI_3) * cos((pos.z * PI_3 - PI_2))), 0.06125));\n color += g * vec3(1);\n gl_FragColor = vec4(color, alpha);\n return;\n }\n\n if (vNormal.z != 0.0) {\n float g = (1.0 - pow(abs(sin(pos.x * PI_3 * 3.0) * cos((pos.y * PI_3 - PI_2) * 3.0)), 0.06125));\n g += (1.0 - pow(abs(sin(pos.x * PI_3) * cos((pos.y * PI_3 - PI_2))), 0.06125));\n color += g * vec3(1);\n gl_FragColor = vec4(color, alpha);\n return;\n }\n }\n if (grid == 0.) {\n gl_FragColor = vec4(color, alpha);\n }\n }\n ",vert:"\n precision highp float;\n\n attribute vec3 position, normal, color;\n varying vec3 vNormal;\n varying vec3 vColor;\n varying vec3 pos;\n uniform mat4 projection, view, model;\n uniform bool inflate;\n\n void main() {\n vNormal = normal;\n pos = position;\n vec4 worldSpacePosition;\n if (inflate) {\n worldSpacePosition = vec4(position + vNormal*0.008 , 1);\n } else {\n worldSpacePosition = vec4(position - vNormal*0.003 , 1);\n }\n gl_Position = projection * view * model * worldSpacePosition;\n vColor = color;//vec3(0.3843137254901961, 0.43529411764705883, 0.48627450980392156);\n }\n "})},r=function(e,t){const i=e({blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:1},equation:{rgb:"add",alpha:"add"},color:[0,0,0,0]},frag:"\n precision mediump float;\n uniform vec3 color;\n uniform float alpha;\n void main() {\n gl_FragColor = vec4(color, alpha);\n }\n ",vert:"\n precision mediump float;\n attribute vec3 position;\n uniform mat4 projection, view;\n void main() {\n gl_Position = projection * view * vec4(position, 1);\n gl_PointSize = 3.0;\n }\n ",attributes:{position:e.prop("position")},uniforms:{alpha:e.prop("alpha"),color:e.prop("color")},lineWidth:1,count:e.prop("count"),primitive:e.prop("primitive")});e({frag:"\n precision mediump float;\n uniform vec3 color;\n void main() {\n gl_FragColor = vec4(color, 1.0);\n }\n ",vert:"\n attribute vec2 position;\n uniform mat4 projection, view;\n uniform mat4 model;\n void main() {\n gl_Position = projection * view * model * vec4(position, 0, 1);\n }\n ",depth:{enable:!1},attributes:{position:e.prop("position")},uniforms:{color:e.prop("color"),model:e.prop("model")},elements:e.prop("edges")});return function(e){i(e.lines)}},a=function(e){return e({depth:{enable:!1},frag:"\n precision mediump float;\n uniform vec3 color;\n void main() {\n gl_FragColor = vec4(color, 1);\n }",vert:"\n precision mediump float;\n uniform mat4 projection, view;\n attribute vec3 position;\n void main() {\n gl_Position = projection * view * vec4(position, 1);\n }",uniforms:{color:[1,0,0]},attributes:{position:e.prop("positions")},elements:e.prop("elements")})},l=function(e){return e({frag:"\n precision mediump float;\n uniform vec3 eye;\n uniform float alpha;\n struct Light {\n vec3 color;\n vec3 position;\n };\n\n uniform Light lights[2];\n varying vec3 fragNormal, fragPosition;\n void main() {\n vec3 normal = fragNormal;\n vec3 light = vec3(0.2, 0.2, 0.2);\n for (int i=0; i<2; i++) {\n vec3 lightDir = normalize(lights[i].position - fragPosition);\n float diffuse = max(0.0, dot(lightDir, normal));\n light += diffuse * lights[i].color;\n }\n gl_FragColor = vec4(light, alpha);\n }\n ",vert:"\n precision mediump float;\n attribute vec3 position, normal;\n uniform mat4 view, projection;\n varying vec3 fragNormal, fragPosition;\n uniform mat4 model;\n uniform mat3 normalMat;\n void main() {\n vec4 modelPos = model * vec4(position, 1);\n\n fragNormal = normalize(normalMat * normal);\n fragPosition = modelPos.xyz;\n gl_Position = projection * view * modelPos;\n }\n ",blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:1},equation:{rgb:"add",alpha:"add"},color:[1,1,1,1]},depth:{enable:!0,mask:!0,func:"<="},cull:{enable:!1},elements:e.prop("elements"),attributes:{position:e.prop("position"),normal:e.prop("normal")},uniforms:{model:e.prop("model"),normalMat:e.prop("normalMat"),alpha:e.prop("opacity"),"lights[0].color":[.7,.7,.7],"lights[1].color":[.9,.9,.9],"lights[0].position":[90,120,90],"lights[1].position":[-90,100,-90]}})},h=function(e,t){const i=e.prop;return e({blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:1},equation:{rgb:"add",alpha:"add"},color:[0,0,0,0]},depth:{enable:!0,mask:!0,func:"<="},cull:{enable:!0,face:"back"},uniforms:{tick:e=>e.tick,model:i("model"),alpha:i("alpha"),inflate:i("inflate"),picked:i("picked"),checkerBoard:i("checkerBoard"),"Lightness[0]":.6,"Lightness[1]":.7,"Lightness[2]":.75,"Lightness[3]":1,"Lightness[4]":.5,"Lightness[5]":.4,"Lightness[6]":.1},attributes:{position:{buffer:i("positions")},normal:{buffer:i("normals")},color:i("colors")},elements:i("elements"),frag:"\n precision mediump float;\n\n uniform float alpha, picked;\n uniform float maxLightDistance;\n uniform vec3 eye;\n uniform bool checkerBoard;\n\n varying vec3 vNormal;\n varying vec3 pos;\n varying vec3 vColor;\n varying float distance;\n uniform float Lightness[7], tick;\n void main() {\n vec3 color = vColor;\n if (vNormal.x < -0.5) {\n color *= Lightness[0];\n } else if (vNormal.x > 0.5) {\n color *= Lightness[1];\n } else if (vNormal.y < -0.5) {\n color *= Lightness[2];\n } else if (vNormal.y > 0.5) {\n color *= Lightness[3];\n } else if (vNormal.z < -0.5) {\n color *= Lightness[4];\n } else if (vNormal.z > 0.5) {\n color *= Lightness[5];\n }\n color = mix(color, vColor, 0.6) + vec3(0.5) * picked;\n\n if (checkerBoard) {\n if (abs(vNormal.z) == 1.0 ) {\n if ((mod(pos.x / 2.0, 1.0) < 0.5) ^^ (mod(pos.y / 2.0, 1.0) < 0.5) ) {\n gl_FragColor = vec4(color,1.0);\n } else {\n gl_FragColor = vec4(0.95 * color,1.0);\n }\n return;\n }\n if (abs(vNormal.x) == 1.0) {\n if ((mod(pos.z / 2.0, 1.0) < 0.5) ^^ (mod(pos.y / 2.0, 1.0) < 0.5) ) {\n gl_FragColor = vec4(color,1.0);\n } else {\n gl_FragColor = vec4(0.95 * color,1.0);\n }\n return;\n }\n if (abs(vNormal.y) == 1.0) {\n if ((mod(pos.x / 2.0, 1.0) < 0.5) ^^ (mod(pos.z / 2.0, 1.0) < 0.5) ) {\n gl_FragColor = vec4(color,1.0);\n } else {\n gl_FragColor = vec4(0.95 * color,1.0);\n }\n return;\n }\n }\n gl_FragColor = vec4(color, alpha + 0.3 * picked * (cos(tick / 10.) * 0.5 + 1.));\n }\n ",vert:"\n precision mediump float;\n\n attribute vec3 position, normal, color;\n varying vec3 vNormal;\n varying vec3 vColor;\n varying vec3 pos;\n\n uniform mat4 projection, view, model;\n uniform bool inflate;\n\n void main() {\n vNormal = normal;\n pos = position;\n\n vec4 worldSpacePosition;\n if (inflate) {\n worldSpacePosition = vec4(position + vNormal*0.008 , 1);\n } else {\n worldSpacePosition = vec4(position - vNormal*0.003 , 1);\n }\n gl_Position = projection * view * model * worldSpacePosition;\n vColor = color;//vec3(0.3843137254901961, 0.43529411764705883, 0.48627450980392156);\n }\n "})};var c=function(e,t){return e({vert:"\n// precision mediump float;\nprecision highp float;\nattribute vec2 position;\nuniform vec3 eye;\nuniform mat4 invProjection, invView;\nvarying vec3 Pos;\n\nvoid main () {\n vec4 near = invView * invProjection * vec4(position, 0, 1);\n vec4 far = invView * invProjection * vec4(position, 1, 1);\n vec3 direction = normalize(near.w * far.xyz - far.w * near.xyz);\n Pos = eye + direction;\n gl_Position = vec4(position, 0.9999, 1);\n}\n",frag:"\n// precision mediump float;\nprecision highp float;\nuniform float width, height;\nuniform vec3 ColorA, ColorB;// Amp, Freq, Phase ,DCOffset;\nuniform vec3 eye;\nvarying vec3 Pos;\n\nvec2 resolution = vec2(width, height);\n\nfloat fogFactorExp(float dist, float density) {\n const float LOG2 = -1.442695;\n float d = density * dist;\n return 1.0 - clamp(exp2(d * d * LOG2), 0.0, 1.0);\n}\n\n// http://www.iquilezles.org/www/articles/palettes/palettes.htm\n// vec3 palette(float t, vec3 a, vec3 b, vec3 c, vec3 d) {\n// return a + b * cos( 6.28318 * (c * t + d) );\n// }\n\nfloat intersectPlane(vec3 ro, vec3 rd, vec3 nor, float dist) {\n // float denom = rd.y;\n float t = -(max(ro.y, 0.) + dist) / rd.y;\n return t;\n}\n\nvec3 bg(vec3 ro, vec3 rd) {\n float PI_2 = 3.14159/2.0;\n float PI_3 = 3.14159/3.0;\n float t = rd.y * 0.4 + 0.4;\n // vec3 grad = palette(t\n // , DCOffset\n // , Amp\n // , Freq\n // , Phase\n // );\n\n // vec3 a = vec3(64, 117, 140) / 255.0;\n vec3 grad = mix(ColorA, ColorB, abs(.5 + 0.5 *sin(rd.y * 3.1415/2.0)));\n\n float d = intersectPlane(ro, rd, vec3(0, 1, 0), 0.);\n if (d > 0.0) {\n vec3 p = ro + rd * d;\n float g = (1.0 - pow(abs(sin(p.x * PI_3) * cos(p.z * PI_3 - PI_2)), 0.06125));\n grad += (1.0 - fogFactorExp(d, 0.004)) * vec3(1.7) * g * 0.18;\n }\n return grad;\n}\n\nvoid main() {\n vec2 p = gl_FragCoord.xy / resolution.xy;\n vec3 rayDir = normalize(Pos - eye);\n vec3 color = bg(eye, rayDir);\n gl_FragColor = vec4(color, 1.0);\n}\n",attributes:{position:[-1,-1,1,-1,1,1,1,1,-1,1,-1,-1]},uniforms:{ColorA:e.prop("cA"),ColorB:e.prop("cB"),height:e.context("viewportHeight"),width:e.context("viewportWidth")},count:6})};var d=function(e){return e({frag:"\n precision mediump float;\n varying vec3 color, normal;\n varying float ao;\n void main() {\n float light = 0.3 * (max(dot(normal, vec3(1, 1, 1)), 0.) + ao);\n gl_FragColor = vec4(pow(light * color, vec3(1. / 2.2)), 1);\n }\n ",vert:"\n precision mediump float;\n attribute vec4 s0, s1;\n uniform mat4 projection, view, model;\n uniform vec3 offset;\n varying vec3 color;\n varying float ao;\n varying vec3 normal;\n void main() {\n float faceCode = s1.a;\n lowp float h0 = step(faceCode, 0.5);\n lowp float h1 = step(faceCode, 1.5);\n lowp float h2 = step(faceCode, 2.5);\n lowp float h3 = step(faceCode, 3.5);\n lowp float h4 = step(faceCode, 4.5);\n vec3 faceNormal = vec3(\n h1 - 2. * h0,\n h3 - 2. * h2 + h1,\n 1. - 2. * h4 + h3);\n normal = normalize(faceNormal);\n\n color = pow(s1.rgb / 255., vec3(2.2));\n ao = s0.a / 255.;\n gl_Position = projection * view * model * vec4(s0.xyz, 1);\n }\n ",attributes:{s0:e.prop("s0"),s1:e.prop("s1")},uniforms:{model:e.prop("model")},primitive:"triangles",count:e.prop("vertCount")})},p=Object.defineProperty,u=Object.defineProperties,f=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,b=(e,t,i)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,x=(e,t)=>{for(var i in t||(t={}))g.call(t,i)&&b(e,i,t[i]);if(m)for(var i of m(t))v.call(t,i)&&b(e,i,t[i]);return e},y=(e,t)=>u(e,f(t));t.a=function(e,t){const i=t.require(n),p=s.b.identity(s.b.create()),u=t.require(r),f=t.require(a),m=t.require(h),g=(t.require(d),t.require(l)),v=t.require(c),b=Object(o.b)(e),_=t.cache("main:setup",{context:{model:p,eye:b("camera")("eye").prop,cameraTarget:b("camera")("target").prop,view:b("camera")("view").prop,fixedView:b("camera")("fixedView").prop,projection:b("camera")("projection").prop,invView:b("camera")("invView").prop,invProjection:b("camera")("invProjection").prop},uniforms:{model:p,eye:b("camera")("eye").prop,cameraTarget:b("camera")("target").prop,view:b("camera")("view").prop,fixedView:b("camera")("fixedView").prop,projection:b("camera")("projection").prop,invView:b("camera")("invView").prop,invProjection:b("camera")("invProjection").prop,invViewProj:b("camera")("invViewProjection").prop}},!0);let E;return{renderFrame:function(t){E=t.veState,_(t,()=>{e.clear({color:[.361,.392,.424,1],depth:1}),E.pbrPreviewMode?t.pbrRenderer?(t.pbrRenderer.sample(1,t.pbrRenderer.totalSamplesCount),t.pbrRenderer.display()):console.error("renderer is not create yet"):(E.terrainMode||v({cA:E.bg.cA,cB:E.bg.cB}),t.destModel.tickUpdate(),t.editingModel.tickUpdate(),t.selectionModel.tickUpdate(),t.selectionModel.render(),t.destModel.render(),t.editingModel.renderTempGeo?m(y(x({},t.editingModel.temporarayGeoData),{model:s.b.create(),alpha:1,inflate:!1,checkerBoard:!1,picked:0})):t.editingModel.render(),t.triangleMesh&&t.triangleMesh.length&&g(t.triangleMesh),!1===t.veState.previewMeshMode&&t.boundaryBox.show&&(i(y(x({},t.boundaryBox),{workspaceSize:E.basicConfig.workspaceSize,model:s.b.create(),alpha:.5,inflate:!1,checkerBoard:E.viewConfig.boundaryCheckboard})),f(t.pointer)),t.boundaryBox.show&&u(t.axis))})}}}},1605:function(e,t,i){"use strict";i.d(t,"a",(function(){return d}));var s=i(3);var o=i(77);function n(e){const t=function(e,t,i,s,o,n){let r=0;const a=[],l=[],h=[],c=[];function d(e,t,i,s,o,n,d,p,u,f){const m=r;for(let c=0;c<=d;c++)for(let m=0;m<=n;m++){const g=a[r]=[0,0,0];g[e]=(-s/2+m*s/n)*u,g[t]=(-o/2+c*o/d)*f,g[i]=p;const v=l[r]=[0,0,0];v[e]=0,v[t]=0,v[i]=p/Math.abs(p);const b=h[r]=[0,0];b[0]=m/n,b[1]=1-c/d,++r}for(let e=0;e.001&&(a=o,n=a,"reglFramebufferCube"===h.name?(h.destroy(),h=l({sunDirection:s.e.normalize(s.e.create(),n),resolution:1024})):l({sunDirection:s.e.normalize(s.e.create(),n),envFBO:h}));for(let s=0;s255&&(this.x=0,this.y++,this.y>255))throw new Error("Exceeded voxel type limit of 65536");this.keys[t]=[this.x,this.y];const i=256*this.y+this.x;this.aRGB[3*i+0]=e.red,this.aRGB[3*i+1]=e.green,this.aRGB[3*i+2]=e.blue,this.aRMET[4*i+0]=e.rough,this.aRMET[4*i+1]=e.metal,this.aRMET[4*i+2]=e.emit,this.aRMET[4*i+3]=e.transparent,this.aRi[i]=e.refract}return this.keys[t]}}class h{constructor(e,t,i,s){this.data={},this.vIndex=new l,this.textureSize=0,this.regl=e,this.width=t,this.height=i,this.depth=s,this.tIndex=e.texture(),this.tRGB=e.texture(),this.tRMET=e.texture(),this.tRi=e.texture()}getWidth(){return this.width}getHeight(){return this.height}getDepth(){return this.depth}key(e,t,i){return`${e} ${t} ${i}`}set(e,t,i,{red:s=1,green:o=1,blue:n=1,rough:r=255,metal:a=0,emit:l=0,transparent:h=0,refract:c=1}={}){if(e<0||e>=this.width)throw new Error("Voxel: set out of bounds.");if(t<0||t>=this.height)throw new Error("Voxel: set out of bounds.");if(i<0||i>=this.depth)throw new Error("Voxel: set out of bounds.");this.data[this.key(e,t,i)]={x:e,y:t,z:i,red:Math.round(255*s),green:Math.round(255*o),blue:Math.round(255*n),rough:r,metal:a,emit:l,transparent:h,refract:c}}updateBounds(e,t,i){this.width=e,this.height=t,this.depth=i}unset(e,t,i){1!==Object.keys(this.data).length&&delete this.data[this.key(e,t,i)]}get(e,t,i){return this.data[this.key(e,t,i)]}clear(){this.vIndex.clear(),this.data={}}update(){this.textureSize=1;const e=this.width*this.height*this.depth;for(;this.textureSize*this.textureSize{this._renderDirty=!0});let a=0;window.addEventListener("resize",()=>{a=Date.now(),setTimeout(()=>{Date.now()-a>=500&&(this._renderDirty=!0)},500)})}getWidth(){return this.stage.getWidth()}getHeight(){return this.stage.getHeight()}getDepth(){return this.stage.getDepth()}updateBounds(e,t,i){this.stage.updateBounds(e,t,i),this._stageDirty=!1}set(e,t,i,s){this.stage.set(e,t,i,s),this._stageDirty=!0}unset(e,t,i){this.stage.unset(e,t,i),this._stageDirty=!0}get(e,t,i){return this.stage.get(e,t,i)}clear(){this.stage.clear(),this._stageDirty=!0}get sampleCount(){return this.renderer.sampleCount()}getGround(){return{color:this._ground.color,rough:this._ground.rough,metal:this._ground.metal}}setGround(e){void 0===e.color||s.e.equals(e.color,this._ground.color)||(this._ground.color[0]=e.color[0],this._ground.color[1]=e.color[1],this._ground.color[2]=e.color[2],this._renderDirty=!0),void 0!==e.rough&&e.rough!==this._ground.rough&&(this._ground.rough=e.rough,this._renderDirty=!0),void 0!==e.metal&&e.metal!==this._ground.metal&&(this._ground.metal=e.metal,this._renderDirty=!0)}getSun(){return{time:this._sun.time,azimuth:this._sun.azimuth,radius:this._sun.radius,intensity:this._sun.intensity}}setSun(e){void 0!==e.time&&e.time!==this._sun.time&&(this._sun.time=e.time,this._renderDirty=!0),void 0!==e.azimuth&&e.azimuth!==this._sun.azimuth&&(this._sun.azimuth=e.azimuth,this._renderDirty=!0),void 0!==e.radius&&e.radius!==this._sun.radius&&(this._sun.radius=e.radius,this._renderDirty=!0),void 0!==e.intensity&&e.intensity!==this._sun.intensity&&(this._sun.intensity=e.intensity,this._renderDirty=!0)}setDof(e,t){this._dof.distance===e&&this._dof.magnitude===t||(this._dof.distance=e,this._dof.magnitude=t,this._renderDirty=!0)}sample(e,t=1/0){this.oldCanvasSize[0]!==this._canvas.offsetWidth&&this.oldCanvasSize[1]!==this._canvas.offsetHeight&&(this.oldCanvasSize=[this._canvas.offsetWidth,this._canvas.offsetHeight],this._renderDirty=!0),this._stageDirty&&(this.stage.update(),this._renderDirty=!0,this._stageDirty=!1),this._renderDirty&&(this.renderer.reset(),this._renderDirty=!1),this.sampleCount(e[e.Idle=0]="Idle",e[e.MovingCamera=1]="MovingCamera",e[e.EditingVoxel=2]="EditingVoxel",e[e.DragingModel=3]="DragingModel",e[e.PickingChunk=4]="PickingChunk",e[e.ImportingMesh=5]="ImportingMesh",e))(s||{});let o=0;function n(){return o}function r(e){o=e}var a=(e=>(e[e.Idle=0]="Idle",e[e.Activate=1]="Activate",e[e.Ready=2]="Ready",e[e.Start=3]="Start",e[e.End=4]="End",e))(a||{});let l=0;function h(){return l}function c(e){l=e}var d=i(1379),p=i(3),u=i(129),f=i(128);function m(e,t,i,s,o,n,r){const a=new u.a;a.hitVoxel=[-1,-1,-1],Object(u.b)(a,f.b.identity,s,e,t,500);const l=a.hitNormal,h=a.hitPosition,c=a.hitVoxel;for(let e=0;e<3;e++)if(0==l[e]&&h[e]==s.shape[e]&&c[e]==h[e]-1){a.hitNormal[e]=1;break}if(a&&-1!==a.hitVoxel[0]){const e=s.getVoxel(a.hitVoxel[0],a.hitVoxel[1],a.hitVoxel[2]);return null!=r&&r.update(a.hitPosition,a.hitVoxel,a.hitNormal,!1),e>0&&1==n?[a.hitVoxel[0]+a.hitNormal[0],a.hitVoxel[1]+a.hitNormal[1],a.hitVoxel[2]+a.hitNormal[2]]:a.hitVoxel}for(let i=0;i=0)continue;const a=[o.positions[n[0]],o.positions[n[1]],o.positions[n[2]]],l=p.e.create(),h=p.e.create();if(null!==v(l,e,t,a,[[0,0,0],s.shape])){for(let e=0;ec)return null;p.e.cross(h,a,n);const u=p.e.dot(i,h);if(u<0||d+u>c)return null;const f=p.e.dot(r,h)/c;return o?(e[0]=g(t[0]+f*i[0],o[0][0],o[1][0]-1),e[1]=g(t[1]+f*i[1],o[0][1],o[1][1]-1),e[2]=g(t[2]+f*i[2],o[0][2],o[1][2]-1)):(e[0]=t[0]+f*i[0],e[1]=t[1]+f*i[1],e[2]=t[2]+f*i[2]),f}function b(e,t,i,s,o){for(let i=0;i=0)continue;const a=[s.positions[r[0]],s.positions[r[1]],s.positions[r[2]]],l=p.e.create(),h=[0,0,0];if(null!==v(l,e,t,a,o)){for(let e=0;e128?1:t<128?2:t>128?3:i<128?4:i>128?5:0}i(1387),i(220);var P=i(66);const k=[[-1,1,1],[-1,1,-1],[-1,-1,-1],[-1,1,1],[-1,-1,-1],[-1,-1,1],[1,0,0],[-1,1,1],[-1,-1,1],[1,0,0],[-1,1,-1],[-1,1,1],[1,0,0],[-1,-1,1],[-1,-1,-1],[1,0,0],[-1,-1,-1],[-1,1,-1]],R=[[.8,0,0],[.8,0,0],[.8,0,0],[.8,0,0],[.8,0,0],[.8,0,0],[.7,0,0],[.7,0,0],[.7,0,0],[.85,0,0],[.85,0,0],[.85,0,0],[.75,0,0],[.75,0,0],[.75,0,0],[.9,0,0],[.9,0,0],[.9,0,0]],I=[[-1,-1,1],[-1,-1,-1],[1,-1,-1],[-1,-1,1],[1,-1,-1],[1,-1,1],[0,1,0],[-1,-1,1],[1,-1,1],[0,1,0],[-1,-1,-1],[-1,-1,1],[0,1,0],[1,-1,1],[1,-1,-1],[0,1,0],[1,-1,-1],[-1,-1,-1]],O=[[0,.8,0],[0,.8,0],[0,.8,0],[0,.8,0],[0,.8,0],[0,.8,0],[0,.7,0],[0,.7,0],[0,.7,0],[0,.85,0],[0,.85,0],[0,.85,0],[0,.75,0],[0,.75,0],[0,.75,0],[0,.9,0],[0,.9,0],[0,.9,0]],j=[[-1,-1,-1],[-1,1,-1],[1,-1,-1],[-1,1,-1],[1,1,-1],[1,-1,-1],[0,0,1],[-1,1,-1],[-1,-1,-1],[0,0,1],[1,1,-1],[-1,1,-1],[0,0,1],[-1,-1,-1],[1,-1,-1],[0,0,1],[1,-1,-1],[1,1,-1]],T=[[0,0,.8],[0,0,.8],[0,0,.8],[0,0,.8],[0,0,.8],[0,0,.8],[0,0,.7],[0,0,.7],[0,0,.7],[0,0,.85],[0,0,.85],[0,0,.85],[0,0,.75],[0,0,.75],[0,0,.75],[0,0,.9],[0,0,.9],[0,0,.9]];class N{constructor(e,t,i,s,o){this.label=e,this.position=t,this.color=i,this.shift=s,this.targetPos=[0,0,0],this.count=this.position.length,this.hover=0,this.scale=[1,1,1]}}class D{constructor(){this.x_arrow=new N("x",k,R,[50,0,0],[10,20,10]),this.y_arrow=new N("y",I,O,[0,50,0],[10,20,10]),this.z_arrow=new N("z",j,T,[0,0,50],[10,20,10]),this.x_arrow.scale=[15,3,3],this.y_arrow.scale=[3,15,3],this.z_arrow.scale=[3,3,15]}updateSize(e){e=Math.max(e,1);const t=Math.sqrt(e/250);this.x_arrow.scale=[15,3,3].map(e=>e*t),this.y_arrow.scale=[3,15,3].map(e=>e*t),this.z_arrow.scale=[3,3,15].map(e=>e*t)}getArrow(){return[this.x_arrow,this.y_arrow,this.z_arrow]}updateArrowPosition(e){this.x_arrow.targetPos=e,this.y_arrow.targetPos=e,this.z_arrow.targetPos=e}translateArrow(e){for(let t=0;t<3;t++)this.x_arrow.shift[t]+=e[t],this.y_arrow.shift[t]+=e[t],this.z_arrow.shift[t]+=e[t]}pickArrow(e,t,i){const s=p.e.len(p.e.sub(p.e.create(),i,this.x_arrow.targetPos));let o,n,r,a=1/0,l=-1;const h=[this.x_arrow,this.y_arrow,this.z_arrow],c=Math.min(1,Math.max(s/250,.2));for(let i=0;i=0&&(h[l].hover=1),{arrow:o,hitPos:n,normal:r}}}class V{constructor(e,[t,i,s],o,n){this.voxels=void 0,this.mesh=void 0,this.alpha=.5,this.inflate=!1,this.wireframeColor=[0,0,0],this.count=0,this.model=p.b.create(),this.faceLightness=[.6,.7,.75,1,.5,.4,.1],this.shift=[0,0,0],this._deltaShift=[0,0,0],this.showMesh=!0,this.showBoundBox=!1,this.boundBox={positions:[],elements:[],normals:[],colors:[],alpha:.2,picked:0},this.voxels=e,this.index=[t,i,s],this.chunkId=n,p.b.translate(this.model,this.model,this.index.map((e,t)=>e*o[t]+10*e)),this.shift=this.index.map((e,t)=>e*o[t]+10*e),this._transition_clock=0,this._start_transtion=!1,this.updateBoundBoxSize(o);const r=Object(w.s)("555555").map(e=>e/255);for(let e=0;eMath.round(e)))}}bakeMesh(){this.mesh=function(e){const t=e.shape[0]+3,i=e.shape[1]+3,s=e.shape[2]+3;if(z){if(z.shape[0]!=t||z.shape[1]!=i||z.shape[2]!=s){Object(P.c)(z.data);const e=Object(P.a)(2*t*i*s);z=S()(new Uint16Array(e),[t,i,s])}}else{const e=Object(P.a)(2*t*i*s);z=S()(new Uint16Array(e),[t,i,s])}for(let e=0;e=0)continue;const o=[this.boundBox.positions[s[0]].map((e,t)=>e+this.shift[t]),this.boundBox.positions[s[1]].map((e,t)=>e+this.shift[t]),this.boundBox.positions[s[2]].map((e,t)=>e+this.shift[t])],n=p.e.create();if(null!==v(n,e,t,o))return p.e.distance(e,n)}return-1}hardCoreTranslate(e){this.shift=[this.shift[0]+e[0],this.shift[1]+e[1],this.shift[2]+e[2]],p.b.translate(this.model,this.model,e),this.arrowHelper.updateArrowPosition(this.shift.map((e,t)=>e+this.voxels.shape[t]/2)),this.shift=this.shift.map(e=>Math.round(e))}}const B=new V(void 0,[0,0,0],[32,32,32],-1),A=new class{constructor(){this.voxels=void 0,this.chunks=[]}setVoxlels(e){this.chunks=[];const[t,i,s]=e.shape;this.voxels=e;const o=Math.ceil(t/64),n=Math.ceil(i/64),r=Math.ceil(s/64);let a=0;for(let e=0;e-10*e);this.chunks[e].startTranslateTransition(t),this.chunks[e].alpha=1}}splitMesh(){for(let e=0;e10*e);this.chunks[e].startTranslateTransition(t),this.chunks[e].alpha=.5}}pickChunk(e,t,i){let s=1/0,o=-1;for(let n=0;ni){const e=t;t=i,i=e}return F(U(e,t),i)}function Q(e,t,i){const s=K(.5+.5*(t-e)/i,0,1);return function(e,t,i){return i=U(0,i),e*(1-(i=F(1,i)))+t*i}(t,e,s)-i*s*(1-s)}function J(e,t,i){const s=q(-i*e)+q(-i*t);return-Z(s)/i}function $(e){return e=[(e=[(e=[e[0]*e[0],e[1]*e[1]])[0]*e[0],e[1]*e[1]])[0]*e[0],e[1]*e[1]],X(e[0]+e[1],1/8)}function ee(e,t){const i=G(t),s=W(t),o=[0,0,0];return o[0]=e[0],o[1]=s*e[1]-i*e[2],o[2]=i*e[1]+s*e[2],o}function te(e,t,i){const s=[H(e[0])-t[0],H(e[1])-t[1],H(e[2])-t[2]];return F(U(s[0],U(s[1],s[2])),0)+p.e.len([U(s[0],0),U(s[1],0),U(s[2],0)])-i}function ie(e,t){const i=[p.d.len([e[0],e[2]]),e[1]],s=-i[1]-t[2],o=U(p.d.dot(i,[t[0],t[1]]),i[1]);return p.d.len([U(s,0),U(o,0)])+F(U(s,o),0)}function se(e,t){const i=p.e.len([e[0]/t[0],e[1]/t[1],e[2]/t[2]]);return i*(i-1)/p.e.len([e[0]/(t[0]*t[0]),e[1]/(t[1]*t[1]),e[2]/(t[2]*t[2])])}function oe(e,t){const i=[p.d.len([e[0],e[2]])-t[0],e[1]];return p.d.len(i)-t[1]}function ne(e,t){const i=[$([e[0],e[2]])-t[0],e[1]];return $(i)-t[1]}function re(e,t){const i=function(e,t){const i=[H(e[0])-t[0],H(e[1])-t[1],H(e[2])-t[2]];return F(U(i[0],U(i[1],i[2])),0)+p.e.len([U(i[0],0),U(i[1],0),U(i[2],0)])}([e[0],e[1]+2*t[2],e[2]],[2*t[2],2*t[2],2*t[2]]);let s=0;s=U(s,H(p.e.dot(e,[-t[0],t[1],0]))),s=U(s,H(p.e.dot(e,[t[0],t[1],0]))),s=U(s,H(p.e.dot(e,[0,t[1],t[0]]))),s=U(s,H(p.e.dot(e,[0,t[1],-t[0]])));const o=s-t[2];return U(-i,o)}function ae(e,t){const i=[H(e[0]),H(e[1]),H(e[2])];return U(i[2]-t[1],U(.866025*i[0]+.5*i[1],i[1])-t[0])}function le(e,t){const i=[H(e[0]),H(e[1]),H(e[2])];return U(i[2]-t[1],U(.866025*i[0]+.5*e[1],-e[1])-.5*t[0])}function he(e){const t=[e[0],e[1],e[2]];e[1]+=.2*G(1.6*e[1]),e[2]-=.05*e[0];const i=oe(ee([e[0]-.4,e[1],e[2]],1.57),[.3,.1]);e[2]=t[2],e[2]+=.05*e[0];const s=oe(ee([e[0]+.4,e[1],e[2]],1.57),[.3,.1]);e[0]+=G(e[0]);const o=oe([e[0],e[1]+.45,e[2]+.19],[.2,.05]);e[0]=t[0],e[1]=t[1],e[2]=t[2],e[0]+=G(.07*e[0]),e[0]*=W(.6*e[1]+1.1*H(.2*W(3.7+e[1])));let n=p.e.length([e[0],e[1]-.14,e[2]-.79])-.98;e[0]=t[0],e[1]=t[1],e[2]=t[2],e[1]+=.3*G(1.7*e[1]);let r=p.e.length([e[0]-.4,e[1],e[2]+.1])-.25;n=U(n,-r),r=p.e.length([e[0]+.4,e[1],e[2]+.1])-.25,n=U(n,-r),e[0]=t[0],e[1]=t[1],e[2]=t[2],e[2]+=e[2]-.4*e[1];const a=te([e[0],e[1]+.68,e[2]-.7],[.02,.07,.8],.27);let l=Q(i,s,.5);return l=J(l,o,14),l=Q(l,n,.09),J(l,a,12)}function ce(e){const t=[e[0],e[1],e[2]];let i=[t[1],2];t[1]-=15,t[0]*=.8,t[1]*=.9,t[2]*=.8,t[1]-=1.5;const s=H(t[0]);let o=t[1],n=t[2];o=4+1.2*o-s*Y(U((20-s)/15,0)),n*=2-o/15;const r=Y(s*s+o*o+n*n)-15;return r{e.preventDefault();const t=e.touches[0].clientX-this.pointerDownPos.x,i=e.touches[0].clientY-this.pointerDownPos.y,s=e.touches[0].clientX-this.prevCurosrPos.x,o=e.touches[0].clientY-this.prevCurosrPos.y,n=this.virtualCursorElement.getBoundingClientRect();n.x<=1&&s<=0?this.virtualCursorElement.style.left="1px":n.x+n.width>=window.innerWidth-1&&t>=0?this.virtualCursorElement.style.left=window.innerWidth-1-n.width+"px":this.virtualCursorElement.style.left=this.virtualCurosorPos.x+t+"px",n.y<=1&&o<=0?this.virtualCursorElement.style.top="1px":n.y+n.height>=window.innerHeight-1&&i>=0?this.virtualCursorElement.style.top=window.innerHeight-1-n.height+"px":this.virtualCursorElement.style.top=this.virtualCurosorPos.y+i+"px";const r=this.virtualCursorPointer.getBoundingClientRect(),a={clientX:Math.ceil(r.x),clientY:Math.ceil(r.y),button:0,target:this.voxel_editor_ele};this.onmousemove(a),this.prevCurosrPos.x=e.touches[0].clientX,this.prevCurosrPos.y=e.touches[0].clientY,e.stopPropagation()},this.onTouchEnd=e=>{e.preventDefault(),document.body.removeEventListener("touchmove",this.onTouchMove),document.body.removeEventListener("touchend",this.onTouchEnd);const t=this.virtualCursorElement.getBoundingClientRect();t.x<=1?this.virtualCursorElement.style.left="1px":t.x+t.width>=window.innerWidth-1&&(this.virtualCursorElement.style.left=window.innerWidth-1-t.width+"px"),t.y<=1?this.virtualCursorElement.style.top="1px":t.y+t.height>=window.innerHeight-1&&(this.virtualCursorElement.style.top=window.innerHeight-1-t.height+"px");const i=this.virtualCursorPointer.getBoundingClientRect(),s={clientX:Math.ceil(i.x),clientY:Math.ceil(i.y),button:0,target:this.voxel_editor_ele};this.onmouseup(s),this.camera.rotateLock=!1,e.stopPropagation()},this.virtualCurosorPos={x:0,y:0},this.prevCurosrPos={x:0,y:0},this.pointerDownPos={x:0,y:0},this.ontouchStart=e=>{if(e.target.id&&"voxelEditor-cursorDragger"===e.target.id){e.preventDefault(),e.stopPropagation();const t=document.getElementById("voxelEditor-cursor"),i=document.getElementById("voxelEditor-cursorPointer");if(t&&i){this.virtualCursorElement=t,window.VECursor=t,this.virtualCursorPointer=i;const s=t.getBoundingClientRect();this.virtualCurosorPos.x=s.x,this.virtualCurosorPos.y=s.y,this.pointerDownPos.x=e.touches[0].clientX,this.pointerDownPos.y=e.touches[0].clientY,this.prevCurosrPos.x=this.pointerDownPos.x,this.prevCurosrPos.y=this.pointerDownPos.y,this.registerTouchEvent();const o=i.getBoundingClientRect(),n={clientX:Math.ceil(o.x),clientY:Math.ceil(o.y),button:0,target:this.voxel_editor_ele};!1===this.virtualCursorEditLock&&this.onmousedown(n)}}},this.camera=e.camera,this.canvas=e.canvas,this.veState=e.veState,this.voxel_editor_ele=document.getElementById("voxel-editor"),this.boundaryBox=e.boundaryBox,this.pointer=e.pointer,this.destModel=e.destModel,this.editingModel=e.editingModel,this.selectionModel=e.selectionModel,this.paletteManager=e.paletteManager,this.editor=e.editor,this.onmousedown=this.onmousedown.bind(this),this.onmousemove=this.onmousemove.bind(this),this.onmouseup=this.onmouseup.bind(this),this.onkeydown=this.onkeydown.bind(this),this.onkeyup=this.onkeyup.bind(this)}toggleWireframe(){this.destModel.showGrid(this.veState.viewConfig.blockWireframe),this.editingModel.showGrid(this.veState.viewConfig.blockWireframe)}clearAllModels(){this.destModel.clearVoxel(),this.selectionModel.clearVoxel(),this.editingModel.clearVoxel()}updateSelectSpace(e,t){const{start:i,end:s}=Object(w.i)(e,t,[0,0,0],this.destModel.voxels.shape);-1==this._selectSpace.start[0]?(this._selectSpace.start=i,this._selectSpace.end=s):(this._selectSpace.start=Object(w.t)(i,this._selectSpace.start,Math.min),this._selectSpace.end=Object(w.t)(s,this._selectSpace.end,Math.max))}getCameraMoveSurface(){return this.cameraMoveSurface}shiftingViewPort(e,t,i){if(0==i){this.tempInvVp=p.b.clone(this.camera.invViewProjection),p.e.transformMat4(this.rayPoint,[2*e/this.canvas.width-1,-2*t/this.canvas.height+1,0],this.tempInvVp),p.e.transformMat4(this.rayOrigin,[0,0,0],p.b.invert(p.b.create(),this.camera.view)),p.e.normalize(this.rayDir,p.e.subtract(p.e.create(),this.rayPoint,this.rayOrigin));const i=Object(d.c)(this.camera);this.cameraMoveSurface=[],this.cameraMoveSurface[0]=[i[0],i[1],i[2]],this.cameraMoveSurface[1]=[i[0],i[2],i[3]];for(let e=0;e<2;e++){const t=p.e.create();if(null!==v(t,this.rayOrigin,this.rayDir,this.cameraMoveSurface[e])){this.cmS[0]=t[0],this.cmS[1]=t[1],this.cmS[2]=t[2];break}}}else if(1==i){if(!this.cameraMoveSurface||this.cameraMoveSurface.length<1)return;p.e.transformMat4(this.rayPoint,[2*e/this.canvas.width-1,-2*t/this.canvas.height+1,0],this.tempInvVp),p.e.normalize(this.rayDir,p.e.subtract(p.e.create(),this.rayPoint,this.rayOrigin));for(let e=0;e<2;e++){const t=p.e.create();if(null!==v(t,this.rayOrigin,this.rayDir,this.cameraMoveSurface[e])){const e=[t[0]-this.cmS[0],t[1]-this.cmS[1],t[2]-this.cmS[2]];this.camera.target[0]-=e[0],this.camera.target[1]-=e[1],this.camera.target[2]-=e[2],this.cmS[0]=t[0],this.cmS[1]=t[1],this.cmS[2]=t[2];break}}}}pickingIntersectMesh(){this.editingModel.voxelPoints=[],Object(w.p)(this.editingModel.voxels,[0,0,0],this.editingModel.voxels.shape,(e,t,i)=>this.destModel.voxels.getVoxel(e,t,i)||this.selectionModel.voxels.getVoxel(e,t,i));const e=m(this.rayOrigin,this.rayDir,this.rayPoint,this.editingModel.voxels,this.boundaryBox,2,this.pointer);if(!e)return;let t;if(this.selectionModel.voxels.getVoxel(e[0],e[1],e[2]))t=this.selectionModel;else{if(!this.destModel.voxels.getVoxel(e[0],e[1],e[2]))return;t=this.destModel}return{color:t.voxels.getVoxel(e[0],e[1],e[2]),pickedModel:t}}performFillSameColorSpace(e){const t=this.pickingIntersectMesh();if(!t)return;const{pickedModel:i,color:s}=t,o=i.voxels.shape;Object(w.z)(i.voxels,[0,0,0],[o[0]-1,o[1]-1,o[2]-1],(t,o,n,r,a)=>{r===s&&(i.voxels.data[a]=e)}),i.syncWorkerVoxelData(),i.bakeData(),this.editor.saveHistory()}performHollowOut(){const e=this.pickingIntersectMesh();if(!e)return;const{pickedModel:t,color:i}=e,s=t.voxels.shape;Object(w.z)(t.voxels,[0,0,0],[s[0]-1,s[1]-1,s[2]-1],(e,s,o,n,r)=>{n===i&&(t.voxels.data[r]=0)}),t.syncWorkerVoxelData(),t.bakeData(),this.editor.saveHistory()}performColorSelection(e,t){const i=this.editor.paletteManager.getCurrentColorIndex(),o=[this.editingModel.voxels.shape[0]-1,this.editingModel.voxels.shape[1]-1,this.editingModel.voxels.shape[2]-1],n=this.pointer.getNormal();-1==this._selectSpace.start[0]&&(this._selectSpace.start=[1/0,1/0,1/0],this._selectSpace.end=[0,0,0]);const a=this.veState.getColorSelectOption();if(a===w.l.volume)Object(w.p)(this.editingModel.voxels,[0,0,0],o,0),Object(w.g)(this.destModel.voxels,this.editingModel.voxels,e,t,i,[1,1,1],this._selectSpace.start,this._selectSpace.end),Object(w.z)(this.editingModel.voxels,this._selectSpace.start,this._selectSpace.end,(e,t,i,s,o)=>{const n=s||this.selectionModel.voxels.data[o];0!=n&&(this.selectionModel.voxels.data[o]=n,this.destModel.voxels.data[o]=0)});else if(a===w.l.face){Object(w.p)(this.editingModel.voxels,[0,0,0],o,0);const s=[0,0,0];0!=n[0]?s[1]=s[2]=1:0!=n[1]?s[0]=s[2]=1:0!=n[2]&&(s[0]=s[1]=1),Object(w.g)(this.destModel.voxels,this.editingModel.voxels,e,t,i,s,this._selectSpace.start,this._selectSpace.end,n),Object(w.z)(this.editingModel.voxels,this._selectSpace.start,this._selectSpace.end,(e,t,i,s,o)=>{const n=s||this.selectionModel.voxels.data[o];0!=n&&(this.selectionModel.voxels.data[o]=n,this.destModel.voxels.data[o]=0)})}else a===w.l.all&&Object(w.z)(this.destModel.voxels,[0,0,0],o,(e,i,s,o,n)=>{o===t&&(this.selectionModel.voxels.data[n]=o,this.destModel.voxels.data[n]=0)});this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(()=>{this.destModel.syncWorkerVoxelData(),this.destModel.bakeData()}),r(s.Idle),this.editor.saveHistory()}performTranslate(e,t,i){if(1==i){this.editingModel.voxelPoints=[];const i=[this.editingModel.voxels.shape[0]-1,this.editingModel.voxels.shape[1]-1,this.editingModel.voxels.shape[2]-1];Object(w.p)(this.editingModel.voxels,[0,0,0],i,(e,t,i)=>{const s=this.destModel.voxels.getVoxel(e,t,i)||this.selectionModel.voxels.getVoxel(e,t,i);return s&&this.editingModel.voxelPoints.push([e,t,i]),s});const s=m(this.rayOrigin,this.rayDir,this.rayPoint,this.editingModel.voxels,this.boundaryBox,2,this.pointer);if(!s)return;if(this.selectionModel.voxels.getVoxel(s[0],s[1],s[2]))this.tslModel=this.selectionModel;else{if(!this.destModel.voxels.getVoxel(s[0],s[1],s[2]))return;this.tslModel=this.destModel}this.tslModel.syncWorkerVoxelData(!0),this.currTslState=2,this._tslStartPoint.clientX=e,this._tslStartPoint.clientY=t,this._tslStartPoint.hitAbsPosition=this.pointer.getAbsolutedPos(),this._tslStartPoint.hitNormal=this.pointer.getNormal(),this.tslShift=[0,0,0],this.tslSurface=Object(w.x)(this._tslStartPoint.hitNormal,this.pointer.getPosition(),300)}else if(2==i){b(this.rayOrigin,this.rayDir,this.rayPoint,[this.editingModel],this.pointer);const i=e-this._tslStartPoint.clientX,s=t-this._tslStartPoint.clientY,o=Math.abs(i),n=Math.abs(s);if(o>1||n>1){const e=this.pointer.getAbsolutedPos(),t=e[0]-this._tslStartPoint.hitAbsPosition[0],i=e[1]-this._tslStartPoint.hitAbsPosition[1],s=e[2]-this._tslStartPoint.hitAbsPosition[2],o=Math.abs(t),n=Math.abs(i),r=Math.abs(s);0!=this._tslStartPoint.hitNormal[0]?this.tslDirection=n>r?[0,1,0]:[0,0,1]:0!=this._tslStartPoint.hitNormal[1]?this.tslDirection=o>r?[1,0,0]:[0,0,1]:0!=this._tslStartPoint.hitNormal[2]&&(this.tslDirection=o>n?[1,0,0]:[0,1,0]),this.currTslState=3,this.editingModel.voxelPoints.forEach(e=>{this.editingModel.voxels.setVoxel(e[0],e[1],e[2],0)}),delete this.editingModel.voxelPoints,this.editingModel.syncWorkerVoxelData(),this.editingModel.cleanMeshData()}}else if(3==i){const i=this.pointer.getVoxelPos();x(this.rayOrigin,this.rayDir,this.rayPoint,this.tslSurface,this.pointer);const s=this.pointer.getVoxelPos(),o=[0,0,0];for(let e=0;e<3;e++)o[e]=this.tslDirection[e]*(s[e]-i[e]),this.tslShift[e]+=o[e];if(0==o[0]&&0==o[1]&&0==o[2])return;this.tslModel.sendActionToWorker([w.a.Translate,o]),this.tslModel.bakeData(),this._tslStartPoint.clientX=e,this._tslStartPoint.clientY=t}else if(4==i){if(!this.tslModel)return;this.tslModel.translate(this.tslShift),this.tslShift=[0,0,0],this.currTslState=0,this._tslStartPoint.clientX=this._tslStartPoint.clientY=-1,r(s.Idle),this.PREVEND=this.START=void 0}else b(this.rayOrigin,this.rayDir,this.rayPoint,[this.tslModel,this.destModel,this.selectionModel],this.pointer)}addSphere(e){this.deSelect();const t=this.selectionModel.voxels.shape,i=[t[0]/2,t[1]/2,t[2]/2];for(let t=i[0]-e;t<=i[0]+e;t++)for(let n=i[1]-e;n<=i[1]+e;n++)for(let r=i[2]-e;r<=i[2]+e;r++)s=[t-i[0],n-i[1],r-i[2]],o=e,p.e.len(s)-o<=0&&this.selectionModel.voxels.setVoxel(t,n,r,254);var s,o;this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}addEllipsoid(e){this.deSelect();const t=this.selectionModel.voxels.shape,i=[t[0]/2,t[1]/2,t[2]/2];for(let s=0;s<=t[0];s++)for(let o=0;o<=t[1];o++)for(let n=0;n<=t[2];n++)se([s-i[0],o-i[1]+1,n-i[2]],e)<=0&&this.selectionModel.voxels.setVoxel(s,o,n,254);this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}addCone(e){this.deSelect();const t=[Math.cos(3.14159*e[0]/180),Math.sin(3.14159*e[0]/180),e[1]],i=this.selectionModel.voxels.shape,s=[i[0]/2,i[1]/2,i[2]/2];for(let e=0;e<=i[0];e++)for(let o=0;o<=i[1];o++)for(let n=0;n<=i[2];n++)ie([e-s[0],o-i[1]+1,n-s[2]],t)<=0&&this.selectionModel.voxels.setVoxel(e,o,n,254);this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}addPyramid(e){this.deSelect();const t=[Math.cos(3.14159*e[0]/180),Math.sin(3.14159*e[0]/180),e[1]],i=this.selectionModel.voxels.shape,s=[i[0]/2,i[1]/2,i[2]/2];for(let e=0;e<=i[0];e++)for(let o=0;o<=i[1];o++)for(let n=0;n<=i[2];n++)re([e-s[0],o,n-s[2]],t)<=0&&this.selectionModel.voxels.setVoxel(e,o,n,254);this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}addTorus(e){this.deSelect();const t=this.selectionModel.voxels.shape,i=[t[0]/2,t[1]/2,t[2]/2];for(let s=0;s<=t[0];s++)for(let o=0;o<=t[1];o++)for(let n=0;n<=t[2];n++)oe([s-i[0],o-i[1],n-i[2]],e)<=0&&this.selectionModel.voxels.setVoxel(s,o,n,254);this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}addTorus88(e){this.deSelect();const t=this.selectionModel.voxels.shape,i=[t[0]/2,t[1]/2,t[2]/2];for(let s=0;s<=t[0];s++)for(let o=0;o<=t[1];o++)for(let n=0;n<=t[2];n++)ne([s-i[0],o-i[1],n-i[2]],e)<=0&&this.selectionModel.voxels.setVoxel(s,o,n,254);this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}addRoundbox(e,t){this.deSelect();const i=this.selectionModel.voxels.shape,s=[i[0]/2,i[1]/2,i[2]/2];for(let o=0;o<=i[0];o++)for(let n=0;n<=i[1];n++)for(let r=0;r<=i[2];r++)te([o-s[0],n-s[1],r-s[2]],e,t)<=0&&this.selectionModel.voxels.setVoxel(o,n,r,254);this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}addHexPrism(e){this.deSelect();const t=this.selectionModel.voxels.shape,i=[t[0]/2,t[1]/2,t[2]/2];for(let s=0;s<=t[0];s++)for(let o=0;o<=t[1];o++)for(let n=0;n<=t[2];n++)ae([s-i[0],o-i[1],n-i[2]],e)<=0&&this.selectionModel.voxels.setVoxel(s,o,n,254);this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}addTriPrism(e){this.deSelect();const t=this.selectionModel.voxels.shape,i=[t[0]/2,t[1]/2,t[2]/2];for(let s=0;s<=t[0];s++)for(let o=0;o<=t[1];o++)for(let n=0;n<=t[2];n++)le([s-i[0],o-i[1],n-i[2]],e)<=0&&this.selectionModel.voxels.setVoxel(s,o,n,254);this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}addSkull(e){this.deSelect();const t=this.selectionModel.voxels.shape,i=[t[0]/2,t[1]/2,t[2]/2];for(let s=0;s<=t[0];s++)for(let o=0;o<=t[1];o++)for(let n=0;n<=t[2];n++)he([(s-i[0])/e[0],(o-i[1])/e[1],(n-i[2]/2)/e[2]])<=0&&this.selectionModel.voxels.setVoxel(s,o,n,254);this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}addHeart(e){this.deSelect();const t=this.selectionModel.voxels.shape,i=[t[0]/2,t[1]/2,t[2]/2];for(let s=0;s<=t[0];s++)for(let o=0;o<=t[1];o++)for(let n=0;n<=t[2];n++)ce([(s-i[0])/e[0]*10,o/e[1]*10,(n-i[2])/e[2]*10])<=0&&this.selectionModel.voxels.setVoxel(s,o,n,254);this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}addFlower(e){this.deSelect();const t=this.selectionModel.voxels.shape,i=[t[0]/2,t[1]/2,t[2]/2];for(let s=0;s<=t[0];s++)for(let o=0;o<=t[1];o++)for(let n=0;n<=t[2];n++)fe([(s-i[0])/e[0],(o-i[1])/e[1],(n-i[2])/e[2]])<=0&&this.selectionModel.voxels.setVoxel(s,o,n,254);this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}invSelect(){const e=this.selectionModel.voxels;this.selectionModel.voxels=this.destModel.voxels,this.destModel.voxels=e;const t=this.selectionModel.rawMeshBuffer;this.selectionModel.rawMeshBuffer=this.destModel.rawMeshBuffer,this.destModel.rawMeshBuffer=t;const i=this.selectionModel.meshBuffer;this.selectionModel.meshBuffer=this.destModel.meshBuffer,this.destModel.meshBuffer=i;const s=this.selectionModel.cIndexBuffer;this.selectionModel.cIndexBuffer=this.destModel.cIndexBuffer,this.destModel.cIndexBuffer=s,this.selectionModel.rawMeshBuffer&&(this.selectionModel.vertexCount=this.selectionModel.rawMeshBuffer.length/8),this.destModel.rawMeshBuffer&&(this.destModel.vertexCount=this.destModel.rawMeshBuffer.length/8)}subtractSelection(){const e=this.destModel.voxels.shape[0]*this.destModel.voxels.shape[1]*this.destModel.voxels.shape[2];for(let t=0;t{this.destModel.cleanMeshData()})}deSelect(){const e=this.destModel.voxels.shape[0]*this.destModel.voxels.shape[1]*this.destModel.voxels.shape[2];for(let t=0;t0){const{lo:e,hi:t}=this.selectionModel.bounday(),i=[(e[0]+t[0])/2,(e[1]+t[1])/2,(e[2]+t[2])/2].map(e=>Math.round(e));this.editingModel.cleanMeshData();const s=this.selectionModel.voxels.shape;Object(w.z)(this.selectionModel.voxels,[0,0,0],[s[0]-1,s[1]-1,s[2]-1],(e,t,s,o)=>{const n=t-i[1],r=s-i[2],a=0*n-1*r,l=0*r+1*n;this.editingModel.voxels.setVoxel(e,a+i[1],l+i[2],o)}),Object(w.z)(this.editingModel.voxels,[0,0,0],[s[0]-1,s[1]-1,s[2]-1],(e,t,i,s)=>{this.selectionModel.voxels.setVoxel(e,t,i,s)}),this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}}rotateY_90deg(){if(this.selectionModel.vertexCount>0){const{lo:e,hi:t}=this.selectionModel.bounday(),i=[(e[0]+t[0])/2,(e[1]+t[1])/2,(e[2]+t[2])/2].map(e=>Math.round(e));this.editingModel.cleanMeshData();const s=this.selectionModel.voxels.shape;Object(w.z)(this.selectionModel.voxels,[0,0,0],[s[0]-1,s[1]-1,s[2]-1],(e,t,s,o)=>{const n=e-i[0],r=s-i[2],a=0*n-1*r,l=0*r+1*n;this.editingModel.voxels.setVoxel(a+i[0],t,l+i[2],o)}),Object(w.z)(this.editingModel.voxels,[0,0,0],[s[0]-1,s[1]-1,s[2]-1],(e,t,i,s)=>{this.selectionModel.voxels.setVoxel(e,t,i,s)}),this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}}rotateZ_90deg(){if(this.selectionModel.vertexCount>0){const{lo:e,hi:t}=this.selectionModel.bounday(),i=[(e[0]+t[0])/2,(e[1]+t[1])/2,(e[2]+t[2])/2].map(e=>Math.round(e));this.editingModel.cleanMeshData();const s=this.selectionModel.voxels.shape;Object(w.z)(this.selectionModel.voxels,[0,0,0],[s[0]-1,s[1]-1,s[2]-1],(e,t,s,o)=>{const n=e-i[0],r=t-i[1],a=0*n-1*r,l=0*r+1*n;this.editingModel.voxels.setVoxel(a+i[0],l+i[1],s,o)}),Object(w.z)(this.editingModel.voxels,[0,0,0],[s[0]-1,s[1]-1,s[2]-1],(e,t,i,s)=>{this.selectionModel.voxels.setVoxel(e,t,i,s)}),this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}}flipX(){if(this.selectionModel.vertexCount>0){const{lo:e,hi:t}=this.selectionModel.bounday(),i=[(e[0]+t[0])/2,(e[1]+t[1])/2,(e[2]+t[2])/2].map(e=>Math.round(e)),s=this.selectionModel.voxels.shape;Object(w.z)(this.selectionModel.voxels,[0,0,0],[i[0],s[1]-1,s[2]-1],(e,t,s,o,n)=>{const r=o,a=this.selectionModel.voxels.getVoxel(2*i[0]-e,t,s);this.selectionModel.voxels.setVoxel(e,t,s,a),this.selectionModel.voxels.setVoxel(2*i[0]-e,t,s,r)}),this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}}flipY(){if(this.selectionModel.vertexCount>0){const{lo:e,hi:t}=this.selectionModel.bounday(),i=[(e[0]+t[0])/2,(e[1]+t[1])/2,(e[2]+t[2])/2].map(e=>Math.round(e)),s=this.selectionModel.voxels.shape;Object(w.z)(this.selectionModel.voxels,[0,0,0],[s[0]-1,i[1],s[2]-1],(e,t,s,o,n)=>{const r=o,a=this.selectionModel.voxels.getVoxel(e,2*i[1]-t,s);this.selectionModel.voxels.setVoxel(e,t,s,a),this.selectionModel.voxels.setVoxel(e,2*i[1]-t,s,r)}),this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}}flipZ(){if(this.selectionModel.vertexCount>0){const{lo:e,hi:t}=this.selectionModel.bounday(),i=[(e[0]+t[0])/2,(e[1]+t[1])/2,(e[2]+t[2])/2].map(e=>Math.round(e)),s=this.selectionModel.voxels.shape;Object(w.z)(this.selectionModel.voxels,[0,0,0],[s[0]-1,s[1]-1,i[2]],(e,t,s,o,n)=>{const r=o,a=this.selectionModel.voxels.getVoxel(e,t,2*i[2]-s);this.selectionModel.voxels.setVoxel(e,t,s,a),this.selectionModel.voxels.setVoxel(e,t,2*i[2]-s,r)}),this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.editor.saveHistory()}}beginAttach(){const e=[this.destModel.voxels.shape[0]-1,this.destModel.voxels.shape[1]-1,this.destModel.voxels.shape[2]-1],t=this.paletteManager.getCurrentColorIndex(),i=this.veState.getEditingMode();let o=2;i!=w.c.face&&(o=1);const n=m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,o,this.pointer);if(n){const s=this.destModel.voxels.getVoxel(n[0],n[1],n[2]);if(this.PREVEND=this.START=n,this.editingModel.blockRender(!1),i==w.c.box){this.veState.getOptionResPoint(this.START,this.PREVEND,e);this.destModel.syncWorkerVoxelData()}else if(i==w.c.center){this.destModel.syncWorkerVoxelData(),this.start_pointer_N=this.pointer.getNormal();const e=Object(w.x)(this.pointer.getNormal(),this.pointer.getPosition(),300),t=this.pointer.indecs;this.temSurface=[e[t[0][0]],e[t[0][1]],e[t[0][2]],e[t[1][0]],e[t[1][1]],e[t[1][2]]]}else if(i==w.c.face){this.veState.getFaceModeColorOpt()===w.d.currentColor?this.tempColor=-1:this.tempColor=t,Object(w.p)(this.editingModel.voxels,[0,0,0],e,0);const i=[0,0,0],o=this.pointer.getNormal(),n=this.pointer.getVoxelPos();this.tempStartPos=[0,0,0],this.tempEndPos=e.slice(0);const r=n.slice(0);this.tempHitStartPos=n.slice(0),this.tempPrePos=n.slice(0),this.tempHitNormal=this.pointer.getNormal(),0!=o[0]?(i[1]=i[2]=1,this.tempStartPos[0]=this.tempEndPos[0]=n[0]):0!=o[1]?(i[0]=i[2]=1,this.tempStartPos[1]=this.tempEndPos[1]=n[1]):0!=o[2]&&(i[0]=i[1]=1,this.tempStartPos[2]=this.tempEndPos[2]=n[2]);const a=[this.camera.eye[0],this.camera.eye[1],this.camera.eye[2]],l=this.destModel.voxels.shape;for(let e=0;e<3;e++)a[e]>n[e]?r[e]=n[e]+o[e]:r[e]=n[e]-l[e]+1+o[e];this.tempDistance=0;const h=[r[0]+l[0],r[1]+l[1],r[2]+l[2]];if(0!==s||0!==n[0]&&n[0]!==e[0]&&0!==n[1]&&n[1]!==e[1]&&0!==n[2]&&n[2]!==e[2])this.veState.getFaceModeSelectionOpt()===w.e.geometry?Object(w.g)(this.destModel.voxels,this.editingModel.voxels,n,-1,t,i,this.tempStartPos,this.tempEndPos,o):Object(w.g)(this.destModel.voxels,this.editingModel.voxels,n,s,t,i,this.tempStartPos,this.tempEndPos,o);else{Object(w.g)(this.destModel.voxels,this.editingModel.voxels,n,0,t,i,this.tempStartPos,this.tempEndPos,o);for(let e=0;e<3;e++)r[e]-=o[e],h[e]-=o[e],this.tempStartPos[e]=this.tempEndPos[e]=n[e]-o[e]}this.editingModel.syncWorkerVoxelData(!0),this.editingModel.bakeData(),this.tempBoundBoxGeo=Object(w.q)(r,h,!1,!1,!1)}else if(i==w.c.line){const e=n;this.tempStartPos=[e[0],e[1],e[2]],this.editingModel.syncWorkerVoxelData()}}else r(s.Idle)}beginErase(){const e=[this.destModel.voxels.shape[0]-1,this.destModel.voxels.shape[1]-1,this.destModel.voxels.shape[2]-1],t=this.paletteManager.getCurrentColorIndex(),i=this.veState.getEditingMode(),o=m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,2,this.pointer);if(o){const s=this.destModel.voxels.getVoxel(o[0],o[1],o[2]);if(this.PREVEND=this.START=o,this.editingModel.blockRender(!1),i==w.c.box)Object(w.z)(this.destModel.voxels,[0,0,0],e,(e,t,i,s,o)=>{this.editingModel.voxels.data[o]=s}),this.destModel.syncWorkerVoxelData(),this.editingModel.syncWorkerVoxelData(),this.editingModel.bakeData(()=>{this.destModel.blockRender(!0)});else if(i==w.c.center){Object(w.z)(this.destModel.voxels,[0,0,0],e,(e,t,i,s,o)=>{this.editingModel.voxels.data[o]=s}),this.destModel.syncWorkerVoxelData(),this.editingModel.syncWorkerVoxelData(),this.editingModel.bakeData(()=>{this.destModel.blockRender(!0)}),this.start_pointer_N=this.pointer.getNormal();const t=Object(w.x)(this.pointer.getNormal(),this.pointer.getPosition(),300),i=this.pointer.indecs;this.temSurface=[t[i[0][0]],t[i[0][1]],t[i[0][2]],t[i[1][0]],t[i[1][1]],t[i[1][2]]]}else if(i==w.c.face){this.veState.getFaceModeColorOpt()===w.d.currentColor?this.tempColor=-1:this.tempColor=t,Object(w.z)(this.destModel.voxels,[0,0,0],e,(e,t,i,s,o)=>{this.editingModel.voxels.data[o]=s});const i=[0,0,0],o=this.pointer.getNormal(),n=this.pointer.getVoxelPos();this.tempStartPos=[0,0,0],this.tempEndPos=e.slice(0);const r=[n[0],n[1],n[2]];this.tempHitStartPos=[n[0],n[1],n[2]],this.tempPrePos=[n[0],n[1],n[2]],this.tempHitNormal=this.pointer.getNormal(),0!=o[0]?(i[1]=i[2]=1,this.tempStartPos[0]=this.tempEndPos[0]=n[0]):0!=o[1]?(i[0]=i[2]=1,this.tempStartPos[1]=this.tempEndPos[1]=n[1]):0!=o[2]&&(i[0]=i[1]=1,this.tempStartPos[2]=this.tempEndPos[2]=n[2]);const a=[this.camera.eye[0],this.camera.eye[1],this.camera.eye[2]],l=this.destModel.voxels.shape;for(let e=0;e<3;e++)a[e]>n[e]?0!==o[e]?r[e]=n[e]-l[e]+1:r[e]=n[e]:0!==o[e]?r[e]=n[e]:r[e]=n[e]-l[e]+1;this.tempDistance=0;const h=[r[0]+l[0],r[1]+l[1],r[2]+l[2]];this.editingModel.syncWorkerVoxelData(),this.editingModel.voxelPoints=[],Object(w.z)(this.editingModel.voxels,[0,0,0],e,(e,t,i,s,o)=>{this.editingModel.voxels.data[o]=0}),this.veState.getFaceModeSelectionOpt()===w.e.geometry?Object(w.g)(this.destModel.voxels,this.editingModel.voxels,n,-1,t,i,this.tempStartPos,this.tempEndPos,o):Object(w.g)(this.destModel.voxels,this.editingModel.voxels,n,s,t,i,this.tempStartPos,this.tempEndPos,o);for(let t=0;t<=e[0];t++)for(let i=0;i<=e[1];i++)for(let s=0;s<=e[2];s++)this.editingModel.voxels.getVoxel(t,i,s)>0&&this.editingModel.voxelPoints.push([t,i,s]);this.editingModel.syncWorkerVoxelPoints(),this.editingModel.bakeData(()=>{this.destModel.blockRender(!0)}),this.tempBoundBoxGeo=Object(w.q)(r,h,!1,!1,!1)}else if(i==w.c.line){const t=this.pointer.getVoxelPos();this.tempStartPos=[t[0],t[1],t[2]],Object(w.z)(this.destModel.voxels,[0,0,0],e,(e,t,i,s,o)=>{this.editingModel.voxels.data[o]=s}),this.editingModel.syncWorkerVoxelData(),this.editingModel.bakeData(()=>{this.destModel.blockRender(!0)})}}else r(s.Idle)}beginPaint(){const e=this.paletteManager.getCurrentColorIndex(),t=this.veState.getEditingMode(),i=[this.destModel.voxels.shape[0]-1,this.destModel.voxels.shape[1]-1,this.destModel.voxels.shape[2]-1],o=m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,2,this.pointer);if(o){const r=this.destModel.voxels.getVoxel(o[0],o[1],o[2]);if(this.PREVEND=this.START=o,this.editingModel.blockRender(!1),t==w.c.box)this.destModel.syncWorkerVoxelData(),Object(w.z)(this.destModel.voxels,[0,0,0],i,(e,t,i,s,o)=>{this.editingModel.voxels.data[o]=s}),this.editingModel.syncWorkerVoxelData(),this.editingModel.bakeData(()=>{n()===s.EditingVoxel&&this.destModel.blockRender(!0)});else if(t==w.c.center){Object(w.z)(this.destModel.voxels,[0,0,0],i,(e,t,i,s,o)=>{this.editingModel.voxels.data[o]=s}),this.destModel.syncWorkerVoxelData(),this.editingModel.syncWorkerVoxelData(),this.editingModel.bakeData(()=>{n()===s.EditingVoxel&&this.destModel.blockRender(!0)}),this.start_pointer_N=this.pointer.getNormal();const e=Object(w.x)(this.pointer.getNormal(),this.pointer.getPosition(),300),t=this.pointer.indecs;this.temSurface=[e[t[0][0]],e[t[0][1]],e[t[0][2]],e[t[1][0]],e[t[1][1]],e[t[1][2]]]}else if(t==w.c.face){this.veState.getFaceModeColorOpt()===w.d.currentColor?this.tempColor=-1:this.tempColor=e,Object(w.z)(this.destModel.voxels,[0,0,0],i,(e,t,i,s,o)=>{this.editingModel.voxels.data[o]=s});const t=[0,0,0],o=this.pointer.getNormal(),a=this.pointer.getVoxelPos();this.tempStartPos=[0,0,0],this.tempEndPos=i.slice(0);const l=[a[0],a[1],a[2]];this.tempHitStartPos=[a[0],a[1],a[2]],this.tempPrePos=[a[0],a[1],a[2]],this.tempHitNormal=this.pointer.getNormal(),0!=o[0]?(t[1]=t[2]=1,this.tempStartPos[0]=this.tempEndPos[0]=a[0]):0!=o[1]?(t[0]=t[2]=1,this.tempStartPos[1]=this.tempEndPos[1]=a[1]):0!=o[2]&&(t[0]=t[1]=1,this.tempStartPos[2]=this.tempEndPos[2]=a[2]);const h=[this.camera.eye[0],this.camera.eye[1],this.camera.eye[2]],c=this.destModel.voxels.shape;for(let e=0;e<3;e++)h[e]>a[e]?0!==o[e]?l[e]=a[e]-c[e]+1:l[e]=a[e]:0!==o[e]?l[e]=a[e]:l[e]=a[e]-c[e]+1;this.tempDistance=0;const d=[l[0]+c[0],l[1]+c[1],l[2]+c[2]];this.editingModel.syncWorkerVoxelData(),this.editingModel.voxelPoints=[],Object(w.z)(this.editingModel.voxels,[0,0,0],i,(e,t,i,s,o)=>{this.editingModel.voxels.data[o]=0}),this.veState.getFaceModeSelectionOpt()===w.e.geometry?Object(w.g)(this.destModel.voxels,this.editingModel.voxels,a,-1,e,t,this.tempStartPos,this.tempEndPos,o):Object(w.g)(this.destModel.voxels,this.editingModel.voxels,a,r,e,t,this.tempStartPos,this.tempEndPos,o);for(let e=0;e<=i[0];e++)for(let t=0;t<=i[1];t++)for(let s=0;s<=i[2];s++)this.editingModel.voxels.getVoxel(e,t,s)>0&&this.editingModel.voxelPoints.push([e,t,s]);this.editingModel.syncWorkerVoxelPoints(),this.editingModel.bakeData(()=>{n()===s.EditingVoxel&&this.destModel.blockRender(!0)}),this.tempBoundBoxGeo=Object(w.q)(l,d,!1,!1,!1)}else if(t==w.c.line){const e=o;this.tempStartPos=[e[0],e[1],e[2]],Object(w.z)(this.destModel.voxels,[0,0,0],i,(e,t,i,s,o)=>{this.editingModel.voxels.data[o]=s}),this.editingModel.syncWorkerVoxelData(),this.editingModel.bakeData(()=>{n()===s.EditingVoxel&&this.destModel.blockRender(!0)})}}else r(s.Idle)}beginSelect(){const e=m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,2,this.pointer),t=[this.destModel.voxels.shape[0]-1,this.destModel.voxels.shape[1]-1,this.destModel.voxels.shape[2]-1];if(e){this.PREVEND=this.START=e,this.editingModel.blockRender(!1);const i=this.veState.getOptionResPoint(this.START,this.PREVEND,t);for(let e=0;e{this.editingModel.voxels.data[o]=s}),this.selectionModel.voxels.setVoxel(s[0],s[1],s[2],this.destModel.voxels.getVoxel(s[0],s[1],s[2])),this.updateSelectSpace(s,o)}}else r(s.Idle)}onAttach(){const e=this.veState.getCurrentEditingTool(),t=this.paletteManager.getCurrentColorIndex(),i=this.veState.getCenterMode(),s=this.veState.getEditingMode(),o=[this.editingModel.voxels.shape[0]-1,this.editingModel.voxels.shape[1]-1,this.editingModel.voxels.shape[2]-1];if(s===w.c.box){const i=m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,e==w.a.Attach?1:2,this.pointer);if(i){null==this.START&&(this.START=this.PREVEND=i);const e=this.veState.getOptionResPoint(this.START,this.PREVEND,o),s=this.veState.getOptionResPoint(this.START,i,o),n={positions:[],elements:[],normals:[]};for(let i=0;ie.map(e=>e+a));n.elements=n.elements.concat(h),i==e.length-1&&this.editingModel.setTempGeoData(n,t)}this.PREVEND=i}}else if(s===w.c.center){x(this.rayOrigin,this.rayDir,this.rayPoint,this.temSurface,this.pointer);const e=this.pointer.getVoxelPos(),s=this.veState.getCentreModeSymmetryPoint(this.START,o),n=t;if(i===w.b.circle){const t=Object(w.k)(this.start_pointer_N,this.START,e);this.editingModel.sendActionToWorker([w.a.Attach,s,t,n,w.c.center,w.b.circle,this.start_pointer_N])}else if(i===w.b.square){const t=Object(w.j)(this.start_pointer_N,this.START,e);this.editingModel.sendActionToWorker([w.a.Attach,s,t,n,w.c.center,w.b.square,this.start_pointer_N])}this.editingModel.bakeData()}else if(s===w.c.face){const e=this.veState.getFaceModeColorOpt(),i=p.e.max(p.e.create(),this.tempBoundBoxGeo.lo,[0,0,0]),s=p.e.min(p.e.create(),this.tempBoundBoxGeo.hi,this.editingModel.voxels.shape),o=y(this.rayOrigin,this.rayDir,this.rayPoint,this.tempBoundBoxGeo,[i,s],this.pointer);if(null==this.tempHitNormal)return;if(o){let i;for(let e=0;e<3;e++)if(0!=this.tempHitNormal[e]){i=o[e]-this.tempHitStartPos[e];break}if(this.tempDistance==i)return;e===w.d.currentColor?this.editingModel.sendActionToWorker([w.a.Attach,this.tempHitNormal,[this.tempDistance,i],t,w.c.face,this.veState.basicActionOption]):e===w.d.voxelColor&&this.editingModel.sendActionToWorker([w.a.Attach,this.tempHitNormal,[this.tempDistance,i],this.tempColor,w.c.face,this.veState.basicActionOption]),this.tempDistance=i,this.tempPrePos=[o[0],o[1],o[2]],this.editingModel.bakeData()}}else if(s==w.c.line){const i=m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,e==w.a.Attach?1:2,this.pointer);if(!i)return;const s=i,n=this.veState.getCentreModeSymmetryPoint(this.tempStartPos,o),r=this.veState.getCentreModeSymmetryPoint(s,o);this.editingModel.sendActionToWorker([w.a.Attach,n,r,t,w.c.line,this.veState.basicActionOption]),this.editingModel.bakeData(),this.PREVEND=i}}onErase(){const e=this.veState.getCenterMode(),t=this.veState.getEditingMode(),i=[this.editingModel.voxels.shape[0]-1,this.editingModel.voxels.shape[1]-1,this.editingModel.voxels.shape[2]-1];if(t===w.c.box){const e=m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,2,this.pointer);if(e){null==this.START&&(this.START=this.PREVEND=e);const t=this.veState.getOptionResPoint(this.START,this.PREVEND,i),s=this.veState.getOptionResPoint(this.START,e,i);for(let e=0;ethis.editingModel.voxels.getVoxel(e,t,i),(e,t,i)=>this.destModel.voxels.getVoxel(e,t,i)),this.updateSelectSpace(t,o),this.updateSelectSpace(n,r)}this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(),this.PREVEND=e}}endAttach(){const e=[this.destModel.voxels.shape[0]-1,this.destModel.voxels.shape[1]-1,this.destModel.voxels.shape[2]-1],t=this.veState.getEditingMode(),i=this.veState.getCenterMode(),o=this.paletteManager.getCurrentColorIndex();if(t===w.c.box){const t=m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,1,this.pointer);if(t){const i=this.veState.getOptionResPoint(this.START,this.PREVEND,e),s=this.veState.getOptionResPoint(this.START,t,e);for(let t=0;t{0==s&&(this.destModel.voxels.data[n]=o)})}}else if(this.START&&this.PREVEND){const t=this.veState.getOptionResPoint(this.START,this.PREVEND,e);for(let i=0;i{s||(this.destModel.voxels.data[n]=o)}),this.editingModel.voxels.setVoxel(s[0],s[1],s[2],0)}}}else if(t===w.c.center){const t=o;x(this.rayOrigin,this.rayDir,this.rayPoint,this.temSurface,this.pointer);const s=this.pointer.getVoxelPos();let n;const r=this.veState.getCentreModeSymmetryPoint(this.START,e);if(i===w.b.circle){n=Object(w.k)(this.start_pointer_N,this.START,s);for(let i=0;i{if(!(i<0||i>e[0]||s<0||s>e[1]||o<0||o>e[2])){const e=this.destModel.voxels.index(i,s,o);this.destModel.voxels.data[e]=this.destModel.voxels.data[e]||t}})}}else if(i===w.b.square){n=Object(w.j)(this.start_pointer_N,this.START,s);for(let e=0;e0?1:-1,a=this.tempHitNormal;Object(w.z)(this.editingModel.voxels,this.tempStartPos,this.tempEndPos,(t,i,s,o,l)=>{let h=0;if(h+=r,o>0)for(let l=0;l{const s=this.destModel.voxels.index(e,t,i);this.destModel.voxels.data[s]=this.destModel.voxels.data[s]||o});this.destModel.syncWorkerVoxelData(),this.destModel.bakeData()}this.destModel.syncWorkerVoxelData(),this.destModel.bakeData(()=>{this.destModel.blockRender(!1),this.editingModel.cleanMeshData(),this.editingModel.renderTempGeo=!1,this.editingModel.clearVoxel()}),r(s.Idle),this.PREVEND=this.START=void 0}endErase(){const e=[this.destModel.voxels.shape[0]-1,this.destModel.voxels.shape[1]-1,this.destModel.voxels.shape[2]-1],t=this.veState.getEditingMode(),i=this.veState.getCenterMode();if(t===w.c.box){const t=m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,2,this.pointer);if(t){const i=this.veState.getOptionResPoint(this.START,this.PREVEND,e),s=this.veState.getOptionResPoint(this.START,t,e);for(let t=0;t{this.destModel.voxels.data[o]=0})}}else if(this.START&&this.PREVEND){const t=this.veState.getOptionResPoint(this.START,this.PREVEND,e);for(let i=0;i{if(!(t<0||t>e[0]||i<0||i>e[1]||s<0||s>e[2])){const e=this.destModel.voxels.index(t,i,s);this.destModel.voxels.data[e]=0}})}}else if(i===w.b.square){o=Object(w.j)(this.start_pointer_N,this.START,s);for(let e=0;e0?1:-1,o=this.tempHitNormal;if(this.editingModel.voxelPoints)for(let s=0;s{const s=this.destModel.voxels.index(e,t,i);this.destModel.voxels.data[s]=0});this.destModel.syncWorkerVoxelData(),this.destModel.bakeData()}this.destModel.syncWorkerVoxelData(),this.destModel.bakeData(()=>{this.destModel.blockRender(!1),this.editingModel.cleanMeshData(),this.editingModel.renderTempGeo=!1,this.editingModel.clearVoxel()}),r(s.Idle),this.PREVEND=this.START=void 0}endPaint(){const e=[this.destModel.voxels.shape[0]-1,this.destModel.voxels.shape[1]-1,this.destModel.voxels.shape[2]-1],t=this.veState.getEditingMode(),i=this.veState.getCenterMode(),o=this.paletteManager.getCurrentColorIndex();if(t===w.c.box){const t=m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,2,this.pointer);if(t){const i=this.veState.getOptionResPoint(this.START,this.PREVEND,e),s=this.veState.getOptionResPoint(this.START,t,e);for(let e=0;ethis.destModel.voxels.getVoxel(e,t,i),o,(e,t,i)=>0!=this.destModel.voxels.getVoxel(e,t,i))}}else if(this.START&&this.PREVEND){const t=this.veState.getOptionResPoint(this.START,this.PREVEND,e);for(let i=0;i0!=this.destModel.voxels.getVoxel(e,t,i))}}}else if(t===w.c.center){const t=o;x(this.rayOrigin,this.rayDir,this.rayPoint,this.temSurface,this.pointer);const s=this.pointer.getVoxelPos();let n;const r=this.veState.getCentreModeSymmetryPoint(this.START,e);if(i===w.b.circle){n=Object(w.k)(this.start_pointer_N,this.START,s);for(let i=0;i{if(!(i<0||i>e[0]||s<0||s>e[1]||o<0||o>e[2])){const e=this.destModel.voxels.index(i,s,o);this.destModel.voxels.data[e]=this.destModel.voxels.data[e]?t:this.destModel.voxels.data[e]}})}}else if(i===w.b.square){n=Object(w.j)(this.start_pointer_N,this.START,s);for(let e=0;e0?1:-1,o=this.tempHitNormal;if(this.editingModel.voxelPoints)for(let t=0;t{const s=this.destModel.voxels.index(e,t,i);this.destModel.voxels.data[s]&&(this.destModel.voxels.data[s]=o)});this.destModel.syncWorkerVoxelData(),this.destModel.bakeData()}this.destModel.syncWorkerVoxelData(),this.destModel.bakeData(()=>{this.editingModel.blockRender(!0),this.destModel.blockRender(!1),this.editingModel.renderTempGeo=!1,this.editingModel.clearVoxel()}),r(s.Idle),this.PREVEND=this.START=void 0}endSelect(){(m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,2,this.pointer)||this.START&&this.PREVEND)&&(Object(w.p)(this.destModel.voxels,this._selectSpace.start,this._selectSpace.end,0,(e,t,i)=>0!=this.selectionModel.voxels.getVoxel(e,t,i)),this.destModel.syncWorkerVoxelData()),this.destModel.syncWorkerVoxelData(),this.destModel.bakeData(()=>{this.destModel.blockRender(!1),this.editingModel.cleanMeshData(),this.editingModel.renderTempGeo=!1,this.editingModel.clearVoxel()}),this.selectionModel.syncWorkerVoxelData(),this.selectionModel.bakeData(()=>{this.destModel.blockRender(!1)}),r(s.Idle),this.PREVEND=this.START=void 0}onmousedown(e){if(this.veState.projectLoading||this.veState.previewMeshMode)return;if(e.target!==this.voxel_editor_ele&&e.target!==this.canvas||2==e.button||this.camera.isRotating())return;if(n()===s.DragingModel)return void(h()==a.Idle&&c(a.Activate));if(1===e.button||n()===s.MovingCamera)return r(s.MovingCamera),void this.shiftingViewPort(e.clientX,e.clientY,0);r(s.EditingVoxel),p.e.transformMat4(this.rayPoint,[2*e.clientX/window.innerWidth-1,-2*e.clientY/window.innerHeight+1,0],this.camera.invViewProjection),p.e.transformMat4(this.rayOrigin,[0,0,0],this.camera.invView),p.e.normalize(this.rayDir,p.e.subtract(p.e.create(),this.rayPoint,this.rayOrigin));const t=this.veState.getCurrentEditingTool(),i=[this.destModel.voxels.shape[0]-1,this.destModel.voxels.shape[1]-1,this.destModel.voxels.shape[2]-1],o=this.paletteManager.getCurrentColorIndex();if(t!==w.a.Translate){if(t===w.a.HollowOut||t===w.a.FillSameColorSpace)return t===w.a.HollowOut?this.performHollowOut():this.performFillSameColorSpace(o),void r(s.Idle);if(t===w.a.Attach)this.beginAttach();else if(t===w.a.Erase)this.beginErase();else if(t===w.a.Paint)this.beginPaint();else if(t===w.a.Select)-1!=this._selectSpace.start[0]&&(this.multipleSelect?Object(w.u)(this.destModel.voxels,this.selectionModel.voxels,this._selectSpace.start,this._selectSpace.end,3):this.deSelect(),this.destModel.syncWorkerVoxelData(),this.destModel.bakeData()),this.beginSelect();else{if(t===w.a.ColorSelect){this.multipleSelect?Object(w.u)(this.destModel.voxels,this.selectionModel.voxels,[0,0,0],i,3):this.deSelect();const e=m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,2,this.pointer);if(e){const t=this.destModel.voxels.getVoxel(e[0],e[1],e[2]);t>0&&this.performColorSelection(e,t)}return}if(t===w.a.PickColor){for(let e=0;e<=i[0];e++)for(let t=0;t<=i[1];t++)for(let s=0;s<=i[2];s++){const i=this.destModel.voxels.index(e,t,s);this.selectionModel.voxels.data[i]>0?this.editingModel.voxels.data[i]=this.selectionModel.voxels.data[i]:this.editingModel.voxels.data[i]=this.destModel.voxels.data[i]}const e=m(this.rayOrigin,this.rayDir,this.rayPoint,this.editingModel.voxels,this.boundaryBox,2,this.pointer);if(e){let t=this.selectionModel.voxels.getVoxel(e[0],e[1],e[2]);0==t&&(t=this.destModel.voxels.getVoxel(e[0],e[1],e[2])),this.paletteManager.setCurentColor(t),r(s.Idle)}return}}}else this.performTranslate(e.clientX,e.clientY,1)}onmousemove(e){const t=this.veState.getCurrentEditingTool();n()!==s.MovingCamera?n()!==s.PickingChunk?n()!==s.DragingModel?n()===s.Idle&&e.target!=this.voxel_editor_ele&&e.target!=this.canvas||(p.e.transformMat4(this.rayPoint,[2*e.clientX/window.innerWidth-1,-2*e.clientY/window.innerHeight+1,0],this.camera.invViewProjection),p.e.transformMat4(this.rayOrigin,[0,0,0],this.camera.invView),p.e.normalize(this.rayDir,p.e.subtract(p.e.create(),this.rayPoint,this.rayOrigin)),t!=w.a.Translate?n()===s.EditingVoxel?t===w.a.Attach?this.onAttach():t===w.a.Erase?this.onErase():t===w.a.Paint?this.onPaint():t===w.a.Select&&this.onSelect():m(this.rayOrigin,this.rayDir,this.rayPoint,this.destModel.voxels,this.boundaryBox,t==w.a.Attach?1:2,this.pointer):this.performTranslate(e.clientX,e.clientY,this.currTslState)):h()==a.Idle&&B.arrowHelper.pickArrow(this.rayOrigin,this.rayDir,this.camera.eye):L().pickChunk(this.rayOrigin,this.rayDir,this.rayPoint):this.shiftingViewPort(e.clientX,e.clientY,1)}onmouseup(e){if(p.e.transformMat4(this.rayPoint,[2*e.clientX/window.innerWidth-1,-2*e.clientY/window.innerHeight+1,0],this.camera.invViewProjection),p.e.transformMat4(this.rayOrigin,[0,0,0],this.camera.invView),p.e.normalize(this.rayDir,p.e.subtract(p.e.create(),this.rayPoint,this.rayOrigin)),n()===s.MovingCamera)return this.cmS=[0,0,0],void r(s.Idle);if(n()===s.DragingModel)return void(h()!=a.Idle&&c(a.End));if(n()!==s.EditingVoxel)return;const t=this.veState.getCurrentEditingTool();t==w.a.Translate?this.performTranslate(e.clientX,e.clientY,4):t==w.a.Attach?this.endAttach():t===w.a.Erase?this.endErase():t===w.a.Paint?this.endPaint():t===w.a.Select&&this.endSelect(),this.editor.saveHistory(),this.editStepCount++,this.previousEditTime=Date.now()}onkeydown(e){if("INPUT"!=e.target.tagName){if(e.stopPropagation(),this.keydown[e.keyCode]=!0,e.keyCode==me)return void r(s.MovingCamera);if(e.keyCode==ge)return L().toggleChunk(!0),L().toggleBoundBox(!0),void r(s.PickingChunk);if(e.keyCode==ve)return void(n()===s.DragingModel&&r(s.Idle));if(e.keyCode==be)return void(this.multipleSelect=!0)}}onkeyup(e){if(this.keydown[e.keyCode]=!1,"INPUT"!=e.target.tagName){if(e.stopPropagation(),e.keyCode==me)return void r(s.Idle);if(e.keyCode==ge)return L().toggleChunk(!1),L().toggleBoundBox(!1),void r(s.Idle);if(e.keyCode==be)return void(this.multipleSelect=!1)}}ondragover(e){return e.preventDefault()&&!1}ondrop(e){e.preventDefault(),e.dataTransfer}preparePbrRendering(){if(this.veState.pbrPreviewMode&&(void 0===this.editor.pbrRenderer&&this.editor.createPbrRenderer(),this.editor.pbrRenderer)){this.editor.pbrRenderer.clear(),this.veState.basicConfig.workspaceSize[0]===this.editor.pbrRenderer.getWidth()&&this.veState.basicConfig.workspaceSize[1]===this.editor.pbrRenderer.getHeight()&&this.veState.basicConfig.workspaceSize[2]===this.editor.pbrRenderer.getDepth()||this.editor.pbrRenderer.updateBounds(this.veState.basicConfig.workspaceSize[0],this.veState.basicConfig.workspaceSize[1],this.veState.basicConfig.workspaceSize[2]);for(let e=0;e{void 0===e&&(e=document.getElementById("sampleProgress")),e&&(e.style.width=100*t+"%")}}}registerTouchEvent(){this.camera.rotateLock=!0,document.body.addEventListener("touchmove",this.onTouchMove),document.body.addEventListener("touchend",this.onTouchEnd)}attachEvent(){this.camera.attachEventListener(),document.body.addEventListener("mousedown",this.onmousedown),document.body.addEventListener("keydown",this.onkeydown),document.body.addEventListener("keyup",this.onkeyup),document.body.addEventListener("mousemove",this.onmousemove),document.body.addEventListener("mouseup",this.onmouseup),document.body.addEventListener("dragover",this.ondragover),document.body.addEventListener("drop",this.ondrop),document.body.addEventListener("touchstart",this.ontouchStart,{passive:!1});const e=setInterval(()=>{this.voxel_editor_ele=document.getElementById("voxel-editor"),null!==this.voxel_editor_ele&&clearInterval(e)},20)}releaseEvent(){document.body.removeEventListener("mousedown",this.onmousedown),document.body.removeEventListener("keydown",this.onkeydown),document.body.removeEventListener("keyup",this.onkeyup),document.body.removeEventListener("mousemove",this.onmousemove),document.body.removeEventListener("mouseup",this.onmouseup),document.body.removeEventListener("dragover",this.ondragover),document.body.removeEventListener("drop",this.ondrop),document.body.removeEventListener("touchstart",this.ontouchStart),this.camera.releaseEventListener()}}},1607:function(e,t,i){"use strict";i.d(t,"a",(function(){return v}));var s=i(229),o=i(220),n=i(1357),r=i(66),a=i(3);let l=void 0;function h(e,t){return{DrawSolidPrgm:()=>{},DrawAlphaPrgm:()=>{}}}var c=i(552),d=i(192),p=i(309),u=i(434);var f=i(1387),m=i(411);class g{constructor(e,t,i){this.post={exposure:.00411307405202814,gamma:2.2};const s=t.subarray(0,4*i);this.vbo=e.buffer(s),this.attrib0={buffer:this.vbo,offset:0,stride:d.c,normalized:!1,size:4,divisor:0},this.attrib1={buffer:this.vbo,offset:4,stride:d.c,normalized:!1,size:4,divisor:0},this.attrib2={buffer:this.vbo,offset:8,stride:d.c,normalized:!1,size:4,divisor:0},this.attrib3={buffer:this.vbo,offset:12,stride:d.c,normalized:!1,size:4,divisor:0},this.count=i/8*3}update(e,t){if(t){const i=e.subarray(0,4*t);this.vbo(i),this.count=t/8*3}}destroy(){this.vbo.destroy()}}class v{constructor(e,t,o,n){this.forceBlockRender=!1,this.name="",this.renderTerrain=!1,this.wireframeColor=[.6,.6,.6],this.inflate=!1,this.preserveRawMeshData=!1,this.renderTempGeo=!1,this.voxelPoints=[],this._needBakeData=!1,this._callbackList=[],this._receive_ack=0,this._renderGrid=!1,this.geom=void 0,this.alphaGeom=void 0,this.fluidGeom=void 0,this.vertexCount=0,this.terrainData=void 0,this._w=Object(m.a)(1609,{cdnPath:n}).worker,o.name&&(this.name=o.name),o.wireframeColor&&(this.wireframeColor=o.wireframeColor),this._editor=o.editor,this.veState=o.veState;const d=this;this.meshBuffer=e.buffer(4096),this.rawMeshBuffer=new Uint8Array(0),this.cIndexBuffer=new Uint8Array(0),this.temporarayGeoData={positions:[],normals:[],elements:[],colors:[]},this.voxelPoints=void 0,this.modelMatrix=a.b.create(),this.regl=e,this.voxels=o.voxels,this.faceLightness=[.6,.7,.75,1,.5,.4,.1],this._ack=0,this.lo=[1/0,1/0,1/0],this.hi=[-1/0,-1/0,-1/0],this.drawAOmeshCmd=function(e){return l||(l=e({frag:i(1518),vert:i(1519),cull:{enable:!0,face:"back"},attributes:{s0:{buffer:e.prop("mesh"),offset:0,stride:8,size:4,divisor:0,normalized:!1},s1:{buffer:e.prop("mesh"),offset:4,stride:8,size:4,divisor:0,normalized:!1}},uniforms:{time:e.context("tick"),polishing:e.prop("polishing"),inflate:e.prop("inflate"),wireframeColor:e.prop("wireframeColor"),model:e.prop("model"),showGrid:e.prop("showGrid"),"Lightness[0]":e.prop("faceLightness[0]"),"Lightness[1]":e.prop("faceLightness[1]"),"Lightness[2]":e.prop("faceLightness[2]"),"Lightness[3]":e.prop("faceLightness[3]"),"Lightness[4]":e.prop("faceLightness[4]"),"Lightness[5]":e.prop("faceLightness[5]"),"Lightness[6]":e.prop("faceLightness[6]"),lo:e.prop("lo"),hi:e.prop("hi")},primitive:"triangles",count:e.prop("count")})),l}(e),this.drawTerrainCmd=t.require(h),this._w.addEventListener("message",(function(t){d._receive_ack=t.data[1];const i=t.data[0];if(d.preserveRawMeshData&&d._callbackList.length)return void d._callbackList[0](i);const o=d._editor.paletteManager.getCurrentColorTable().getRGBArray(),n={};if(d.rawMeshBuffer&&d.rawMeshBuffer.length&&(Object(r.c)(d.rawMeshBuffer),Object(r.c)(d.cIndexBuffer)),i){d.cIndexBuffer=new Uint8Array(i.length/8);let t=0;if(d.renderTerrain)d.renderTerrain&&(d.terrainData=i);else{for(let e=0;e{n&&(e[0]=Math.min(e[0],i),e[1]=Math.min(e[1],s),e[2]=Math.min(e[2],o),t[0]=Math.max(t[0],i),t[1]=Math.max(t[1],s),t[2]=Math.max(t[2],o))}),{lo:e,hi:t}}isEmpty(){for(let e=0;e{const i=function(e,t,i){const s=e.length/8/6,o=new Uint8Array(Object(r.a)(6*s));Object(p.a)(o,0);let n=0;const a=Math.min,l=Math.max,h={},c=[{},{},{},{},{},{}];for(let r=0;r<6;r++)for(let d=0;dNumber(e));t=t.sort((e,t)=>e-t),f[d++]=e,f[d++]=t.length;for(let i=0;i0&&s.push([t[0]-e[0],e[1],e[2]]),i.Mirror.y>0){const e=s.length;for(let i=0;i0){const e=s.length;for(let i=0;i{if(!(e<0||e>=f.shape[0]||s<0||s>=f.shape[1]||o<0||o>=f.shape[2])){const n=m.index(e,s,o);t==d.a.Attach?m.data[n]=m.data[n]||i:(t==d.a.Erase||t==d.a.Paint&&m.data[n])&&(m.data[n]=i)}}):n===d.b.square&&Object(d.o)(m,i,a,o,r)}}t.default=function(){self.addEventListener("message",(function(e){const t=e.data[0];if(t==d.f.syncVoxel){const t=e.data[1],i=[e.data[2][0],e.data[2][1],e.data[2][2]];v=e.data[5];const[s,o,n]=i,r=1,a=s,h=a*o;if(null==f||f.shape[0]==i[0]&&f.shape[1]==i[1]&&f.shape[2]==i[2]||f&&(Object(l.c)(f),Object(l.c)(m)),null==f||f.shape[0]!=i[0]||f.shape[1]!=i[1]||f.shape[2]!=i[2]){f=new l.a(t,[s,o,n],[r,a,h],0),m=Object(l.b)(s,o,n);for(let e=0;ee-1),(e,t,i,s)=>{0!=s&&b.push([e,t,i]),m.setVoxel(e,t,i,s)})}else if(t==d.f.changeSize){const t=e.data[1];f&&(Object(l.c)(f),Object(l.c)(m),f=Object(d.h)(t[0],t[1],t[2]),m=Object(d.h)(t[0],t[1],t[2]))}else if(t==d.f.updateVoxel){const t=e.data[1],i=e.data[2],s=e.data[3],o=e.data[4],n=e.data[5];if(t==d.a.Attach){if(n==d.c.box){const e=Object(d.i)(s[0],s[1],[0,0,0],f.shape.map(e=>e-1));Object(d.z)(f,e.start,e.end,(e,t,i,s,n)=>{0==s&&(m.data[n]=o)})}else if(n==d.c.center)_(e,d.a.Attach,o);else if(n===d.c.face){const t=e.data[2],i=e.data[3][1],s=Math.abs(i),o=e.data[3][0],n=e.data[6],r=Math.abs(o),a=i>0?1:-1;for(let e=0;es;e--,l-=a){let e=[];0!=t[0]?e.push([i[0]+l,i[1],i[2]]):t[1]!=[0]?e.push([i[0],i[1]+l,i[2]]):t[2]!=[0]&&e.push([i[0],i[1],i[2]+l]),e=y(e[0],f.shape.map(e=>e-1),n);const s=e.length;for(let t=0;te-1),n);const s=e.length;for(let t=0;tf.getVoxel(e,t,i),o,(e,t,i)=>0!=f.getVoxel(e,t,i));else if(n==d.c.center)_(e,d.a.Paint,o);else if(n==d.c.face){const t=e.data[2],i=e.data[3][1],s=Math.abs(i),n=e.data[3][0],r=e.data[6],a=Math.abs(n),l=i>0?1:-1;for(let e=0;ee-1),r);const i=e.length;for(let t=0;te-1),r);const i=e.length,s=f.index(h[0],h[1],h[2]);for(let t=0;tf.getVoxel(e,t,i),0,()=>!0);else if(n==d.c.center)_(e,d.a.Erase,0);else if(n==d.c.face){const t=e.data[2],i=e.data[3][1],s=Math.abs(i),n=e.data[3][0],r=e.data[6],a=Math.abs(n),l=i>0?1:-1;for(let e=0;ee-1),r);const i=e.length;for(let t=0;te-1),r);const i=e.length;for(let t=0;t{f.data[o]=0,m.data[o]=0})}))};let E},1614:function(e,t,i){"use strict";i.r(t),i.d(t,"default",(function(){return c}));var s=i(1),o=i.n(s),n=i(555),r=i.n(n),a=i(77),l=i(1501),h=i(62);class c extends o.a.Component{constructor(e){super(e),this._sensorsReport=()=>{var e,t;const i=new h.a,s={is_first_open:!this.props.loadModel,voxel_name:(null==(e=this.props.loadModel)?void 0:e.name)||"",voxel_id:(null==(t=this.props.loadModel)?void 0:t.content_id)||"",triggered_from:this.handler.editor.connectedToGameEditor?h.b.GAME_EDITOR:h.b.CONTENT_PAGE};i.track(h.c.OPEN_VOXEL_EDITOR,s)},this.handler=e.handler,this.handler||(this.handler=this.init()),e.loadModel&&this.handler.editor.loadBackendContent(e.loadModel)}componentDidMount(){this._sensorsReport()}init(){const e=r()({extensions:["OES_element_index_uint","OES_standard_derivatives"],optionalExtensions:["OES_texture_float","EXT_color_buffer_float","OES_texture_float_linear","OES_texture_half_float","EXT_color_buffer_half_float","OES_texture_half_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","EXT_disjoint_timer_query"],attributes:{alpha:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!0}}),t=new l.a({regl:e,content:this.props.content,logger:this.props.logger,brpc:this.props.brpc});let i=!1;(this.props.canvas||document.createElement("canvas")).getContext("2d");return Object(a.a)(e,!1,e._gl.canvas.getContext("2d")),e.frame(s=>{if(!i)return e._gl.canvas.style.maxWidth="initial",e._gl.canvas.style.maxHeight="initial",e._gl.canvas.style.width="0%",e._gl.canvas.style.position="absolute",e._gl.canvas.style.zIndex="0",void(e._gl.canvas.style.transform="initial");e._gl.canvas.style.maxWidth="initial",e._gl.canvas.style.maxHeight="initial",e._gl.canvas.style.width="100%",e._gl.canvas.style.height="100%",e._gl.canvas.style.position="fixed",e._gl.canvas.style.top="0",e._gl.canvas.style.left="0",e._gl.canvas.style.zIndex="0",e._gl.canvas.style.transform="initial",t.voxelEditorFrameCB()}),{editor:t,setRendering:e=>{i=e},isRendering:()=>i}}render(){const e=this.handler.editor;return e.renderDom({onOpen:()=>{this.handler.setRendering(!0),e.startFrame().catch(e=>this.props.logger.error(e.toString()))},onClose:()=>{this.handler.setRendering(!1),e.stopFrame(),this.props.onClose()},onHandleLogin:this.props.onHandleLogin})}}},192:function(e,t,i){"use strict";i.d(t,"a",(function(){return s})),i.d(t,"c",(function(){return o})),i.d(t,"b",(function(){return c}));const s=8,o=16,n=[0,4,1,5];function r(e){return e+(e>>>8)+(e>>>16)+(e>>>24)&255}function a(e){return 252645135&(e|e<<12)}function l(e){return 1&e^1}function h(e){return e>>1<<27}class c{constructor(e,t,i,s){this.blockIndex=e,this.meshPtr=0,this.alphaPtr=0,this.fluidPtr=0;const n=t*i*s*o*6;this.meshBuffer=new Uint8Array(n),this.meshBuffer32=new Uint32Array(this.meshBuffer.buffer),this.alphaBuffer=new Uint8Array(n),this.alphaBuffer32=new Uint32Array(this.alphaBuffer.buffer),this.fluidBuffer=new Uint8Array(n),this.fluidBuffer32=new Uint32Array(this.fluidBuffer.buffer),this.nx=t,this.ny=i,this.nz=s}mesh(e,t){const{nx:i,ny:s,nz:o}=this;this.meshPtr=0,this.alphaPtr=0,this.fluidPtr=0;const[n,r,a]=e.stride,l=e.data;let h=e.offset+n+r+a;const c=-n-r-a,d=-n-r,p=-n-r+a,u=-n-a,f=-n,m=-n+a,g=-n+r-a,v=-n+r,b=-n+r+a,x=-r-a,y=-r,_=-r+a,E=-a,M=+a,S=r-a,w=r,C=r+a,P=+n-r-a,k=+n-r,R=+n-r+a,I=+n-a,O=+n,j=+n+a,T=+n+r-a,N=+n+r;for(let e=0;e>>12,m>>>12,g>>>12,v>>>12,b>>>12,x>>>12,y>>>12,_>>>12,E>>>12);const z=(l(M)||l(S))&&a(f),H=a(m),U=(l(M)||l(w))&&a(g),F=a(v),G=a(b),W=a(x),Y=(l(C)||l(S))&&a(y),X=a(_),q=(l(C)||l(w))&&a(E);let Z=e?this.meshPtr:this.alphaPtr;const K=e?this.meshBuffer32:this.alphaBuffer32,Q=V>>>14;let J=0;0===u?u=n[4-Q&3]:4===u?u=n[4-Q+1&3]:1===u?u=n[4-Q+2&3]:5===u?u=n[4-Q+3&3]:3===u?J|=Q<<20:2===u&&(J|=(3&-Q)<<20),J|=this.blockIndex.texture[6*d+u];let $=0;if(!l(V)){const e=l(O)&&l(P)&&l(j),t=l(O)&&l(k)&&l(T),i=l(O)&&l(I)&&l(D),s=l(O)&&l(R)&&l(N);$=3===u&&1===Q||2===u&&3===Q?s<<3|t<<2|i<<1|e:3===u&&3===Q||2===u&&1===Q?i<<3|e<<2|s<<1|t:3===u&&2===Q||2===u&&2===Q?t<<3|i<<2|e<<1|s:e<<3|s<<2|t<<1|i}const ee=J|$<<16;r(z)+r(q)>r(Y)+r(U)?(K[Z++]=L,K[Z++]=z+(H<<4),K[Z++]=F+(G<<4),K[Z++]=ee,K[Z++]=L+h,K[Z++]=H+(U<<4),K[Z++]=G+(W<<4),K[Z++]=ee,K[Z++]=L+c,K[Z++]=F+(G<<4),K[Z++]=Y+(X<<4),K[Z++]=ee,K[Z++]=L+h+c,K[Z++]=G+(W<<4),K[Z++]=X+(q<<4),K[Z++]=ee):(K[Z++]=L+h,K[Z++]=H+(U<<4),K[Z++]=G+(W<<4),K[Z++]=ee,K[Z++]=L+h+c,K[Z++]=G+(W<<4),K[Z++]=X+(q<<4),K[Z++]=ee,K[Z++]=L,K[Z++]=z+(H<<4),K[Z++]=F+(G<<4),K[Z++]=ee,K[Z++]=L+c,K[Z++]=F+(G<<4),K[Z++]=Y+(X<<4),K[Z++]=ee),e?this.meshPtr=Z:this.alphaPtr=Z}_emitFluidFace(e,t,i,s,o,n,r,a,l,c,d,p,u,f,m){const g=this.blockIndex.fluidInfo,v=g[o],b=g[n];if(b&&v)return;let x=t;b&&(x=t&~(1<<24)|function(e){switch(e){case 4:return 5;case 5:return 4;case 0:return 1;case 1:return 0;case 3:return 2;default:return 3}}(x>>24));let y=this.fluidPtr;const _=this.fluidBuffer32,E=b|v;r+m>u+l?(_[y++]=x|h(r+a+c+d),_[y++]=E,_[y++]=x+i|h(a+l+d+p),_[y++]=E,_[y++]=x+s|h(c+d+u+f),_[y++]=E,_[y++]=x+i+s|h(d+p+f+m),_[y++]=E):(_[y++]=x+i|h(a+l+d+p),_[y++]=E,_[y++]=x+i+s|h(d+p+f+m),_[y++]=E,_[y++]=x|h(r+a+c+d),_[y++]=E,_[y++]=x+s|h(c+d+u+f),_[y++]=E),this.fluidPtr=y}}},20:function(e,t,i){"use strict";i.d(t,"b",(function(){return n})),i.d(t,"c",(function(){return r})),i.d(t,"a",(function(){return a})),i.d(t,"d",(function(){return l})),i.d(t,"e",(function(){return h}));var s=i(0),o=i(113);const n=5,r=1<>1)-1:e>>1}function r(e){let t=1227133513&e;return t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),t=1023&(t|t>>>16),t<<22>>>22}function a(e){const t=e.readVarint(),i=e.readVarint(),a=new Array(t);for(let i=0;i>>1),v=r(p>>>2);i.minX=n(m)+h&s.a,i.minY=n(g)+c&s.a,i.minZ=n(v)+d&s.a;const b=r(u),x=r(u>>>1),y=r(u>>>2);i.maxX=b+i.minX,i.maxY=x+i.minY,i.maxZ=y+i.minZ,i.block=a[f],i.faces=0,h=i.minX,c=i.minY,d=i.minZ}return l}function l(e,t){const{data:i,stride:[s,o,n],offset:r}=e;for(let e=0;e(e[e.default=0]="default",e[e.monochrome=1]="monochrome",e[e.mvColorScheme=2]="mvColorScheme",e[e.eightBit=3]="eightBit",e[e.custom=4]="custom",e))(s||{});const o="updateColor";function n(e){const t=e[0],i=e[1],s=e[2];return(Math.floor(t/32)<<5)+(Math.floor(i/32)<<2)+Math.floor(s/64)}function r(e,t,i){return Array.isArray(e)?"#"+a(e[0])+a(e[1])+a(e[2]):"#"+a(e)+a(t)+a(i)}function a(e){return e=parseInt(e,10),isNaN(e)?"00":(e=Math.max(0,Math.min(e,255)),"0123456789ABCDEF".charAt((e-e%16)/16)+"0123456789ABCDEF".charAt(e%16))}function l(e){const t=new Float32Array(3);return 7===e.length&&"#"==e[0]?(t[0]=parseInt(e.slice(1,3),16)/255,t[1]=parseInt(e.slice(3,5),16)/255,t[2]=parseInt(e.slice(5,7),16)/255):6===e.length&&(t[0]=parseInt(e.slice(0,2),16)/255,t[1]=parseInt(e.slice(2,4),16)/255,t[2]=parseInt(e.slice(4,6),16)/255),t}let h='[{"r":255,"g":255,"b":255,"a":255},{"r":220,"g":159,"b":180,"a":255},{"r":225,"g":107,"b":140,"a":255},{"r":142,"g":53,"b":74,"a":255},{"r":248,"g":195,"b":205,"a":255},{"r":244,"g":167,"b":185,"a":255},{"r":100,"g":54,"b":60,"a":255},{"r":245,"g":150,"b":170,"a":255},{"r":181,"g":73,"b":91,"a":255},{"r":232,"g":122,"b":144,"a":255},{"r":208,"g":90,"b":110,"a":255},{"r":219,"g":77,"b":109,"a":255},{"r":254,"g":223,"b":225,"a":255},{"r":158,"g":122,"b":122,"a":255},{"r":208,"g":16,"b":76,"a":255},{"r":159,"g":53,"b":58,"a":255},{"r":203,"g":27,"b":69,"a":255},{"r":238,"g":169,"b":169,"a":255},{"r":191,"g":103,"b":102,"a":255},{"r":134,"g":71,"b":63,"a":255},{"r":177,"g":150,"b":147,"a":255},{"r":235,"g":122,"b":119,"a":255},{"r":149,"g":74,"b":69,"a":255},{"r":169,"g":99,"b":96,"a":255},{"r":203,"g":64,"b":66,"a":255},{"r":171,"g":59,"b":58,"a":255},{"r":215,"g":196,"b":187,"a":255},{"r":144,"g":72,"b":64,"a":255},{"r":115,"g":67,"b":56,"a":255},{"r":199,"g":62,"b":58,"a":255},{"r":85,"g":66,"b":54,"a":255},{"r":153,"g":70,"b":57,"a":255},{"r":241,"g":148,"b":131,"a":255},{"r":181,"g":68,"b":52,"a":255},{"r":185,"g":136,"b":125,"a":255},{"r":241,"g":124,"b":103,"a":255},{"r":136,"g":76,"b":58,"a":255},{"r":232,"g":48,"b":21,"a":255},{"r":215,"g":84,"b":85,"a":255},{"r":181,"g":93,"b":76,"a":255},{"r":133,"g":72,"b":54,"a":255},{"r":163,"g":94,"b":71,"a":255},{"r":204,"g":84,"b":58,"a":255},{"r":114,"g":72,"b":50,"a":255},{"r":247,"g":92,"b":47,"a":255},{"r":106,"g":64,"b":40,"a":255},{"r":154,"g":80,"b":52,"a":255},{"r":196,"g":98,"b":67,"a":255},{"r":175,"g":95,"b":60,"a":255},{"r":251,"g":150,"b":110,"a":255},{"r":114,"g":73,"b":56,"a":255},{"r":180,"g":113,"b":87,"a":255},{"r":219,"g":142,"b":113,"a":255},{"r":240,"g":94,"b":28,"a":255},{"r":237,"g":120,"b":74,"a":255},{"r":202,"g":120,"b":83,"a":255},{"r":179,"g":92,"b":55,"a":255},{"r":86,"g":63,"b":46,"a":255},{"r":227,"g":145,"b":110,"a":255},{"r":143,"g":90,"b":60,"a":255},{"r":240,"g":169,"b":134,"a":255},{"r":160,"g":103,"b":75,"a":255},{"r":193,"g":105,"b":60,"a":255},{"r":251,"g":153,"b":102,"a":255},{"r":148,"g":122,"b":109,"a":255},{"r":163,"g":99,"b":54,"a":255},{"r":231,"g":148,"b":96,"a":255},{"r":125,"g":83,"b":44,"a":255},{"r":199,"g":133,"b":80,"a":255},{"r":152,"g":95,"b":42,"a":255},{"r":225,"g":166,"b":121,"a":255},{"r":133,"g":91,"b":50,"a":255},{"r":252,"g":159,"b":77,"a":255},{"r":255,"g":186,"b":132,"a":255},{"r":233,"g":139,"b":42,"a":255},{"r":233,"g":163,"b":104,"a":255},{"r":177,"g":120,"b":68,"a":255},{"r":150,"g":99,"b":46,"a":255},{"r":202,"g":122,"b":44,"a":255},{"r":67,"g":52,"b":27,"a":255},{"r":236,"g":184,"b":138,"a":255},{"r":120,"g":85,"b":43,"a":255},{"r":176,"g":119,"b":54,"a":255},{"r":150,"g":114,"b":73,"a":255},{"r":226,"g":148,"b":59,"a":255},{"r":199,"g":128,"b":45,"a":255},{"r":155,"g":110,"b":35,"a":255},{"r":110,"g":85,"b":47,"a":255},{"r":235,"g":180,"b":113,"a":255},{"r":215,"g":185,"b":142,"a":255},{"r":130,"g":102,"b":58,"a":255},{"r":182,"g":142,"b":85,"a":255},{"r":188,"g":159,"b":119,"a":255},{"r":135,"g":102,"b":51,"a":255},{"r":193,"g":138,"b":38,"a":255},{"r":255,"g":177,"b":27,"a":255},{"r":209,"g":152,"b":38,"a":255},{"r":221,"g":165,"b":45,"a":255},{"r":201,"g":152,"b":51,"a":255},{"r":249,"g":191,"b":69,"a":255},{"r":220,"g":184,"b":121,"a":255},{"r":186,"g":145,"b":50,"a":255},{"r":232,"g":182,"b":71,"a":255},{"r":247,"g":194,"b":66,"a":255},{"r":125,"g":108,"b":70,"a":255},{"r":218,"g":201,"b":166,"a":255},{"r":250,"g":214,"b":137,"a":255},{"r":217,"g":171,"b":66,"a":255},{"r":246,"g":197,"b":85,"a":255},{"r":255,"g":196,"b":8,"a":255},{"r":239,"g":187,"b":36,"a":255},{"r":202,"g":173,"b":95,"a":255},{"r":141,"g":116,"b":42,"a":255},{"r":180,"g":165,"b":130,"a":255},{"r":135,"g":127,"b":108,"a":255},{"r":137,"g":125,"b":85,"a":255},{"r":116,"g":103,"b":62,"a":255},{"r":162,"g":140,"b":55,"a":255},{"r":108,"g":96,"b":36,"a":255},{"r":134,"g":120,"b":53,"a":255},{"r":98,"g":89,"b":44,"a":255},{"r":233,"g":205,"b":76,"a":255},{"r":247,"g":217,"b":76,"a":255},{"r":251,"g":226,"b":81,"a":255},{"r":217,"g":205,"b":144,"a":255},{"r":173,"g":161,"b":66,"a":255},{"r":221,"g":210,"b":59,"a":255},{"r":165,"g":160,"b":81,"a":255},{"r":190,"g":194,"b":63,"a":255},{"r":108,"g":106,"b":45,"a":255},{"r":147,"g":150,"b":80,"a":255},{"r":131,"g":138,"b":45,"a":255},{"r":177,"g":180,"b":121,"a":255},{"r":97,"g":97,"b":56,"a":255},{"r":75,"g":78,"b":42,"a":255},{"r":91,"g":98,"b":46,"a":255},{"r":77,"g":81,"b":57,"a":255},{"r":137,"g":145,"b":107,"a":255},{"r":144,"g":180,"b":75,"a":255},{"r":145,"g":173,"b":112,"a":255},{"r":181,"g":202,"b":160,"a":255},{"r":100,"g":106,"b":88,"a":255},{"r":123,"g":162,"b":63,"a":255},{"r":134,"g":193,"b":102,"a":255},{"r":74,"g":89,"b":61,"a":255},{"r":66,"g":96,"b":45,"a":255},{"r":81,"g":110,"b":65,"a":255},{"r":145,"g":180,"b":147,"a":255},{"r":128,"g":143,"b":124,"a":255},{"r":27,"g":129,"b":62,"a":255},{"r":93,"g":172,"b":129,"a":255},{"r":54,"g":86,"b":60,"a":255},{"r":34,"g":125,"b":81,"a":255},{"r":168,"g":216,"b":185,"a":255},{"r":106,"g":131,"b":114,"a":255},{"r":45,"g":109,"b":75,"a":255},{"r":70,"g":93,"b":76,"a":255},{"r":36,"g":147,"b":110,"a":255},{"r":134,"g":166,"b":151,"a":255},{"r":0,"g":137,"b":108,"a":255},{"r":9,"g":97,"b":72,"a":255},{"r":32,"g":96,"b":79,"a":255},{"r":15,"g":76,"b":58,"a":255},{"r":79,"g":114,"b":108,"a":255},{"r":0,"g":170,"b":144,"a":255},{"r":105,"g":176,"b":172,"a":255},{"r":38,"g":69,"b":61,"a":255},{"r":102,"g":186,"b":183,"a":255},{"r":38,"g":135,"b":133,"a":255},{"r":64,"g":91,"b":85,"a":255},{"r":48,"g":90,"b":86,"a":255},{"r":120,"g":194,"b":196,"a":255},{"r":55,"g":107,"b":109,"a":255},{"r":165,"g":222,"b":228,"a":255},{"r":119,"g":150,"b":154,"a":255},{"r":102,"g":153,"b":161,"a":255},{"r":129,"g":199,"b":212,"a":255},{"r":51,"g":166,"b":184,"a":255},{"r":12,"g":72,"b":66,"a":255},{"r":13,"g":86,"b":97,"a":255},{"r":0,"g":137,"b":167,"a":255},{"r":51,"g":103,"b":116,"a":255},{"r":37,"g":83,"b":89,"a":255},{"r":30,"g":136,"b":168,"a":255},{"r":86,"g":108,"b":115,"a":255},{"r":87,"g":124,"b":138,"a":255},{"r":88,"g":178,"b":220,"a":255},{"r":43,"g":95,"b":117,"a":255},{"r":58,"g":143,"b":183,"a":255},{"r":46,"g":92,"b":110,"a":255},{"r":0,"g":98,"b":132,"a":255},{"r":125,"g":185,"b":222,"a":255},{"r":81,"g":168,"b":221,"a":255},{"r":46,"g":169,"b":223,"a":255},{"r":11,"g":16,"b":19,"a":255},{"r":15,"g":37,"b":64,"a":255},{"r":8,"g":25,"b":45,"a":255},{"r":0,"g":92,"b":175,"a":255},{"r":11,"g":52,"b":110,"a":255},{"r":123,"g":144,"b":210,"a":255},{"r":110,"g":117,"b":164,"a":255},{"r":38,"g":30,"b":71,"a":255},{"r":17,"g":50,"b":133,"a":255},{"r":78,"g":79,"b":151,"a":255},{"r":33,"g":30,"b":85,"a":255},{"r":139,"g":129,"b":195,"a":255},{"r":112,"g":100,"b":154,"a":255},{"r":155,"g":144,"b":194,"a":255},{"r":138,"g":107,"b":190,"a":255},{"r":106,"g":76,"b":156,"a":255},{"r":143,"g":119,"b":181,"a":255},{"r":83,"g":61,"b":91,"a":255},{"r":178,"g":143,"b":206,"a":255},{"r":152,"g":109,"b":178,"a":255},{"r":119,"g":66,"b":141,"a":255},{"r":60,"g":47,"b":65,"a":255},{"r":74,"g":34,"b":93,"a":255},{"r":102,"g":50,"b":124,"a":255},{"r":89,"g":44,"b":99,"a":255},{"r":111,"g":51,"b":129,"a":255},{"r":87,"g":76,"b":87,"a":255},{"r":180,"g":129,"b":187,"a":255},{"r":63,"g":43,"b":54,"a":255},{"r":87,"g":42,"b":63,"a":255},{"r":94,"g":61,"b":80,"a":255},{"r":114,"g":99,"b":110,"a":255},{"r":98,"g":41,"b":84,"a":255},{"r":109,"g":46,"b":91,"a":255},{"r":193,"g":50,"b":142,"a":255},{"r":168,"g":73,"b":122,"a":255},{"r":86,"g":46,"b":55,"a":255},{"r":224,"g":60,"b":138,"a":255},{"r":96,"g":55,"b":62,"a":255},{"r":252,"g":250,"b":242,"a":255},{"r":255,"g":255,"b":251,"a":255},{"r":189,"g":192,"b":186,"a":255},{"r":145,"g":152,"b":159,"a":255},{"r":120,"g":125,"b":123,"a":255},{"r":112,"g":124,"b":116,"a":255},{"r":101,"g":103,"b":101,"a":255},{"r":83,"g":89,"b":83,"a":255},{"r":79,"g":79,"b":72,"a":255},{"r":82,"g":67,"b":61,"a":255},{"r":55,"g":60,"b":56,"a":255},{"r":58,"g":50,"b":38,"a":255},{"r":238,"g":238,"b":238,"a":255},{"r":221,"g":221,"b":221,"a":255},{"r":187,"g":187,"b":187,"a":255},{"r":170,"g":170,"b":170,"a":255},{"r":136,"g":136,"b":136,"a":255},{"r":119,"g":119,"b":119,"a":255},{"r":85,"g":85,"b":85,"a":255},{"r":68,"g":68,"b":68,"a":255},{"r":34,"g":34,"b":34,"a":255},{"r":17,"g":17,"b":17,"a":255}]';h=JSON.parse(h);const c=["#FF5050","#FFAF00","#FFD236","#C3EB37","#23AF41","#73E1C8","#82D2F0","#5FA7FF","#4173F5","#AA64D7","#FF87F5","#FFB4CD","#AF6E28","#FFEDDB","#D7D7D7","#FFFFFF","#A7DACA"];function d(e){e.push(void 0);let t=0;for(t=0;te/255))}class p{constructor(e){this._messages={},this.colorsRgb=[],this.MSE=[],this.TR=[],this._currentIndex=1,e||(e={type:0}),this.initColor(e);for(let e=0;e>5),32*((28&t)>>2),64*(3&t)];e.push([s[0]/255,s[1]/255,s[2]/255])}var t;e.push([236/255,236/255,226/255])}(this.colorsRgb);break;case 1:!function(e){e.push(void 0);for(let t=1;t<=255;t++){const i=246/255*(t-127.5)+123;e[t]=[i/255,i/255,i/255]}}(this.colorsRgb);break;case 2:!function(e){e.push(void 0);for(let t=0;t255*e)).slice(1));return e}getHexColorById(e){return r(this.colorsRgb[e].map(e=>255*e)).slice(1)}getRgbById(e){return this.colorsRgb[e]}getRgbColorById(e){return[this.colorsRgb[e][0],this.colorsRgb[e][1],this.colorsRgb[e][2]]}getRGBArray(){const e=[];e.push({r:0,g:0,b:0});for(let t=1;t256?console.warn("color index out of range",e):this._currentIndex=e}getCurrentColor(){return{index:this._currentIndex,colorHex:this.colorsRgb[this._currentIndex]}}updateColor(e,t){if(!(e<1&&e>256)&&("string"==typeof t&&(t=l(t)),r(255*t[0],255*t[1],255*t[2])!==r(255*this.colorsRgb[e][0],255*this.colorsRgb[e][1],255*this.colorsRgb[e][2]))){const i=this.colorsRgb[e].splice(0);this.colorsRgb[e][0]=t[0],this.colorsRgb[e][1]=t[1],this.colorsRgb[e][2]=t[2],this.fire(o,{index:e,preColor:i,currColor:t})}}updatePBRProperties(e,t){e<1&&e>256||this.MSE[e][0]===t[0]&&this.MSE[e][1]===t[1]&&this.MSE[e][2]===t[2]||(this.MSE[e][0]=t[0],this.MSE[e][1]=t[1],this.MSE[e][2]=t[2])}updateTR(e,t){e<1&&e>256||this.TR[e][0]===t[0]&&this.TR[e][1]===t[1]||(this.TR[e][0]=t[0],this.TR[e][1]=t[1])}getColor(e){if(!(e<1||e>256))return this.colorsRgb[e]}getPBRProperties(e){if(!(e<1||e>256))return this.MSE[e]}getTRProperties(e){if(!(e<1||e>256))return this.TR[e]}on(e,t){return void 0===this._messages[e]?this._messages[e]=[t]:this._messages[e].push(t),this}fire(e,t){if(void 0!==this._messages[e]){{const i={event:e,args:t||{}},s=this._messages[e].length;for(let t=0;t=0;i--)this._messages[e][i]===t&&this._messages[e].splice(i,1)}return this}removeAll(e){return this._messages[e]instanceof Array&&this._messages[e].splice(0),this}}},319:function(e,t,i){"use strict";i.d(t,"d",(function(){return r})),i.d(t,"h",(function(){return d})),i.d(t,"g",(function(){return p})),i.d(t,"c",(function(){return u})),i.d(t,"b",(function(){return f})),i.d(t,"e",(function(){return m})),i.d(t,"f",(function(){return g})),i.d(t,"i",(function(){return v})),i.d(t,"a",(function(){return b}));var s=i(0),o=i(434);const n=new s.a,r=new o.b,a=(new s.t(0),new s.r("")),l=new s.r,h=new s.b(new s.u,1/0),c=(new s.q({meshBuffer:h,pbrBuffer:h}),new s.q({name:a}),new s.q({name:a,projectData:l}),new s.q({name:a,previewImg:new s.r}),new s.q({name:a,requestId:new s.r,contentId:new s.j,handle:n,meshData:r,projectData:l,previewImg:new s.r})),d=(new s.q({requestId:new s.r,model:new s.r}),new s.q({model:new s.r,requestId:new s.r,handle:n}),new s.q({requestId:new s.r,contentId:new s.j,meshHash:new s.r,projectHash:new s.r,previewHash:new s.r,handle:n})),p=(new s.q({handle:n,new_name:new s.r}),new s.q({handle:n,requestId:new s.r}),{name:"VoxelEditor",client:{saveDataEcho:d},server:{postMetaBundle:c}});var u=(e=>(e[e.empty=0]="empty",e[e.firstShakeHand=1]="firstShakeHand",e[e.projectInfo=2]="projectInfo",e[e.savedModel=3]="savedModel",e[e.closeEcho=4]="closeEcho",e))(u||{}),f=(e=>(e[e.gameEditor=0]="gameEditor",e[e.voxelEditor=1]="voxelEditor",e))(f||{});const m=new s.q({name:new s.r,hash:new s.a,userId:new s.w(0),contentId:new s.w(0)}),g=new s.q({name:new s.r,projectHash:new s.a,previewHash:new s.a}),v="veBridgeMsg",b=new s.q({name:new s.r(v),type:new s.u,data:new s.v({empty:new s.a(""),modelParam:m,savedResult:g}),from:new s.u})},35:function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));const s=()=>{throw new Error("cannot serialize references")};class o{constructor(){this.identity=null,this.muType="ref",this.muData={type:"ref"},this.json={type:"ref"},this.diff=s,this.patch=s,this.toJSON=s,this.fromJSON=s}alloc(){return null}free(){}assign(e,t){return t}clone(e){return e}equal(e,t){return e===t}}},468:function(e,t,i){"use strict";function s(e,t,i){t&&(e.grow(10),e.writeVarint(t-1),e.writeVarint(i))}function o(e,t){const{data:i,shape:[o,n,r],stride:[a,l,h],offset:c}=e;let d=-1,p=0,u=c;const f=a,m=l-a*o,g=h-l*n;for(let e=0;e=p)return!1;const t=e[m++];if(t<255)f=t;else{if(m+1>=p)return!1;f=(e[m]<<8)+e[m+1],m+=2}if(m>=p)return!1;const i=e[m++];if(i<255)u=i;else{if(m+1>=p)return!1;u=(e[m]<<8)+e[m+1],m+=2}}o[_]=u,f-=1,_+=b}_+=x}_+=y}return m===e.length&&0===f}(e,t,[0,0,0],t.shape.map(e=>e-1))}i.d(t,"a",(function(){return o})),i.d(t,"b",(function(){return n})),i.d(t,"c",(function(){return r}))},469:function(e,t,i){"use strict";i.d(t,"a",(function(){return h}));var s=i(66),o=i(309);function n(e,t){const i=15*(538976288+(252645135&(e|e<<12))-(252645135&(t|t<<12))&269488144);return 65535&(i>>>4|i>>>16)}function r(e,t){return e^(e^t)&n(e,t)}function a(e){const t=522133279+(252645135&(e|e<<12)),i=t+((269488144&t)>>>4)&252645135;return i+(i>>>12)&65535}function l(e,t){const i=e^t,s=252645135&(i|i<<12),o=s|s<<1|s>>>2,n=252645135&~(o|o<<2|o>>>1);return n+(n>>>12)&65535}class h{constructor(e,t,i=!1){this.blockIndex=e,this.nx=0,this.ny=0,this.nz=0,this.sx=0,this.sy=0,this.sz=0,this.ADD_PTR=0,this.REMOVE_PTR=0,this.ADD_XLO=0,this.ADD_YLO=0,this.ADD_ZLO=0,this.ADD_XHI=0,this.ADD_YHI=0,this.ADD_ZHI=0,this.voxels=t,this.MIN_LIGHT=i?53248:0;const o=this.nx=t.shape[0],n=this.ny=t.shape[1],r=this.nz=t.shape[2];this.sx=t.stride[0],this.sy=t.stride[1],this.sz=t.stride[2];const a=this.nx*this.nz*2;this.yRays=new Int16Array(Object(s.a)(a)),this.lightLevel=new Uint16Array(Object(s.a)(o*n*r*4));const l=Math.pow(33,2)*Math.max(33,3*(o+r));this.ADD_QUEUE=new Uint16Array(Object(s.a)(6*l)),this.REMOVE_QUEUE=new Uint32Array(Object(s.a)(16*l)),this.recalcRays(),this.recalcLightLevel()}pushAdd(e,t,i){ethis.ADD_XHI||tthis.ADD_YHI||ithis.ADD_ZHI||(this.ADD_QUEUE[this.ADD_PTR++]=e,this.ADD_QUEUE[this.ADD_PTR++]=t,this.ADD_QUEUE[this.ADD_PTR++]=i)}pushRemove(e,t,i,s){this.REMOVE_QUEUE[this.REMOVE_PTR++]=e,this.REMOVE_QUEUE[this.REMOVE_PTR++]=t,this.REMOVE_QUEUE[this.REMOVE_PTR++]=i,this.REMOVE_QUEUE[this.REMOVE_PTR++]=s}_isTransparent(e){return 1&e^1}destroy(){Object(s.c)(this.yRays.buffer),Object(s.c)(this.lightLevel.buffer),Object(s.c)(this.ADD_QUEUE.buffer),Object(s.c)(this.REMOVE_QUEUE.buffer)}recalcRays(){const{nx:e,ny:t,nz:i,yRays:s,voxels:n}=this;Object(o.a)(s,-1);for(let o=0;o>>0;e>d&&(r=(61440|r)>>>0),!r&&this._isTransparent(h[t])&&(r=(r|this.MIN_LIGHT)>>>0),l[t]=r}}for(let r=0;r=this.MIN_LIGHT)return e;return-61441&e|this.MIN_LIGHT}_addLights(){const{nx:e,ny:t,nz:i,sx:s,sy:o,sz:n,voxels:l,lightLevel:h}=this,c=l.data;for(let l=0;l0){const e=f-s;if(this._isTransparent(c[e])){const t=h[e],i=this._minLight(r(t,m));i!==t&&(h[e]=i,this.pushAdd(d-1,p,u))}}if(d0){const e=f-o;if(this._isTransparent(c[e])){const t=h[e],i=this._minLight(r(t,m));i!==t&&(h[e]=i,this.pushAdd(d,p-1,u))}}if(p0){const e=f-n;if(this._isTransparent(c[e])){const t=h[e],i=this._minLight(r(t,m));i!==t&&(h[e]=i,this.pushAdd(d,p,u-1))}}if(u0&&this._removeLightValue(t-1,i,r,a),t0&&this._removeLightValue(t,i-1,r,a),i0&&this._removeLightValue(t,i,r-1,a),r0&&a[d-e]&&this.pushAdd(l-1,h,c),l0&&a[d-t]&&this.pushAdd(l,h-1,c),h0&&a[d-i]&&this.pushAdd(l,h,c-1),c0&&(x=h[g-c]),e0&&(x=r(x,h[g-d])),t0&&(x=r(x,h[g-p])),iu){if(f=f||1&c.getVoxel(e,t,i),f){for(let s=u+1;s<=t;++s){const t=c.index(e,s,i),o=d[t];d[t]&=-61441,this.pushRemove(e,s,i,61440&o)}h[p]=t}}else if(t===u){let s=c.index(e,t,i);const o=c.data;let n=t;for(;n>=0&&!(1&o[s]);)d[s]|=61440,this.pushAdd(e,n--,i),s-=a;h[p]=n}}updateLight(e,t,i){const{lightLevel:s,voxels:o}=this;this.ADD_PTR=0,this.REMOVE_PTR=0,this.ADD_XLO=0,this.ADD_YLO=0,this.ADD_ZLO=0,this.ADD_XHI=this.nx-1,this.ADD_YHI=this.ny-1,this.ADD_ZHI=this.nz-1;const n=o.index(e,t,i),r=o.data[n];this._updateHeight(e,t,i);const a=s[n];this.pushRemove(e,t,i,1&r?a:4095&a),s[n]=1&r?0:61440&a,this._removeLights(),s[n]|=this.blockIndex.emissive[4095&o.data[n]],this.pushAdd(e,t,i),this._addLights()}_sampleLightInt(e,t,i,s,o){const{nx:n,ny:r,nz:a,lightLevel:l,voxels:h}=this,c=Math.min(Math.max(i,0),n-2),d=Math.min(Math.max(s,0),r-2),p=Math.min(Math.max(o,0),a-2),u=h.index(c,d,p);if(1&h.data[u])return 0;const f=l[u];return e.r+=t*((15&f)/15),e.g+=t*((240&f)/240),e.b+=t*((3840&f)/3840),e.a+=t*((61440&f)/61440),t}sampleLight(e,t,i,s){const o=Math.floor(t),n=Math.floor(i),r=Math.floor(s),a=t-o,l=i-n,h=s-r,c=1-a,d=1-l,p=1-h;e.r=e.g=e.b=e.a=0;let u=0;if(u+=this._sampleLightInt(e,c*d*p,o,n,r),u+=this._sampleLightInt(e,c*d*h,o,n,r+1),u+=this._sampleLightInt(e,c*l*p,o,n+1,r),u+=this._sampleLightInt(e,c*l*h,o,n+1,r+1),u+=this._sampleLightInt(e,a*d*p,o+1,n,r),u+=this._sampleLightInt(e,a*d*h,o+1,n,r+1),u+=this._sampleLightInt(e,a*l*p,o+1,n+1,r),u+=this._sampleLightInt(e,a*l*h,o+1,n+1,r+1),u){const t=1/u;e.r*=t,e.r=Math.min(1,e.r/(16-15*e.r)),e.g*=t,e.g=Math.min(1,e.g/(16-15*e.g)),e.b*=t,e.b=Math.min(1,e.b/(16-15*e.b)),e.a*=t,e.a=Math.min(1,e.a/(16-15*e.a))}}}},552:function(e,t,i){"use strict";i.d(t,"a",(function(){return s}));const s={HOTKEYACTION:"Action-HotKey",REBUILDCOLORTABLE:"BuildCoilor",SELECTCOLOR:"SelectColor",UPDATECOLOR:"UpdateColor",CHOICECOLORTABLE:"ChoiceColorTable",PICKCOLOR:"PickColor",CHANGECOLOR:"ChagneColor",CHANGESIZE:"CHANGESIZE",DESELECT:"DESELECT",SAVE:"SAVE",FINISHEDEYEDROPPER:"FINISHEDEYEDROPPER",CLEARALLMODEL:"clearAllModel",SWITCHTOOLS:"switchTools",CHANGEEDITIONMODE:"changeEditionMode",UPDATEBASICCONFIG:"UpdateBasicConfig",TOGGLEBLOCKWIREFRAME:"toggleBlockWireFrame",TOGGLEPAINTERCHECKBOARD:"togglePainterCheckBoard",UPDATEMODELCOLOR:"updateModelColor",PBRPORPERTYCHANGE:"pbrporpertyChange",CLOSECOLORPICKER:"closeColorPicker",SHOWCOLORPICKER:"showColorPicker",MODETOGGLE:"modeToggle",PROCESSTOGGLE:"processToggle",UPDATEDIALOGSTATE:"updateDialogState",DIALOGPOPOUT:"dialogPopOut",DIALOGVANISH:"dialogVanish",PREVIEWLISTUPDATE:"previewListUpdate",PROJECTINFOCHANGE:"projectInfoChange",ONINFOTEXTCHANGE:"onInfoTextChange",STATUS_COORD_CHANGE:"STATUS_COORD_CHANGE",FORCEUPDATETOPBAR:"forceUpdateTopBar",PROJECTLOADINGSTART:"projectLoadingStart",PROJECTLOADINGFINISHED:"projectLoadingFinished"}},554:function(e,t,i){const s=i(1005),o=i(1006);e.exports=function(e,t){var i=t,n=e.readInt32LE(i);i+=4;for(var r,a,l={},h=0;ht in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,d=(e,t)=>{for(var i in t||(t={}))l.call(t,i)&&c(e,i,t[i]);if(a)for(var i of a(t))h.call(t,i)&&c(e,i,t[i]);return e},p=(e,t)=>n(e,r(t));class u{constructor(e,t,i){this.flagFunc=e,this.flags=t,this.cmd=i}test(e){const{flags:t,flagFunc:i}=this;for(let s=0;sn[e]);function g(e){const t=[];for(let i=0;i0){for(let t=e;t>0;--t)l[t]=l[t-1];l[0]=t}return t.cmd}}return function(i){const o=m.map(e=>+e(i)),n=e(p(d({},s),{frag:g(o)+h,vert:g(o)+c,profile:t}));return l.unshift(new u(m,o,n)),n}(i)}return a.push(v),v},require:function(t){const s=o.indexOf(t);if(s>=0)return n[s];const r=t(e,c,i);return o.push(t),n.push(r),r},stats:()=>{const e={};return Object.keys(r).map(t=>{const i=r[t],s={count:0,cpuTime:0,gpuTime:0};for(let e=0;et)}},917:function(e,t){e.exports=function(e,t){return String.fromCharCode(parseInt(e[t++]))+String.fromCharCode(parseInt(e[t++]))+String.fromCharCode(parseInt(e[t++]))+String.fromCharCode(parseInt(e[t++]))}},919:function(e,t,i){const s=i(257).Buffer,o=i(992),n=i(995),r=i(996),a=i(997);e.exports=function(e){var t=e;if(!o(t))try{t=new s(new Uint8Array(e))}catch(e){throw e}var i=n(t),l=a(t,8,t.length,i);return l.RGBA||(l.RGBA=r()),Object.assign(i,l)}},976:function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var s=i(552),o=i(307);class n{constructor(e,t){this._editor=e;const i=[o.a.default,o.a.mvColorScheme,o.a.monochrome,o.a.eightBit];if(t&&null!=t.HEXCOLORS){this.colorTables=[];for(let e=0;e * @license MIT */ e.exports=function(e){return null!=e&&(i(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&i(e.slice(0,0))}(e)||!!e._isBuffer)}},995:function(e,t,i){const s=i(917);e.exports=function(e){var t={};return t[s(e,0)]=e.readInt32LE(4),t}},996:function(e,t){const i=[0,16777215,13434879,10092543,6750207,3407871,65535,16764159,13421823,10079487,6737151,3394815,52479,16751103,13408767,10066431,6724095,3381759,39423,16738047,13395711,10053375,6711039,3368703,26367,16724991,13382655,10040319,6697983,3355647,13311,16711935,13369599,10027263,6684927,3342591,255,16777164,13434828,10092492,6750156,3407820,65484,16764108,13421772,10079436,6737100,3394764,52428,16751052,13408716,10066380,6724044,3381708,39372,16737996,13395660,10053324,6710988,3368652,26316,16724940,13382604,10040268,6697932,3355596,13260,16711884,13369548,10027212,6684876,3342540,204,16777113,13434777,10092441,6750105,3407769,65433,16764057,13421721,10079385,6737049,3394713,52377,16751001,13408665,10066329,6723993,3381657,39321,16737945,13395609,10053273,6710937,3368601,26265,16724889,13382553,10040217,6697881,3355545,13209,16711833,13369497,10027161,6684825,3342489,153,16777062,13434726,10092390,6750054,3407718,65382,16764006,13421670,10079334,6736998,3394662,52326,16750950,13408614,10066278,6723942,3381606,39270,16737894,13395558,10053222,6710886,3368550,26214,16724838,13382502,10040166,6697830,3355494,13158,16711782,13369446,10027110,6684774,3342438,102,16777011,13434675,10092339,6750003,3407667,65331,16763955,13421619,10079283,6736947,3394611,52275,16750899,13408563,10066227,6723891,3381555,39219,16737843,13395507,10053171,6710835,3368499,26163,16724787,13382451,10040115,6697779,3355443,13107,16711731,13369395,10027059,6684723,3342387,51,16776960,13434624,10092288,6749952,3407616,65280,16763904,13421568,10079232,6736896,3394560,52224,16750848,13408512,10066176,6723840,3381504,39168,16737792,13395456,10053120,6710784,3368448,26112,16724736,13382400,10040064,6697728,3355392,13056,16711680,13369344,10027008,6684672,3342336,238,221,187,170,136,119,85,68,34,17,60928,56576,47872,43520,34816,30464,21760,17408,8704,4352,15597568,14483456,12255232,11141120,8912896,7798784,5570560,4456448,2228224,1114112,15658734,14540253,12303291,11184810,8947848,7829367,5592405,4473924,2236962,1118481];e.exports=function(){return i.map((function(e){return{b:(16711680&e)>>16,g:(65280&e)>>8,r:255&e,a:1}}))}},997:function(e,t,i){const s=i(998),o=i(917);e.exports=function e(t,i,n,r){var a=i,l=o(t,i),h=t.readInt32LE(a+=4);a+=4;var c=t.readInt32LE(a),d=(i=i,a+=4),p=h,u=a+h+(c=c);if(0==p&&0==c)return r;if(p&&l){var f=s(t,l,d,u);r[l]?r[l]&&r[l].length&&r[l].push(f):r[l]="RGBA"===l?f:[f]}return c>0?e(t,d+p,n,{}):u!=n?e(t,u,n,r):r}},998:function(e,t,i){const s=i(999),o=i(1e3),n={SIZE:s,XYZI:i(1001),RGBA:o,PACK:i(1002),MATT:i(1003),LAYR:i(1004),nTRN:i(1007),nGRP:i(1008),nSHP:i(1009),rOBJ:i(1010)};e.exports=function(e,t,i,s){if(n[t])return n[t](e,i,s)}},999:function(e,t){e.exports=function(e,t){var i=t,s=e.readInt32LE(i);i+=4;var o=e.readInt32LE(i);i+=4;var n=e.readInt32LE(i);return i+=4,{x:s,y:o,z:n}}}}]);