suyiScreen/public/htWeb/lib/plugin/ht-modeling.js

1 line
23 KiB
JavaScript

!function(p,X,m){"use strict";function $($,z){this.position=$,this.$22n=z}var l="ht",G=p[l],S=null,h=Math,b=h.PI,y=h.cos,Z=h.sin,r=h.abs,I=h.max,g=h.sqrt,t=1e-5,E=G.Default,A=E.def,Q=E.startAnim,J=E.createMatrix,V=E.transformVec,M=E.getInternal(),L=M.addMethod,F=M.superCall,x=M.toPointsArray,n=M.createNormals,C=M.toFloatArray,d=M.glMV,o=(M.glPop,G.graph3d.Graph3dView,G.Math),w=o.Vector3,Y=o.Matrix4,j=o.Euler,f=(o.Quaternion,M.batchShape),_=M.createNodeMatrix,D=M.getFaceInfo,P=M.transformAppend,s=M.drawFaceInfo,N=M.createAnim,O=M.cube(),H=O.is,e=O.vs,T=O.uv,B=M.ui(),c=G.Node,W=G.Shape,i="h",v="v",z="front",a="back",q="left",u="right",K="top",R="bottom",U="dw.expanded",k=".expanded",Iq="dw.angle",sj=".angle",yn=function(Z,b,j){A(l+"."+Z,b,j)},ok=function(n,y,i){i?n.push(y.x,y.y):n.push(y.x,y.y,y.z)},$i=function(){var a=new G.Math.Vector3,A=new G.Math.Vector3,h=new G.Math.Vector3;return function(c,J,w,i,V){if(a.copy(J.$24n),A.copy(w.$24n),h.copy(i.$24n),!(h.equals(a)||A.equals(a)||A.equals(h))){if(!J.$22n||!w.$22n||!i.$22n){var Y=A.sub(a).cross(h.sub(a)).normalize().multiplyScalar(1).toArray();J.$22n||(J.$22n=new Gp(Y)),w.$22n||(w.$22n=new Gp(Y)),i.$22n||(i.$22n=new Gp(Y))}c.push(new Zm([J,w,i],V))}}}(),Ym=function(b,K,X,s){var o,y,d,e,$=0,T=[];if(s)for(o=s.length;o>$;$+=3)y=s[$],d=s[$+1],e=s[$+2],$i(T,new Yk([K[3*y],K[3*y+1],K[3*y+2]],null,X?[X[2*y],X[2*y+1],0]:S),new Yk([K[3*d],K[3*d+1],K[3*d+2]],null,X?[X[2*d],X[2*d+1],0]:S),new Yk([K[3*e],K[3*e+1],K[3*e+2]],null,X?[X[2*e],X[2*e+1],0]:S),b);else for(o=K.length/3;o>$;$+=3)y=$,d=$+1,e=$+2,$i(T,new Yk([K[3*y],K[3*y+1],K[3*y+2]],null,X?[X[2*y],X[2*y+1],0]:S),new Yk([K[3*d],K[3*d+1],K[3*d+2]],null,X?[X[2*d],X[2*d+1],0]:S),new Yk([K[3*e],K[3*e+1],K[3*e+2]],null,X?[X[2*e],X[2*e+1],0]:S),b);return T},Af=[q,z,u,a,K,R],Ld=["",K,R],kp=Af.concat("csg"),tg=[0,6,12,18,24,30],vl=function(A,K,d){var j=_(A),w=[];A.appendAnchorMatrix3d(j);var s,g=K?K.getData3dUI(A):null;if(g&&g.s("shape3d")&&!g.s("csg.cull.box")&&(s=g.shapeModel,g.shapeModel||(s=M.getShapeModel(g,g.s("shape3d"))),s))for(var U=M.createNormalMatrix(j),l=0,t=Ld.length;t>l;l++){var E=Ld[l],P=E.length?E+"_":E,$=s[P+"vs"],N=s[P+"uv"],n=s[P+"is"],c=s[P+"ns"];if($&&$.length)for(var x,y,o,G=0,b=n?n.length:$.length/3;b>G;G+=3)n?(x=n[G],y=n[G+1],o=n[G+2]):(x=G,y=G+1,o=G+2),$i(w,new Yk(V([$[3*x],$[3*x+1],$[3*x+2]],j),c?V([c[3*x],c[3*x+1],c[3*x+2]],U):null,[N[2*x],N[2*x+1],0]),new Yk(V([$[3*y],$[3*y+1],$[3*y+2]],j),c?V([c[3*y],c[3*y+1],c[3*y+2]],U):null,[N[2*y],N[2*y+1],0]),new Yk(V([$[3*o],$[3*o+1],$[3*o+2]],j),c?V([c[3*o],c[3*o+1],c[3*o+2]],U):null,[N[2*o],N[2*o+1],0]),A)}if(!s)for(var l=0;6>l;l++)for(var E=Af[l],p=tg[l],N=d?K.getFaceUv(A,E):S,h=d?K.getFaceUvScale(A,E):S,F=d?K.getFaceUvOffset(A,E):S,r=0;2>r;r++){var u,i,X,k=H[p+3*r],C=H[p+3*r+1],q=H[p+3*r+2];if(d){if(N){var W=8*l;u=[N[2*k-W],N[2*k+1-W],0],i=[N[2*C-W],N[2*C+1-W],0],X=[N[2*q-W],N[2*q+1-W],0]}else u=[T[2*k],T[2*k+1],0],i=[T[2*C],T[2*C+1],0],X=[T[2*q],T[2*q+1],0];h&&(u[0]*=h[0],u[1]*=h[1],i[0]*=h[0],i[1]*=h[1],X[0]*=h[0],X[1]*=h[1]),F&&(u[0]+=F[0],u[1]+=F[1],i[0]+=F[0],i[1]+=F[1],X[0]+=F[0],X[1]+=F[1])}$i(w,new Yk(V([e[3*k],e[3*k+1],e[3*k+2]],j),null,u),new Yk(V([e[3*C],e[3*C+1],e[3*C+2]],j),null,i),new Yk(V([e[3*q],e[3*q+1],e[3*q+2]],j),null,X),A)}return ks.$15n(w)},qp=function(l,k,t){var W,q=l.data.getAttaches();if(q&&q.each(function(B){B instanceof Xc&&B.s("attach.operation")&&(W||(W=[]),W.push(B))}),W){var O;Af.forEach(function(X){var N=Ym(X,l[X].vs,l[X].tuv);O=O?O.concat(N):N}),O=ks.$15n(O),W.forEach(function(m){var k=m.s("attach.operation");O[k]&&(O=O[k](vl(m,l.gv,l.csg.tuv)))}),Af.forEach(function(q){q=l[q],q.vs=[],q.ns=[],q.tuv&&(q.tuv=[])}),l.csg&&!l.csg.ns&&(l.csg.ns=[]);var Q=[];if(O.$19n().forEach(function(x){var b,k=x.$10n;if(k instanceof Xc){if(k.s("attach.cull"))return;b=k.s("csg.cull.color"),b&&(b=M.toColorArray(b)),k="csg"}for(var A=l[k],$=A.vs,j=A.ns,u=A.tuv,p=x.$9n,e=2;e<p.length;e++)if(ok($,p[0].$24n),ok($,p[e-1].$24n),ok($,p[e].$24n),j&&(ok(j,p[0].$22n),ok(j,p[e-1].$22n),ok(j,p[e].$22n)),u&&(ok(u,p[0].uv,!0),ok(u,p[e-1].uv,!0),ok(u,p[e].uv,!0)),b)for(var K=4*($.length/3),h=0;3>h;h++)Q[--K]=b[3],Q[--K]=b[2],Q[--K]=b[1],Q[--K]=b[0]}),Q.length){for(var H=M.toColorArray(l.csg.color),U=0,N=4*(l.csg.vs.length/3);N>U;U+=4)Q[U]==m&&(Q[U]=H[0],Q[U+1]=H[1],Q[U+2]=H[2],Q[U+3]=H[3]);l.csg.cs=Q}}kp.forEach(function(m){var w=l[m];w.visible&&w.vs.length?(w.ns&&w.ns.length?C(w,"ns"):w.ns=n(w.vs),C(w,"vs"),C(w,"tuv"),w.cs&&C(w,"cs")):delete l[m]}),k&&(f(l,S,k,S,t),l.clear())};L(E,{createFrameModel:function(L,F,H,o){L=L==S?.07:L,F=F==S?L:F,H=H==S?L:H,o=o?o:{};var I=o.top,Y=o.bottom,t=o.left,G=o.right,u=o.front,Z=o.back,y=[],k=[];return u===!0?(y.push(-.5,.5,.5,-.5,-.5,.5,.5,-.5,.5,.5,-.5,.5,.5,.5,.5,-.5,.5,.5),k.push(0,0,0,1,1,1,1,1,1,0,0,0)):u===!1||(y.push(-.5,.5,.5,-.5,-.5,.5,-.5+L,-.5,.5,-.5+L,-.5,.5,-.5+L,.5,.5,-.5,.5,.5,.5-L,.5,.5,.5-L,-.5,.5,.5,-.5,.5,.5,-.5,.5,.5,.5,.5,.5-L,.5,.5,-.5+L,.5,.5,-.5+L,.5-F,.5,.5-L,.5-F,.5,.5-L,.5-F,.5,.5-L,.5,.5,-.5+L,.5,.5,-.5+L,-.5+F,.5,-.5+L,-.5,.5,.5-L,-.5,.5,.5-L,-.5,.5,.5-L,-.5+F,.5,-.5+L,-.5+F,.5),k.push(0,0,0,1,L,1,L,1,L,0,0,0,1-L,0,1-L,1,1,1,1,1,1,0,1-L,0,L,0,L,F,1-L,F,1-L,F,1-L,0,L,0,L,1-F,L,1,1-L,1,1-L,1,1-L,1-F,L,1-F)),Z===!0?(y.push(-.5,.5,-.5,.5,-.5,-.5,-.5,-.5,-.5,.5,-.5,-.5,-.5,.5,-.5,.5,.5,-.5),k.push(1,0,0,1,1,1,0,1,1,0,0,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y===!0?(y.push(.5,-.5,.5,-.5,-.5,-.5,.5,-.5,-.5,-.5,-.5,-.5,.5,-.5,.5,-.5,-.5,.5),k.push(1,0,0,1,1,1,0,1,1,0,0,0)):Y===!1||(y.push(.5,-.5,.5,.5-L,-.5,-.5,.5,-.5,-.5,.5-L,-.5,-.5,.5,-.5,.5,.5-L,-.5,.5,-.5+L,-.5,.5,-.5,-.5,-.5,-.5+L,-.5,-.5,-.5,-.5,-.5,-.5+L,-.5,.5,-.5,-.5,.5,.5-L,-.5,.5,-.5+L,-.5,.5-H,.5-L,-.5,.5-H,-.5+L,-.5,.5-H,.5-L,-.5,.5,-.5+L,-.5,.5,.5-L,-.5,-.5+H,-.5+L,-.5,-.5,.5-L,-.5,-.5,-.5+L,-.5,-.5,.5-L,-.5,-.5+H,-.5+L,-.5,-.5+H),k.push(1,0,1-L,1,1,1,1-L,1,1,0,1-L,0,L,0,0,1,L,1,0,1,L,0,0,0,1-L,0,L,H,1-L,H,L,H,1-L,0,L,0,1-L,1-H,L,1,1-L,1,L,1,1-L,1-H,L,1-H)),{vs:y,uv:k}}}),L(G.Style,{"csg.cull.color":m,"csg.cull.box":!0,"dw.flip":!1,"dw.s3":[.999,.999,.5],"dw.t3":m,"dw.expanded":!1,"dw.toggleable":!0,"dw.axis":"left","dw.start":0,"dw.end":b/2,"dw.angle":0,"attach.cull":!1,"attach.operation":"subtract"},!0),Af.forEach(function(T){var C={};C[T+k]=!1,C[T+".toggleable"]=!1,C[T+".axis"]=q,C[T+".start"]=0,C[T+".end"]=b/2,C[T+sj]=0,L(G.Style,C,!0)});var ks=function(){this.$4n=[]};ks.$15n=function(R){var W=new ks;return W.$4n=R,W},ks.prototype={clone:function(){var m=new ks;return m.$4n=this.$4n.map(function(k){return k.clone()}),m},$19n:function(){return this.$4n},union:function(z){var m=new Ll(this.clone().$4n),Q=new Ll(z.clone().$4n);return m.$3n(Q),Q.$3n(m),Q.$6n(),Q.$3n(m),Q.$6n(),m.$7n(Q.$2n()),ks.$15n(m.$2n())},subtract:function(x){var E=new Ll(this.clone().$4n),d=new Ll(x.clone().$4n);return E.$6n(),E.$3n(d),d.$3n(E),d.$6n(),d.$3n(E),d.$6n(),E.$7n(d.$2n()),E.$6n(),ks.$15n(E.$2n())},intersect:function(j){var b=new Ll(this.clone().$4n),s=new Ll(j.clone().$4n);return b.$6n(),s.$3n(b),s.$6n(),b.$3n(s),s.$3n(b),b.$7n(s.$2n()),b.$6n(),ks.$15n(b.$2n())},inverse:function(){var p=this.clone();return p.$4n.map(function(J){J.flip()}),p}},ks.cube=function(c){c=c||{};var z=new Gp(c.center||[0,0,0]),M=c.radius?c.radius.length?c.radius:[c.radius,c.radius,c.radius]:[1,1,1];return ks.$15n([[[0,4,6,2],[-1,0,0]],[[1,3,7,5],[1,0,0]],[[0,1,5,4],[0,-1,0]],[[2,6,7,3],[0,1,0]],[[0,2,3,1],[0,0,-1]],[[4,5,7,6],[0,0,1]]].map(function($){return new Zm($[0].map(function(n){var R=new Gp(z.x+M[0]*(2*!!(1&n)-1),z.y+M[1]*(2*!!(2&n)-1),z.z+M[2]*(2*!!(4&n)-1));return new Yk(R,new Gp($[1]))}))}))},ks.sphere=function(C){function L(l,O){l*=2*b,O*=b;var o=new Gp(y(l)*Z(O),y(O),Z(l)*Z(O));q.push(new Yk($.$20n(o.$21n(B)),o))}C=C||{};for(var q,$=new Gp(C.center||[0,0,0]),B=C.radius||1,I=C.slices||16,M=C.stacks||8,U=[],m=0;I>m;m++)for(var l=0;M>l;l++)q=[],L(m/I,l/M),l>0&&L((m+1)/I,l/M),M-1>l&&L((m+1)/I,(l+1)/M),L(m/I,(l+1)/M),U.push(new Zm(q));return ks.$15n(U)},ks.cylinder=function(W){function J(A,p,t){var R=2*p*b,G=v.$21n(y(R)).$20n(T.$21n(Z(R))),W=Q.$20n(l.$21n(A)).$20n(G.$21n(B)),O=G.$21n(1-r(t)).$20n($.$21n(t));return new Yk(W,O)}W=W||{};for(var Q=new Gp(W.start||[0,-1,0]),w=new Gp(W.end||[0,1,0]),l=w.$13n(Q),B=W.radius||1,p=W.slices||16,$=l.$14n(),X=r($.y)>.5,v=new Gp(X,!X,0).cross($).$14n(),T=v.cross($).$14n(),e=new Yk(Q,$.$11n()),u=new Yk(w,$.$14n()),P=[],K=0;p>K;K++){var _=K/p,I=(K+1)/p;P.push(new Zm([e,J(0,_,-1),J(0,I,-1)])),P.push(new Zm([J(0,I,0),J(0,_,0),J(1,_,0),J(1,I,0)])),P.push(new Zm([u,J(1,I,1),J(1,_,1)]))}return ks.$15n(P)};var Gp=function(r,$,y){var u=this;3==arguments.length?(u.x=r,u.y=$,u.z=y):"x"in r?(u.x=r.x,u.y=r.y,u.z=r.z):(u.x=r[0],u.y=r[1],u.z=r[2])};Gp.prototype={clone:function(){return new Gp(this.x,this.y,this.z)},$11n:function(){return new Gp(-this.x,-this.y,-this.z)},$20n:function(w){return new Gp(this.x+w.x,this.y+w.y,this.z+w.z)},$13n:function($){return new Gp(this.x-$.x,this.y-$.y,this.z-$.z)},$21n:function(d){return new Gp(this.x*d,this.y*d,this.z*d)},$16n:function(F){return new Gp(this.x/F,this.y/F,this.z/F)},dot:function(l){return this.x*l.x+this.y*l.y+this.z*l.z},lerp:function(R,x){return this.$20n(R.$13n(this).$21n(x))},length:function(){return g(this.dot(this))},$14n:function(){return this.$16n(this.length())},cross:function(x){var l=this;return new Gp(l.y*x.z-l.z*x.y,l.z*x.x-l.x*x.z,l.x*x.y-l.y*x.x)}};var Yk=function(I,W,Y){var $=this;$.$24n=new Gp(I),$.$22n=W?new Gp(W):null,$.uv=Y?new Gp(Y):null};Yk.prototype={clone:function(){var r=this;return new Yk(r.$24n.clone(),r.$22n.clone(),r.uv?r.uv.clone():null)},flip:function(){this.$22n=this.$22n.$11n()},$18n:function(Z,T){var B=this;return new Yk(B.$24n.lerp(Z.$24n,T),B.$22n.lerp(Z.$22n,T),B.uv?B.uv.lerp(Z.uv,T):null)}};var im=function(M,J){this.$22n=M,this.w=J};im.$17n=function(O,v,F){var x=v.$13n(O).cross(F.$13n(O)).$14n();return new im(x,x.dot(O))},im.prototype={clone:function(){return new im(this.$22n.clone(),this.w)},flip:function(){var F=this;F.$22n=F.$22n.$11n(),F.w=-F.w},$5n:function(W,k,s,o,M){for(var Z=this,d=0,u=1,Y=2,i=3,T=0,e=[],m=0;m<W.$9n.length;m++){var O=Z.$22n.dot(W.$9n[m].$24n)-Z.w,F=-t>O?Y:O>t?u:d;T|=F,e.push(F)}switch(T){case d:(Z.$22n.dot(W.$8n.$22n)>0?k:s).push(W);break;case u:o.push(W);break;case Y:M.push(W);break;case i:for(var b=[],U=[],m=0;m<W.$9n.length;m++){var q=(m+1)%W.$9n.length,H=e[m],B=e[q],K=W.$9n[m],r=W.$9n[q];if(H!=Y&&b.push(K),H!=u&&U.push(H!=Y?K.clone():K),(H|B)==i){var O=(Z.w-this.$22n.dot(K.$24n))/Z.$22n.dot(r.$24n.$13n(K.$24n)),P=K.$18n(r,O);b.push(P),U.push(P.clone())}}b.length>=3&&o.push(new Zm(b,W.$10n)),U.length>=3&&M.push(new Zm(U,W.$10n))}}};var Zm=function(D,q){var i=this;i.$9n=D,i.$10n=q,i.$8n=im.$17n(D[0].$24n,D[1].$24n,D[2].$24n)};Zm.prototype={clone:function(){var F=this.$9n.map(function(F){return F.clone()});return new Zm(F,this.$10n)},flip:function(){this.$9n.reverse().map(function(W){W.flip()}),this.$8n.flip()}};var Ll=function(U){var O=this;O.$8n=null,O.front=null,O.back=null,O.$4n=[],U&&O.$7n(U)};Ll.prototype={clone:function(){var A=this,S=new Ll;return S.$8n=A.$8n&&A.$8n.clone(),S.front=A.front&&A.front.clone(),S.back=A.back&&A.back.clone(),S.$4n=A.$4n.map(function(v){return v.clone()}),S},$6n:function(){for(var L=this,D=0;D<L.$4n.length;D++)L.$4n[D].flip();L.$8n&&L.$8n.flip(),L.front&&L.front.$6n(),L.back&&L.back.$6n();var y=L.front;L.front=L.back,L.back=y},$1n:function(p){var L=this;if(!L.$8n)return p.slice();for(var Q=[],M=[],d=0;d<p.length;d++)L.$8n.$5n(p[d],Q,M,Q,M);return L.front&&(Q=L.front.$1n(Q)),M=L.back?L.back.$1n(M):[],Q.concat(M)},$3n:function(Y){var X=this;X.$4n=Y.$1n(X.$4n),X.front&&X.front.$3n(Y),X.back&&X.back.$3n(Y)},$2n:function(){var W=this,E=W.$4n.slice();return W.front&&(E=E.concat(W.front.$2n())),W.back&&(E=E.concat(W.back.$2n())),E},$7n:function(F){var V=this;if(F.length){V.$8n||(V.$8n=F[0].$8n.clone());for(var l=[],C=[],L=0;L<F.length;L++)this.$8n.$5n(F[L],V.$4n,V.$4n,l,C);l.length&&(V.front||(V.front=new Ll),this.front.$7n(l)),C.length&&(V.back||(V.back=new Ll),V.back.$7n(C))}}};var _j="symbol",og=G.Symbol=function(Z,T,D){var e=this;F(og,e),e.s3(20,20,20),e.s({"all.visible":!1,shape:"rect"}),e.setIcon(Z,T,D)};yn("Symbol",c,{setIcon:function(N,O,a){var q,m=this;return og.superClass.setIcon.call(m,N),N?(q={for3d:!0,face:"center",position:44,names:[N]},a&&(q.transaprent=!0),O&&(q.autorotate=O),m.addStyleIcon(_j,q)):m.removeStyleIcon(_j),m.setWidth(M.getImageWidth(E.getImage(N),m)||20),q}});var Xc=G.CSGNode=function(){F(Xc,this),this.s({shape:"rect","attach.thickness":1.001,"2d.attachable":!0})},ce={position:1,width:1,height:1,rotation:1,rotationX:1,rotationZ:1,rotationMode:1,tall:1,elevation:1,anchor:1,anchorElevation:1,"s:attach.cull":1,"s:attach.operation":1};yn("CSGNode",c,{_22Q:function(){return mk},onPropertyChanged:function(b){var V=this,z=V.getHost();Xc.superClass.onPropertyChanged.call(V,b),ce[b.property]&&(z instanceof nq||z instanceof Xc)&&z.fp("csgNodeChange",!0,!1)}});var mk=function(J,f){F(mk,this,[J,f])};A(mk,B.Node3dUI,{_80o:function(S,l,T){var M=this;M._shape3d?mk.superClass._80o.call(M,S,l,T):(d(M.gv),kp.forEach(function(U){s(M,S,l,U,T)}))},validate:function(v,S){var q=this,t=q.gv,Y=q.data;if(Y.s("shape3d"))return mk.superClass.validate.call(q,v,S),q._shape3d=!0,void 0;q._shape3d=!1;var o=_(Y,t.getMat(Y));Y.appendAnchorMatrix3d(o);var V=v&&v.uv;q.vf2("csg",V);for(var l=0;6>l;l++)for(var h=Af[l],j=tg[l],U=q.vf2(h,V,S),b=U.mat||o,A=U.vs,$=U.uv,x=U.tuv,Z=0;2>Z;Z++){var r=H[j+3*Z],i=H[j+3*Z+1],G=H[j+3*Z+2];if(P(A,b,[e[3*r],e[3*r+1],e[3*r+2]]),P(A,b,[e[3*i],e[3*i+1],e[3*i+2]]),P(A,b,[e[3*G],e[3*G+1],e[3*G+2]]),x)if($){var B=8*l;x.push($[2*r-B],$[2*r+1-B],$[2*i-B],$[2*i+1-B],$[2*G-B],$[2*G+1-B])}else x.push(T[2*r],T[2*r+1],T[2*i],T[2*i+1],T[2*G],T[2*G+1])}qp(q,v,S)},vf2:function(F,Q,Z){var d,X=this,r=X.gv.getFaceVisible(X.data,F);return d=D(X,F,Z),d.vs=[],d.tuv=r&&(d.texture||Q)?[]:S,d.visible=r,d}});var nq=G.CSGShape=function(){var w=this;F(nq,w),w.s({"shape.background":S,"2d.hostable":!0,"shape.border.width":8}),w.setTall(240),w.setElevation(120),w.setThickness(14)};yn("CSGShape",W,{IRotatable:!1,_22Q:function(){return Yg},setRotationX:function(){},setRotation:function(){},setRotationZ:function(){},setSegments:function(){}});var Yg=function(K,P){F(Yg,this,[K,P])};A(Yg,B.Shape3dUI,{_80o:function(P,T,I){var i=this;i.undrawable||(d(i.gv),kp.forEach(function(q){s(i,P,T,q,I)}))},validate:function(Y,p){var B=this,v=B.data,z=v.getPoints();if(B.undrawable=z.size()<2)return B.clear(),void 0;var K=v.isClosePath(),u=I(v._thickness/2,t),g=x(z,S,S,K);kp.forEach(function(M){B.vf(M,Y&&Y.uv,!0,p)}),K&&(B.left.visible=!1,B.right.visible=!1),B._12O(g,u),B._20Q(g);var D=v.getPointsMatrix3d(),E=G.Math.requestVector3();Af.forEach(function(M){if(B[M])for(var p=B[M].vs,L=0,c=p.length;c>L;L+=3)E.set(p[L],p[L+1],p[L+2]).applyMatrix4(D),p[L]=E.x,p[L+1]=E.y,p[L+2]=E.z}),G.Math.releaseVector3(E),qp(B,Y,p)}});var _r=G.DoorWindow=function(){var s=this;F(_r,s),s.setElevation(100),s.s3(100,200,14)};yn("DoorWindow",Xc,{IDoorWindow:!0,toggle:function(K){this.setExpanded(!this.s(U),K)},isExpanded:function(){return this.s(U)},setExpanded:function(v,D){var i=this,S=i.$25n,L=i.s(U);if(S&&(S.stop(!0),delete i.$25n),L!==v){i.beginTransaction();var o=v?i.s("dw.end"):i.s("dw.start");i.s(U,v),D=N(D),D?(L=i.s(Iq),D.action=function($){i.s(Iq,L+(o-L)*$)},D.finishFunc=function(){i.endTransaction()},i.$25n=Q(D)):(i.s(Iq,o),i.endTransaction())}},getMat:function(){var p=this,e=p.s("dw.s3"),V=p.s("dw.t3"),P=p.s("dw.flip"),U=p.s(Iq);if(e||U||V||P){var f=[];if(P&&f.push({r3:[0,b,0]}),e&&f.push({s3:e}),U){e=p.getFinalScale3d();var _=p.s("dw.axis"),Y=e[0]/2,j=e[1]/2;e[2]/2,_===q?f.push({t3:[Y,0,0]},{r3:[0,-U,0]},{t3:[-Y,0,0]}):_===u?f.push({t3:[-Y,0,0]},{r3:[0,U,0]},{t3:[Y,0,0]}):_===K?f.push({t3:[0,-j,0]},{r3:[-U,0,0]},{t3:[0,j,0]}):_===R?f.push({t3:[0,j,0]},{r3:[U,0,0]},{t3:[0,-j,0]}):_===v?f.push({r3:[0,U,0]}):_===i&&f.push({r3:[U,0,0]})}return V&&f.push({t3:V}),J(f)}return S}});var kl=G.CSGBox=function(){var n=this;F(kl,n),n.setElevation(100),n.s3(100,200,100)};yn("CSGBox",Xc,{ICSGBox:!0,toggleFace:function(T,i){this.setFaceExpanded(T,!this.s(T+k),i)},isFaceExpanded:function(C){return this.s(C+k)},setFaceExpanded:function(c,H,p){var T=this,o=T.$25n,W=T.s(c+k);if(o&&(o.stop(!0),delete T.$25n),W!==H){var F=H?T.s(c+".end"):T.s(c+".start");T.s(c+k,H),p=N(p),p?(W=T.s(c+sj),p.action=function(v){T.s(c+sj,W+(F-W)*v)},T.$25n=Q(p)):T.s(c+sj,F)}},getFaceMat:function(d){var H=this,b=H.s(d+sj);if(!b)return S;var v,c,q,A,y,W,s=H.s(d+".axis"),N=H.getFinalScale3d(),n=H.getAnchor3d(),R=N[0]*n.x,L=N[1]*n.y,Y=N[2]*n.z,z=N[0]-R,$=N[1]-L,x=N[2]-Y,f=d+"_"+s;switch(f){case"front_left":v=-R,c=0,q=x,A=0,y=-b,W=0;break;case"front_right":v=z,c=0,q=x,A=0,y=b,W=0;break;case"front_top":v=0,c=$,q=x,A=-b,y=0,W=0;break;case"front_bottom":v=0,c=-L,q=x,A=b,y=0,W=0;break;case"front_h":v=0,c=0,q=x,A=b,y=0,W=0;break;case"front_v":v=0,c=0,q=x,A=0,y=b,W=0;break;case"back_left":v=z,c=0,q=-Y,A=0,y=-b,W=0;break;case"back_right":v=-R,c=0,q=-Y,A=0,y=b,W=0;break;case"back_top":v=0,c=$,q=-Y,A=b,y=0,W=0;break;case"back_bottom":v=0,c=-L,q=-Y,A=-b,y=0,W=0;break;case"back_h":v=0,c=0,q=-Y,A=b,y=0,W=0;break;case"back_v":v=0,c=0,q=-Y,A=0,y=b,W=0;break;case"left_left":v=-R,c=0,q=-Y,A=0,y=-b,W=0;break;case"left_right":v=-R,c=0,q=x,A=0,y=b,W=0;break;case"left_top":v=-R,c=$,q=0,A=0,y=0,W=-b;break;case"left_bottom":v=-R,c=-L,q=0,A=0,y=0,W=b;break;case"left_h":v=-R,c=0,q=0,A=0,y=0,W=b;break;case"left_v":v=-R,c=0,q=0,A=0,y=b,W=0;break;case"right_left":v=z,c=0,q=x,A=0,y=-b,W=0;break;case"right_right":v=z,c=0,q=-Y,A=0,y=b,W=0;break;case"right_top":v=z,c=$,q=0,A=0,y=0,W=b;break;case"right_bottom":v=z,c=-L,q=0,A=0,y=0,W=-b;break;case"right_h":v=z,c=0,q=0,A=0,y=0,W=b;break;case"right_v":v=z,c=0,q=0,A=0,y=b,W=0;break;case"top_left":v=-R,c=$,q=0,A=0,y=0,W=b;break;case"top_right":v=z,c=$,q=0,A=0,y=0,W=-b;break;case"top_top":v=0,c=$,q=-Y,A=-b,y=0,W=0;break;case"top_bottom":v=0,c=$,q=x,A=b,y=0,W=0;break;case"top_h":v=0,c=$,q=0,A=b,y=0,W=0;break;case"top_v":v=0,c=$,q=0,A=0,y=0,W=b;break;case"bottom_left":v=-R,c=-L,q=0,A=0,y=0,W=-b;break;case"bottom_right":v=z,c=-L,q=0,A=0,y=0,W=b;break;case"bottom_top":v=0,c=-L,q=x,A=-b,y=0,W=0;break;case"bottom_bottom":v=0,c=-L,q=-Y,A=b,y=0,W=0;break;case"bottom_h":v=0,c=-L,q=0,A=b,y=0,W=0;break;case"bottom_v":v=0,c=-L,q=0,A=0,y=0,W=b}return J([{t3:[-v,-c,-q]},{r3:[A,y,W]},{t3:[v,c,q]}])}});var He=function(g,d,i,B,I){function H(){var v,D=[],r=new w,z=new w;for(E.eachShapeModel(function($,t,S){for(var A=0,f=t?t.length:$.length/3;f>A;A++)t?(r.fromArray($,3*t[A]),z.fromArray(S,3*t[A])):(r.fromArray($,3*A),z.fromArray(S,3*A)),N(D,r,z)}),D=C(D,M.set(1,0,0)),D=C(D,M.set(-1,0,0)),D=C(D,M.set(0,1,0)),D=C(D,M.set(0,-1,0)),D=C(D,M.set(0,0,1)),D=C(D,M.set(0,0,-1)),v=0;v<D.length;v++){var X=D[v];o.push(.5+X.position.x/I.x,.5-X.position.y/I.y),X.position.applyMatrix4(b),J.push(X.position.x,X.position.y,X.position.z),O.push(X.$22n.x,X.$22n.y,X.$22n.z)}}function N(I,k,q){k.applyMatrix4(y),k.applyMatrix4(x),q.transformDirection(y),q.transformDirection(x),I.push(new $(k.clone(),q.clone()))}function C(p,D){for(var V=[],$=.5*Math.abs(I.dot(D)),T=0;T<p.length;T+=3){var i,N,s,Q,y,h,P,c=0,O=p[T+0].position.dot(D)-$,e=p[T+1].position.dot(D)-$,Z=p[T+2].position.dot(D)-$;switch(i=O>0,N=e>0,s=Z>0,c=(i?1:0)+(N?1:0)+(s?1:0)){case 0:V.push(p[T]),V.push(p[T+1]),V.push(p[T+2]);break;case 1:if(i&&(Q=p[T+1],y=p[T+2],h=n(p[T],Q,D,$),P=n(p[T],y,D,$)),N){Q=p[T],y=p[T+2],h=n(p[T+1],Q,D,$),P=n(p[T+1],y,D,$),V.push(h),V.push(y.clone()),V.push(Q.clone()),V.push(y.clone()),V.push(h.clone()),V.push(P);break}s&&(Q=p[T],y=p[T+1],h=n(p[T+2],Q,D,$),P=n(p[T+2],y,D,$)),V.push(Q.clone()),V.push(y.clone()),V.push(h),V.push(P),V.push(h.clone()),V.push(y.clone());break;case 2:i||(Q=p[T].clone(),y=n(Q,p[T+1],D,$),h=n(Q,p[T+2],D,$),V.push(Q),V.push(y),V.push(h)),N||(Q=p[T+1].clone(),y=n(Q,p[T+2],D,$),h=n(Q,p[T],D,$),V.push(Q),V.push(y),V.push(h)),s||(Q=p[T+2].clone(),y=n(Q,p[T],D,$),h=n(Q,p[T+1],D,$),V.push(Q),V.push(y),V.push(h));break;case 3:}}return V}function n(q,C,L,y){var t=q.position.dot(L)-y,u=C.position.dot(L)-y,a=t/(t-u),J=new $(new w(q.position.x+a*(C.position.x-q.position.x),q.position.y+a*(C.position.y-q.position.y),q.position.z+a*(C.position.z-q.position.z)),new w(q.$22n.x+a*(C.$22n.x-q.$22n.x),q.$22n.y+a*(C.$22n.y-q.$22n.y),q.$22n.z+a*(C.$22n.z-q.$22n.z)));return J}var J=[],O=[],o=[],M=new w,E=g.getData3dUI(d);if(E.mat){var y=(new Y).fromArray(E.mat),L=new Y;L.makeRotationFromEuler(B),L.setPosition(i);var x=(new Y).getInverse(L),b=(new Y).scale({x:1/I.x,y:1/I.y,z:1/I.z});return H(),{vs:J,ns:O,uv:o}}};$.prototype.clone=function(){return new $(this.position.clone(),this.$22n.clone())};var wn=function(J,P,U,$){var T=this,k=T.getDataAt(J);if(k){var X=T.intersectObject(J,k);if(X){"object"==typeof P?P=P.x?new w(P.x,P.y,P.z):new w(P[0],P[1],P[2]):(P=P||20,P=new w(P,P,P)),U=U===m?.1:U;var c=new w(T.getUp()),A=new w(T.getCenter()).sub(new w(T.getEye())).normalize(),R="cross",i=A.clone()[R](c).normalize();c.copy(i)[R](A).normalize(),$&&c.applyAxisAngle(X.worldNormal,-$);var s=new G.Node,l=X.worldNormal.clone().setLength(U).add(X.world),g=(new Y).lookAt(X.worldNormal.clone(),new w(0,0,0),c),E=(new j).setFromRotationMatrix(g),d=He(T,k,X.world.clone(),E,P);return s.p3(l.x,l.y,l.z),s.setEuler(E),s.s3(P.x,P.y,P.z),s.s({shape3d:d,"shape3d.reverse.flip":!0}),s}}};L(G.graph3d.Graph3dView,{createDecal:wn})}("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:(0,eval)("this"),Object);