!function(z,o,p){"use strict";var C="ht",c=z[C],i=null,A=Math,B=A.PI,w=A.cos,j=A.sin,H=A.abs,O=A.max,T=A.sqrt,h=1e-5,b=c.Default,E=b.def,f=b.startAnim,q=b.createMatrix,N=b.transformVec,L=b.getInternal(),K=L.addMethod,W=L.superCall,G=L.toPointsArray,x=L.createNormals,U=L.toFloatArray,X=L.glMV,v=L.batchShape,$=L.createNodeMatrix,d=L.getFaceInfo,t=L.transformAppend,V=L.drawFaceInfo,P=L.createAnim,Y=L.cube(),Z=Y.is,l=Y.vs,R=Y.uv,g=L.ui(),I=c.Node,u=c.Shape,M="h",J="v",s="front",F="back",m="left",n="right",r="top",D="bottom",e="dw.expanded",k=".expanded",S="dw.angle",Q=".angle",a=function(X,S,Z){E(C+"."+X,S,Z)},_=function(h,n,O){O?h.push(n.x,n.y):h.push(n.x,n.y,n.z)},y=[1,0,0],Vg=function(O,H,K,t){var l,b,$,f,h=0,u=[];if(t)for(l=t.length;l>h;h+=3)b=t[h],$=t[h+1],f=t[h+2],u.push(new Np([new bi([H[3*b],H[3*b+1],H[3*b+2]],y,K?[K[2*b],K[2*b+1],0]:i),new bi([H[3*$],H[3*$+1],H[3*$+2]],y,K?[K[2*$],K[2*$+1],0]:i),new bi([H[3*f],H[3*f+1],H[3*f+2]],y,K?[K[2*f],K[2*f+1],0]:i)],O));else for(l=H.length;l>h;h+=3)b=h,$=h+1,f=h+2,u.push(new Np([new bi([H[3*b],H[3*b+1],H[3*b+2]],y,K?[K[2*b],K[2*b+1],0]:i),new bi([H[3*$],H[3*$+1],H[3*$+2]],y,K?[K[2*$],K[2*$+1],0]:i),new bi([H[3*f],H[3*f+1],H[3*f+2]],y,K?[K[2*f],K[2*f+1],0]:i)],O));return u},Nl=[m,s,n,F,r,D],Te=Nl.concat("csg"),Er=[0,6,12,18,24,30],df=function(r,b,w){for(var Q=$(r),Y=[],P=0;6>P;P++)for(var x=Nl[P],C=Er[P],s=w?b.getFaceUv(r,x):i,D=w?b.getFaceUvScale(r,x):i,G=w?b.getFaceUvOffset(r,x):i,A=0;2>A;A++){var J,p,W,S=Z[C+3*A],d=Z[C+3*A+1],M=Z[C+3*A+2];if(w){if(s){var k=8*P;J=[s[2*S-k],s[2*S+1-k],0],p=[s[2*d-k],s[2*d+1-k],0],W=[s[2*M-k],s[2*M+1-k],0]}else J=[R[2*S],R[2*S+1],0],p=[R[2*d],R[2*d+1],0],W=[R[2*M],R[2*M+1],0];D&&(J[0]*=D[0],J[1]*=D[1],p[0]*=D[0],p[1]*=D[1],W[0]*=D[0],W[1]*=D[1]),G&&(J[0]+=G[0],J[1]+=G[1],p[0]+=G[0],p[1]+=G[1],W[0]+=G[0],W[1]+=G[1])}Y.push(new Np([new bi(N([l[3*S],l[3*S+1],l[3*S+2]],Q),y,J),new bi(N([l[3*d],l[3*d+1],l[3*d+2]],Q),y,p),new bi(N([l[3*M],l[3*M+1],l[3*M+2]],Q),y,W)],r))}return Jj.$15n(Y)},jn=function(k,l){var L,j=k.data.getAttaches();if(j&&j.each(function(K){K instanceof ym&&K.s("attach.operation")&&(L||(L=[]),L.push(K))}),L){var J;Nl.forEach(function(A){var m=Vg(A,k[A].vs,k[A].tuv);J=J?J.concat(m):m}),J=Jj.$15n(J),L.forEach(function(Y){var h=Y.s("attach.operation");J[h]&&(J=J[h](df(Y,k.gv,k.csg.tuv)))}),Nl.forEach(function(R){R=k[R],R.vs=[],R.tuv&&(R.tuv=[])}),J.$19n().forEach(function(c){var q=c.$10n;if(q instanceof ym){if(q.s("attach.cull"))return;q="csg"}for(var C=k[q],o=C.vs,u=C.tuv,g=c.$9n,T=2;T$;$++)for(var z=0;U>z;z++)D=[],M($/X,z/U),z>0&&M(($+1)/X,z/U),U-1>z&&M(($+1)/X,(z+1)/U),M($/X,(z+1)/U),A.push(new Np(D));return Jj.$15n(A)},Jj.cylinder=function(s){function b(e,X,x){var P=2*X*B,f=i.$21n(w(P)).$20n(n.$21n(j(P))),l=Y.$20n(D.$21n(e)).$20n(f.$21n(c)),y=f.$21n(1-H(x)).$20n(m.$21n(x));return new bi(l,y)}s=s||{};for(var Y=new Fn(s.start||[0,-1,0]),X=new Fn(s.end||[0,1,0]),D=X.$13n(Y),c=s.radius||1,A=s.slices||16,m=D.$14n(),L=H(m.y)>.5,i=new Fn(L,!L,0).$12n(m).$14n(),n=i.$12n(m).$14n(),Z=new bi(Y,m.$11n()),d=new bi(X,m.$14n()),a=[],p=0;A>p;p++){var l=p/A,P=(p+1)/A;a.push(new Np([Z,b(0,l,-1),b(0,P,-1)])),a.push(new Np([b(0,P,0),b(0,l,0),b(1,l,0),b(1,P,0)])),a.push(new Np([d,b(1,P,1),b(1,l,1)]))}return Jj.$15n(a)};var Fn=function(S,M,Y){var P=this;3==arguments.length?(P.x=S,P.y=M,P.z=Y):"x"in S?(P.x=S.x,P.y=S.y,P.z=S.z):(P.x=S[0],P.y=S[1],P.z=S[2])};Fn.prototype={clone:function(){return new Fn(this.x,this.y,this.z)},$11n:function(){return new Fn(-this.x,-this.y,-this.z)},$20n:function(n){return new Fn(this.x+n.x,this.y+n.y,this.z+n.z)},$13n:function(G){return new Fn(this.x-G.x,this.y-G.y,this.z-G.z)},$21n:function(k){return new Fn(this.x*k,this.y*k,this.z*k)},$16n:function(G){return new Fn(this.x/G,this.y/G,this.z/G)},$23n:function(X){return this.x*X.x+this.y*X.y+this.z*X.z},lerp:function(l,J){return this.$20n(l.$13n(this).$21n(J))},length:function(){return T(this.$23n(this))},$14n:function(){return this.$16n(this.length())},$12n:function(U){var M=this;return new Fn(M.y*U.z-M.z*U.y,M.z*U.x-M.x*U.z,M.x*U.y-M.y*U.x)}};var bi=function(Q,s,V){var F=this;F.$24n=new Fn(Q),F.$22n=new Fn(s),F.uv=V?new Fn(V):null};bi.prototype={clone:function(){var D=this;return new bi(D.$24n.clone(),D.$22n.clone(),D.uv?D.uv.clone():null)},flip:function(){this.$22n=this.$22n.$11n()},$18n:function(C,x){var D=this;return new bi(D.$24n.lerp(C.$24n,x),D.$22n.lerp(C.$22n,x),D.uv?D.uv.lerp(C.uv,x):null)}};var Fd=function(j,y){this.$22n=j,this.w=y};Fd.$17n=function(K,e,E){var T=e.$13n(K).$12n(E.$13n(K)).$14n();return new Fd(T,T.$23n(K))},Fd.prototype={clone:function(){return new Fd(this.$22n.clone(),this.w)},flip:function(){var R=this;R.$22n=R.$22n.$11n(),R.w=-R.w},$5n:function(c,x,s,u,r){for(var f=this,Z=0,y=1,W=2,d=3,R=0,E=[],q=0;qk?W:k>h?y:Z;R|=O,E.push(O)}switch(R){case Z:(f.$22n.$23n(c.$8n.$22n)>0?x:s).push(c);break;case y:u.push(c);break;case W:r.push(c);break;case d:for(var C=[],H=[],q=0;q=3&&u.push(new Np(C,c.$10n)),H.length>=3&&r.push(new Np(H,c.$10n))}}};var Np=function(i,w){var C=this;C.$9n=i,C.$10n=w,C.$8n=Fd.$17n(i[0].$24n,i[1].$24n,i[2].$24n)};Np.prototype={clone:function(){var z=this.$9n.map(function(n){return n.clone()});return new Np(z,this.$10n)},flip:function(){this.$9n.reverse().map(function(X){X.flip()}),this.$8n.flip()}};var zm=function(l){var O=this;O.$8n=null,O.front=null,O.back=null,O.$4n=[],l&&O.$7n(l)};zm.prototype={clone:function(){var L=this,K=new zm;return K.$8n=L.$8n&&L.$8n.clone(),K.front=L.front&&L.front.clone(),K.back=L.back&&L.back.clone(),K.$4n=L.$4n.map(function(i){return i.clone()}),K},$6n:function(){for(var b=this,Z=0;ZF;F++)for(var q=Nl[F],d=Er[F],B=p.vf2(q,i,z),o=B.mat||c,e=B.vs,D=B.uv,r=B.tuv,M=0;2>M;M++){var g=Z[d+3*M],u=Z[d+3*M+1],V=Z[d+3*M+2];if(t(e,o,[l[3*g],l[3*g+1],l[3*g+2]]),t(e,o,[l[3*u],l[3*u+1],l[3*u+2]]),t(e,o,[l[3*V],l[3*V+1],l[3*V+2]]),r)if(D){var N=8*F;r.push(D[2*g-N],D[2*g+1-N],D[2*u-N],D[2*u+1-N],D[2*V-N],D[2*V+1-N])}else r.push(R[2*g],R[2*g+1],R[2*u],R[2*u+1],R[2*V],R[2*V+1])}jn(p,P,z)},vf2:function(P,o,s){var X,n=this,G=n.gv.getFaceVisible(n.data,P);return X=d(n,P,s),X.vs=[],X.tuv=G&&(X.texture||o)?[]:i,X.visible=G,X}});var vm=c.CSGShape=function(){var r=this;W(vm,r),r.s({"shape.background":i,"shape.border.width":8}),r.setTall(240),r.setElevation(120),r.setThickness(14)};a("CSGShape",u,{IRotatable:!1,_22Q:function(){return Am},setRotationX:function(){},setRotation:function(){},setRotationZ:function(){},setSegments:function(){}});var Am=function(Z,h){W(Am,this,[Z,h])};E(Am,g.Shape3dUI,{_80o:function(h,T,m){var e=this;e.undrawable||(X(e.gv),Te.forEach(function(u){V(e,h,T,e[u],m)}))},validate:function(A,w){var a=this,I=a.data,D=I.getPoints();if(a.undrawable=D.size()<2)return a.clear(),void 0;var k=I.isClosePath(),z=O(I._thickness/2,h),j=G(D,i,i,k);Te.forEach(function(D){a.vf(D,A&&A.uv,!0,w)}),k&&(a.left.visible=!1,a.right.visible=!1),a._12O(j,z),a._20Q(j),jn(a,A,w)}});var tb=c.DoorWindow=function(){var _=this;W(tb,_),_.setElevation(100),_.s3(100,200,14)};a("DoorWindow",ym,{IDoorWindow:!0,toggle:function(P){this.setExpanded(!this.s(e),P)},isExpanded:function(){return this.s(e)},setExpanded:function(J,j){var T,z=this,C=z.$25n,D=z.getDataModel(),r=z.s(e);if(D&&(T=D.getHistoryManager()),C&&(C.stop(!0),delete z.$25n),r!==J){T&&T.beginInteraction();var N=J?z.s("dw.end"):z.s("dw.start");z.s(e,J),j=P(j),j?(r=z.s(S),j.action=function(h){z.s(S,r+(N-r)*h)},j.finishFunc=function(){T&&T.endInteraction()},z.$25n=f(j)):(z.s(S,N),T&&T.endInteraction())}},getMat:function(){var f=this,s=f.s("dw.s3"),b=f.s("dw.t3"),L=f.s("dw.flip"),z=f.s(S);if(s||z||b||L){var t=[];if(L&&t.push({r3:[0,B,0]}),s&&t.push({s3:s}),z){s=f.s3();var P=f.s("dw.axis"),T=s[0]/2,h=s[1]/2;s[2]/2,P===m?t.push({t3:[T,0,0]},{r3:[0,-z,0]},{t3:[-T,0,0]}):P===n?t.push({t3:[-T,0,0]},{r3:[0,z,0]},{t3:[T,0,0]}):P===r?t.push({t3:[0,-h,0]},{r3:[-z,0,0]},{t3:[0,h,0]}):P===D?t.push({t3:[0,h,0]},{r3:[z,0,0]},{t3:[0,-h,0]}):P===J?t.push({r3:[0,z,0]}):P===M&&t.push({r3:[z,0,0]})}return b&&t.push({t3:b}),q(t)}return i}});var _k=c.CSGBox=function(){var f=this;W(_k,f),f.setElevation(100),f.s3(100,200,100)};a("CSGBox",ym,{ICSGBox:!0,toggleFace:function(l,Y){this.setFaceExpanded(l,!this.s(l+k),Y)},isFaceExpanded:function(N){return this.s(N+k)},setFaceExpanded:function(Z,j,B){var X=this,y=X.$25n,p=X.s(Z+k);if(y&&(y.stop(!0),delete X.$25n),p!==j){var C=j?X.s(Z+".end"):X.s(Z+".start");X.s(Z+k,j),B=P(B),B?(p=X.s(Z+Q),B.action=function(z){X.s(Z+Q,p+(C-p)*z)},X.$25n=f(B)):X.s(Z+Q,C)}},getFaceMat:function(k){var V=this,u=V.s(k+Q);if(!u)return i;var X=V.s(k+".axis"),H=V.s3(),K=H[0]/2,p=H[1]/2,v=H[2]/2,g=[];return k===s&&(X===m?g.push({t3:[K,0,-v]},{r3:[0,-u,0]},{t3:[-K,0,v]}):X===n?g.push({t3:[-K,0,-v]},{r3:[0,u,0]},{t3:[K,0,v]}):X===r?g.push({t3:[0,-p,-v]},{r3:[-u,0,0]},{t3:[0,p,v]}):X===D?g.push({t3:[0,p,-v]},{r3:[u,0,0]},{t3:[0,-p,v]}):X===J?g.push({t3:[0,0,-v]},{r3:[0,u,0]},{t3:[0,0,v]}):X===M&&g.push({t3:[0,0,-v]},{r3:[u,0,0]},{t3:[0,0,v]})),k===F&&(X===m?g.push({t3:[-K,0,v]},{r3:[0,-u,0]},{t3:[K,0,-v]}):X===n?g.push({t3:[K,0,v]},{r3:[0,u,0]},{t3:[-K,0,-v]}):X===r?g.push({t3:[0,-p,v]},{r3:[u,0,0]},{t3:[0,p,-v]}):X===D?g.push({t3:[0,p,v]},{r3:[-u,0,0]},{t3:[0,-p,-v]}):X===J?g.push({t3:[0,0,v]},{r3:[0,u,0]},{t3:[0,0,-v]}):X===M&&g.push({t3:[0,0,v]},{r3:[u,0,0]},{t3:[0,0,-v]})),k===m&&(X===m?g.push({t3:[K,0,v]},{r3:[0,-u,0]},{t3:[-K,0,-v]}):X===n?g.push({t3:[K,0,-v]},{r3:[0,u,0]},{t3:[-K,0,v]}):X===r?g.push({t3:[K,-p,0]},{r3:[0,0,-u]},{t3:[-K,p,0]}):X===D?g.push({t3:[K,p,0]},{r3:[0,0,u]},{t3:[-K,-p,0]}):X===J?g.push({t3:[K,0,0]},{r3:[0,u,0]},{t3:[-K,0,0]}):X===M&&g.push({t3:[K,0,0]},{r3:[0,0,u]},{t3:[-K,0,0]})),k===n&&(X===m?g.push({t3:[-K,0,-v]},{r3:[0,-u,0]},{t3:[K,0,v]}):X===n?g.push({t3:[-K,0,v]},{r3:[0,u,0]},{t3:[K,0,-v]}):X===r?g.push({t3:[-K,-p,0]},{r3:[0,0,u]},{t3:[K,p,0]}):X===D?g.push({t3:[-K,p,0]},{r3:[0,0,-u]},{t3:[K,-p,0]}):X===J?g.push({t3:[-K,0,0]},{r3:[0,u,0]},{t3:[K,0,0]}):X===M&&g.push({t3:[-K,0,0]},{r3:[0,0,u]},{t3:[K,0,0]})),k===r&&(X===m?g.push({t3:[K,-p,0]},{r3:[0,0,u]},{t3:[-K,p,0]}):X===n?g.push({t3:[-K,-p,0]},{r3:[0,0,-u]},{t3:[K,p,0]}):X===r?g.push({t3:[0,-p,v]},{r3:[-u,0,0]},{t3:[0,p,-v]}):X===D?g.push({t3:[0,-p,-v]},{r3:[u,0,0]},{t3:[0,p,v]}):X===J?g.push({t3:[0,-p,0]},{r3:[0,0,u]},{t3:[0,p,0]}):X===M&&g.push({t3:[0,-p,0]},{r3:[u,0,0]},{t3:[0,p,0]})),k===D&&(X===m?g.push({t3:[K,p,0]},{r3:[0,0,-u]},{t3:[-K,-p,0]}):X===n?g.push({t3:[-K,p,0]},{r3:[0,0,u]},{t3:[K,-p,0]}):X===r?g.push({t3:[0,p,-v]},{r3:[-u,0,0]},{t3:[0,-p,v]}):X===D?g.push({t3:[0,p,v]},{r3:[u,0,0]},{t3:[0,-p,-v]}):X===J?g.push({t3:[0,p,0]},{r3:[0,0,u]},{t3:[0,-p,0]}):X===M&&g.push({t3:[0,p,0]},{r3:[u,0,0]},{t3:[0,-p,0]})),q(g)}})}("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:this,Object);