var DesignCAD=function(){"use strict";var t=KanKan.config(),o={zh:{cad:{floor:"楼层",remove:"删除部件",attribute:"属性",split:"拆分",toolbar:{recall:"撤销",recover:"恢复",clear:"清空",default:"恢复默认",rotate:"旋转",download:"下载",flex:"适应视图",panos:"漫游点",texture:"底图",unit:"测量单位"},classify:{wall:"墙类",door:"门",window:"窗",structure:"构建",tag:"标注"},items:{Wall:"内墙",OutWall:"外墙",SingleDoor:"门",DoubleDoor:"双开门",SlideDoor:"移门",Pass:"垭口",SingleWindow:"窗",BayWindow:"飘窗",FrenchWindow:"落地窗",Beam:"柱子",Flue:"烟道",Corridor:"楼道",Tag:"标注",WallCorner:"点",compass:"指南针"}}}},i=t.lang||"zh";"zh"!=i&&"object"!=typeof t[o]&&(o[i]=t[i]);var s=function(t){if(!t||!o[i])return t;if(-1===t.indexOf("."))return o[i]||t;for(var e=t.split("."),n=null,s=0;sMath.PI&&(e=2*Math.PI-e),Math.abs((c+d)/2-e)0},h.prototype.reverse=function(t){for(var e=[],o=t.length-1;o>-1;--o)e.push(t[o]);return e},h.prototype.getIntersectionPoint=function(t,e){if(this.isParallel(t,e))return null;if(void 0===t.a&&void 0!==e.a){if(t.x)return{x:t.x,y:e.a*t.x+e.b};if(t.y)return{x:(t.y-e.b)/e.a,y:t.y}}else if(void 0===e.a&&void 0!==t.a){if(e.x)return{x:e.x,y:t.a*e.x+t.b};if(e.y)return{x:(e.y-t.b)/t.a,y:e.y}}else if(void 0===e.a&&void 0===t.a)return t.hasOwnProperty("x")&&e.hasOwnProperty("y")?{x:t.x,y:e.y}:t.hasOwnProperty("y")&&e.hasOwnProperty("x")?{x:e.x,y:t.y}:null;return t.a==e.a?null:{x:(e.b-t.b)/(t.a-e.a),y:(t.a*e.b-e.a*t.b)/(t.a-e.a)}},h.prototype.getIntersectionPoint2=function(t,e,o,i){var n=(e.y-t.y)*(i.x-o.x)-(t.x-e.x)*(o.y-i.y);return 0==n?null:{x:((e.x-t.x)*(i.x-o.x)*(o.y-t.y)+(e.y-t.y)*(i.x-o.x)*t.x-(i.y-o.y)*(e.x-t.x)*o.x)/n,y:-((e.y-t.y)*(i.y-o.y)*(o.x-t.x)+(e.x-t.x)*(i.y-o.y)*t.y-(i.x-o.x)*(e.y-t.y)*o.y)/n}},h.prototype.getIntersectionPoint3=function(t,e,o,i){var n=this.getIntersectionPoint2(t,e,o,i);if(n){var s=n.x,r=n.y;return(s-t.x)*(s-e.x)<=.001&&(r-t.y)*(r-e.y)<=.001&&(s-o.x)*(s-i.x)<=.001&&(r-o.y)*(r-i.y)<=.001?{x:s,y:r}:null}return null},h.prototype.getIntersectionPoint4=function(t,e,o){var i=this.createLine1(t,e),n=this.getIntersectionPoint(i,o);return null==n?null:this.PointInSegment(n,t,e)?n:null},h.prototype.isParallel=function(t,e){return void 0===t.a&&void 0===e.a?!(!t.hasOwnProperty("x")||!e.hasOwnProperty("x"))||!(!t.hasOwnProperty("y")||!e.hasOwnProperty("y")):void 0!==t.a&&void 0!==e.a&&this.getFixed(t.a)==this.getFixed(e.a)},h.prototype.Angle=function(t,e,o){var i,n,s=0,r=e.x-t.x,l=e.y-t.y,a=o.x-t.x,h=o.y-t.y;return s=r*a+l*h,n=(r*r+l*l)*(a*a+h*h),(s/=Math.sqrt(n))>=1?0:s<=-1?Math.PI:180*(i=Math.acos(s))/Math.PI<180?i:2*Math.PI-i},h.prototype.getLineForPoint=function(t,e){var o={};return 0==t.a||void 0===t.a?t.hasOwnProperty("x")?o.y=e.y:t.hasOwnProperty("y")&&(o.x=e.x):(o.a=-1/t.a,o.b=e.y-e.x*o.a),o},h.prototype.getJoinLinePoint=function(t,e){var o=this.getVerticalLine(e,t);return this.getIntersectionPoint(e,o)},h.prototype.getDisForPoinLine=function(t,e){var o=this.getJoinLinePoint(t,e);return this.getDistance(t,o)},h.prototype.getVerticalLine=function(t,e){if(void 0===t.a)return t.hasOwnProperty("x")?{y:e.y}:t.hasOwnProperty("y")?{x:e.x}:null;if(0==t.a)return{x:e.x};var o={};return o.a=-1/t.a,this.createLine3(o,e)},h.prototype.isContainForSegment=function(t,e,o,i){i||(i=a.minAdsorb);var n=this.getDistance(e,t)+this.getDistance(o,t),s=this.getDistance(e,o);return Math.abs(n-s)i!=d>i&&o<(u-h)*(i-c)/(d-c)+h&&(n=!n)}return n},h.prototype.getDisForPoinSegment=function(t,e,o,i){var n=this.createLine1(e,o),s=this.getJoinLinePoint(t,n),r=this.getDistance(e,o),l=this.getDistance(s,e),a=this.getDistance(s,o);return this.getDistance(s,e)>r||this.getDistance(s,o)>r?l=0&&s*c+r*u<=0&&Math.abs(i*r-n*s)<=.001},h.prototype.clonePoint=function(t,e){t.x=e.x,t.y=e.y},h.prototype.equalPoint=function(t,e){return t.x==e.x&&t.y==e.y},h.prototype.crossTwoLines=function(t,e,o,i,n){void 0===n&&(n=a.minAdsorb);var s=this.getIntersectionPoint2(t,e,o,i);if(null!=s){if(this.getDistance(t,s)>n&&this.getDistance(e,s)>n&&this.getDistance(o,s)>n&&this.getDistance(i,s)>n)return this.getDistance(t,s)r.x&&(e=r.x),i>r.y&&(i=r.y),or.x)&&(e=r.x),(null==i||i>r.y)&&(i=r.y),(null==o||o0?null:r};var c=new h,u="Point",d="WallCorner",y="Wall",p="SingleDoor",x="DoubleDoor",g="SlideDoor",f="SingleWindow",m="BayWindow",v="FrenchWindow",S="Pass",P="Beam",b="Flue",I="Corridor",k="Line",T="Tag",F="TV",w="CombinationSofa",C="SingleSofa",W="TeaTable",D="Carpet",z="Plant",L="DiningTable",M="DoubleBed",R="SingleBed",O="Wardrobe",A="Dresser",E="BedsideCupboard",B="Pillow",_="GasStove",Y="Cupboard",N="Bathtub",X="Closestool",j="Washstand",U="Desk",J="BalconyChair",V="Elevator",H="all",$="start",Z="end",G="select",K="LEFT",q="RIGHT",Q=function(){this.len=null};Q.prototype.setId=function(t){null==t||void 0===t?(t=he.getCurrentId(),he.updateCurrentId(),this.vectorId=this.geoType+t):this.vectorId=t},Q.prototype.setSymbolPosition=function(t,e){"start"==e?c.clonePoint(this.startPoint,t):"end"==e&&c.clonePoint(this.endPoint,t)},Q.prototype.setSymbolParent=function(t){this.parent=t},Q.prototype.setPointParent=function(t,e){null==this.parent&&(this.parent={}),this.parent[t]=e},Q.prototype.setOpenSide=function(t){var e=[];e.push(this.startPoint),e.push(this.endPoint),e.push(t);var o=null;o=c.isClockwise(e)?K:q,this.openSide=o},Q.prototype.rotatePoint=function(t,e,o){o*=-1;var i=e.x,n=e.y,s=t.x,r=t.y;return{x:i+(s-i)*Math.cos(o*Math.PI/180)-(r-n)*Math.sin(o*Math.PI/180),y:n+(s-i)*Math.sin(o*Math.PI/180)+(r-n)*Math.cos(o*Math.PI/180)}};var tt=function(t){function e(e,o,i,n){t.call(this),this.startPoint=e,this.endPoint=o,this.floor=n,this.openSide=null,this.parent=null,this.enter=null,this.points2d=[],this.position3d={},this.name="单开门",this.geoType=p,this.setId(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setPoints2d=function(){var t=c.createLine1(this.startPoint,this.endPoint),e=c.getDistance(this.startPoint,this.endPoint),o=c.getParallelLineForDistance(t,e),i=c.getVerticalLine(t,this.startPoint),n=c.getVerticalLine(t,this.endPoint),s=c.getIntersectionPoint(o.line1,i),r=c.getIntersectionPoint(o.line2,i),l=c.getIntersectionPoint(o.line1,n),a=c.getIntersectionPoint(o.line2,n);if(this.points2d=[],this.points2d.push(this.startPoint),this.points2d.push(this.endPoint),this.points2d.push(l),this.points2d.push(s),this.openSide==K){if(c.isClockwise(this.points2d))return;this.points2d=[],this.points2d.push(this.startPoint),this.points2d.push(this.endPoint),this.points2d.push(a),this.points2d.push(r)}else if(this.openSide==q){if(!c.isClockwise(this.points2d))return;this.points2d=[],this.points2d.push(this.startPoint),this.points2d.push(this.endPoint),this.points2d.push(a),this.points2d.push(r)}},e.prototype.isContain=function(t){var e=c.getDistance(t,this.startPoint),o=c.getDistance(t,this.endPoint);if(ei)return null;var n=c.Angle(this.points2d[0],t,this.points2d[1]),s=c.Angle(this.points2d[0],t,this.points2d[3]);return nthis.endPoint.x){var i=o.line1;o.line1=o.line2,o.line2=i}var n=c.getVerticalLine(t,this.startPoint),s=c.getVerticalLine(t,this.endPoint),r=o.line1,l=o.line2,a=c.getIntersectionPoint(o.line1,n),h=c.getIntersectionPoint(o.line2,s);this.points2d=[],this.points2d.push(this.startPoint),this.points2d.push(this.endPoint),this.points2d.push(a),c.isClockwise(this.points2d)?null==this.openSide||"LEFT"==this.openSide||(r=o.line2,l=o.line1,a=c.getIntersectionPoint(r,n),h=c.getIntersectionPoint(l,s)):null!=this.openSide&&"LEFT"!=this.openSide||(r=o.line2,l=o.line1,a=c.getIntersectionPoint(r,n),h=c.getIntersectionPoint(l,s));var u={x:(this.startPoint.x+this.endPoint.x)/2,y:(this.startPoint.y+this.endPoint.y)/2};this.points2d=[],this.points2d.push(this.startPoint);var d=4/le.res,y=c.getVerticalLine(t,u),p=c.getParallelLineForDistance(y,d),x=c.getIntersectionPoint(r,p.line1),g=c.getIntersectionPoint(r,p.line2),f=c.getIntersectionPoint(l,p.line1),m=c.getIntersectionPoint(l,p.line2),v=c.getIntersectionPoint(t,p.line1),S=c.getIntersectionPoint(t,p.line2);c.getDistance(this.startPoint,v)c.getDisForPoinLine(this.startPoint,h.line2)?(t=h.line2,e=u.line2,o=h.line1,i=u.line1):(t=h.line1,e=u.line1,o=h.line2,i=u.line2);var d=c.getParallelLineForDistance(n,2/le.res),y=c.getParallelLineForDistance(n,this.thickness-2/le.res),p=c.getParallelLineForDistance(n,this.thickness),x=d.line1,g=d.line2,f=y.line2,m=p.line2,v=d.line2,S=d.line1,P=y.line1,b=p.line1,I=c.getIntersectionPoint(t,x),k=c.getIntersectionPoint(o,x),T=c.getIntersectionPoint(o,f),F=c.getIntersectionPoint(t,f),w=c.getIntersectionPoint(e,g),C=c.getIntersectionPoint(i,g),W=c.getIntersectionPoint(i,m),D=c.getIntersectionPoint(e,m),z=c.getIntersectionPoint(t,v),L=c.getIntersectionPoint(o,v),M=c.getIntersectionPoint(o,P),R=c.getIntersectionPoint(t,P),O=c.getIntersectionPoint(e,S),A=c.getIntersectionPoint(i,S),E=c.getIntersectionPoint(i,b),B=c.getIntersectionPoint(e,b);this.points2d=[],this.points2d.push(I),this.points2d.push(k),this.points2d.push(T),this.points2d.push(F),"LEFT"==this.openSide?c.isClockwise(this.points2d)?(this.points2d.push(w),this.points2d.push(C),this.points2d.push(W),this.points2d.push(D)):(this.points2d=[],this.points2d.push(z),this.points2d.push(L),this.points2d.push(M),this.points2d.push(R),this.points2d.push(O),this.points2d.push(A),this.points2d.push(E),this.points2d.push(B)):"RIGHT"==this.openSide&&(c.isClockwise(this.points2d)?(this.points2d=[],this.points2d.push(z),this.points2d.push(L),this.points2d.push(M),this.points2d.push(R),this.points2d.push(O),this.points2d.push(A),this.points2d.push(E),this.points2d.push(B)):(this.points2d.push(w),this.points2d.push(C),this.points2d.push(W),this.points2d.push(D)))},e.prototype.isContain=function(t){var e=c.getDistance(t,this.startPoint),o=c.getDistance(t,this.endPoint);if(e2){for(var u in r)if(u!=e){var d=this.AngleForWall2(e,u);null==h&&1==d.clockwise?((i=d).wallId=u,h=d.angle,(s=d).wallId=u,c=d.angle):h>d.angle&&1==d.clockwise?((i=d).wallId=u,h=d.angle):cd.angle&&0==d.clockwise?((o=d).wallId=u,l=d.angle):a1)this.moveTo(o,i);else{he.deleteWall(e);var s=he.getPoint(o);c.clonePoint(s,n)}return i},ht.prototype.changeSymbolsWallToWall=function(t,e,o){for(var i=he.getWall(t,o),n=he.getWall(e,o),s=0;sa.maxAngle/180*Math.PI)return this.mergeWall(Object.keys(e.parent)[0],Object.keys(e.parent)[1]);return null},ht.prototype.getLinkPointId=function(t,e){var o=he.getWall(t),i=he.getWall(e);return o.start==i.start||o.start==i.end?o.start:o.end==i.start||o.end==i.end?o.end:o.start==i.start?null:void 0},ht.prototype.moveTo=function(t,e){var o=this.getWallId(t,e),i=he.getPoint(t),n=he.getPoint(e);i.x,n.x,i.y,n.y;var s=i.parent,r=n.parent;for(var l in s)if(l!=o){var h=he.getWall(l).getOtherPointId(t),u=he.getPoint(h);for(var d in r)if(d!=o){var y=he.getWall(d).getOtherPointId(e),p=he.getPoint(y),x=c.Angle(n,u,p);if(Math.abs(x)2)for(var o in e.parent)he.deleteWall(o);else if(2==Object.keys(e.parent).length){this.AngleForWall(Object.keys(e.parent)[0],Object.keys(e.parent)[1])>a.maxAngle/180*Math.PI?this.mergeWall(Object.keys(e.parent)[0],Object.keys(e.parent)[1]):(he.deleteWall(Object.keys(e.parent)[0]),he.deleteWall(Object.keys(e.parent)[0]))}};var ct=new ht,ut=function(t){function e(e,o){t.call(this),this.center=e,this.angle=0,this.points2d=[],this.sideWidth=.65,this.sideThickness=.65,this.name="柱子",this.geoType=P,this.setId(o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isContain=function(t){return c.isPointInPoly(t,this.points2d)},e.prototype.setPoints2d=function(){this.points2d=[];var t=this.center.x-this.sideWidth/2,e=this.center.y-this.sideThickness/2,o=this.center.x+this.sideWidth/2,i=this.center.y+this.sideThickness/2,n=this.rotatePoint({x:t,y:i},this.center,this.angle),s=this.rotatePoint({x:o,y:i},this.center,this.angle),r=this.rotatePoint({x:o,y:e},this.center,this.angle),l=this.rotatePoint({x:t,y:e},this.center,this.angle);this.points2d.push(n),this.points2d.push(s),this.points2d.push(r),this.points2d.push(l)},e}(Q),dt=function(t){function e(e,o){t.call(this),this.center=e,this.angle=0,this.points2d=[],this.sideWidth=.65,this.sideThickness=.65,this.name="烟道",this.geoType=b,this.setId(o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isContain=function(t){var e=[];return e.push(this.points2d[0]),e.push(this.points2d[1]),e.push(this.points2d[2]),e.push(this.points2d[3]),c.isPointInPoly(t,e)},e.prototype.setPoints2d=function(){this.points2d=[];var t=this.center.x-this.sideWidth/2,e=this.center.y-this.sideThickness/2,o=this.center.x+this.sideWidth/2,i=this.center.y+this.sideThickness/2,n=this.rotatePoint({x:t,y:i},this.center,this.angle),s=this.rotatePoint({x:o,y:i},this.center,this.angle),r=this.rotatePoint({x:o,y:e},this.center,this.angle),l=this.rotatePoint({x:t,y:e},this.center,this.angle);this.points2d.push(n),this.points2d.push(s),this.points2d.push(r),this.points2d.push(l),t=this.center.x-(this.sideWidth-.1)/2,e=this.center.y-(this.sideThickness-.1)/2,o=this.center.x+(this.sideWidth-.1)/2,i=this.center.y+(this.sideThickness-.1)/2;var a=this.rotatePoint({x:t,y:i},this.center,this.angle),h=this.rotatePoint({x:o,y:i},this.center,this.angle),c=this.rotatePoint({x:o,y:e},this.center,this.angle),u=this.rotatePoint({x:t,y:e},this.center,this.angle),d={x:(this.center.x+h.x)/2,y:(this.center.y+h.y)/2};this.points2d.push(a),this.points2d.push(h),this.points2d.push(c),this.points2d.push(u),this.points2d.push(d)},e}(Q),yt=function(t){function e(e,o){t.call(this),this.center=e,this.angle=0,this.points2d=[],this.sideWidth=.65,this.sideThickness=.65,this.name="楼道",this.geoType=I,this.setId(o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isContain=function(t){var e=[];return e.push(this.points2d[0]),e.push(this.points2d[1]),e.push(this.points2d[2]),e.push(this.points2d[3]),c.isPointInPoly(t,e)},e.prototype.setPoints2d=function(){this.points2d=[];var t=this.center.x-this.sideWidth/2,e=this.center.y-this.sideThickness/2,o=this.center.x+this.sideWidth/2,i=this.center.y+this.sideThickness/2,n=this.rotatePoint({x:t,y:i},this.center,this.angle),s=this.rotatePoint({x:o,y:i},this.center,this.angle),r=this.rotatePoint({x:o,y:e},this.center,this.angle),l=this.rotatePoint({x:t,y:e},this.center,this.angle);this.points2d.push(n),this.points2d.push(s),this.points2d.push(r),this.points2d.push(l);var a=this.center.x-2/le.res,h=this.center.x+2/le.res,c=3/le.res,u=this.rotatePoint({x:a,y:i},this.center,this.angle),d=this.rotatePoint({x:a,y:e},this.center,this.angle);this.points2d.push(u),this.points2d.push(d);var y=this.rotatePoint({x:h,y:i},this.center,this.angle),p=this.rotatePoint({x:h,y:e},this.center,this.angle);this.points2d.push(y),this.points2d.push(p);for(var x=Math.floor(this.sideThickness*le.res/3),g=0;g0?(c.clonePoint(i.startPoint,h.position1),c.clonePoint(i.endPoint,h.position2)):(c.clonePoint(i.endPoint,h.position1),c.clonePoint(i.startPoint,h.position2)),i.parent!=o&&se.changeSymbolForBelong(e,o),i.setOpenSide(t),i.setPoints2d(),se.setPosition3d(i))},oe.prototype.moveSymbolPoint=function(t,e,o){var i=se.moveSymbolSinglePoint(t,e,o);if(null==i)return null;var n=he.getSymbol(e),s={x:(n.startPoint.x+n.endPoint.x)/2,y:(n.startPoint.y+n.endPoint.y)/2},r=c.getDistance(s,i.position);if(ra.maxSymbolLen)return null;var l=he.getWall(n.parent),h=he.getPoint(l.start),u=he.getPoint(l.end);if(o==$){var d=se.getNewForContainSymbols(n.endPoint,i.position,n.parent,e);if(null==d||d.collision)return null;ct.isContain(l,i.position)?se.setPosition(n,i.position,"start"):c.getDistance(n.startPoint,h)-1&&t.children.splice(o,1),he.getSymbol(e).parent=null}},ne.prototype.deleteSymbol=function(t){var e=he.getSymbol(t);if(e.parent){var o=he.getWall(e.parent);this.deleteSymbolForWall(o,t)}he.deleteSymbol(t)},ne.prototype.changeSymbolForBelong=function(t,e){var o=he.getSymbol(t),i=o.parent,n=he.getWall(i);this.deleteSymbolForWall(n,t),o.setSymbolParent(e);var s=he.getWall(e);ct.addChildren(s,t)},ne.prototype.reBelongForSplitWall=function(t,e,o){for(var i=he.getWall(t),n=0;nu){if(S[k].vectorId==S[k+1].vectorId&&S[k].type!=y)return{position1:p,position2:x,collision:!0,state:!1};if(S[k].vectorId==S[k+1].vectorId&&S[k].type==y)return{position1:p,position2:x,collision:!0,state:!0};if(!c.isContainForSegment(p,S[k],S[k+1])||!c.isContainForSegment(x,S[k],S[k+1]))return{position1:p,position2:x,collision:!0,state:!1}}else{if(c.getDistance(S[k],S[k+1])d&&(e=d)}var y=c.getParallelLineForDistance(l,e/2),p=c.getIntersectionPoint(y.line1,s),x=c.getIntersectionPoint(y.line2,s),g={};c.getDistance(i,p)Math.min(v,S)&&(vc.getDistance(h.endPoint,y)?(y=null,x=null):u=Math.min(v,S));var P=c.getDistance(h.endPoint,m.startPoint),b=c.getDistance(h.endPoint,m.endPoint);d>Math.min(P,b)&&(Pc.getDistance(h.startPoint,p)?(p=null,g=null):d=Math.min(P,b))}return o&&(null==y&&(c.getDistance(r,h.startPoint)>c.getDistance(r,h.endPoint)?(y=l,x=l):(y=r,x=r)),null==p&&(c.getDistance(r,h.startPoint)>c.getDistance(r,h.endPoint)?(p=r,g=r):(p=l,g=l))),{startPosition:y,startPosition2:x,endPosition:p,endPosition2:g}},ne.prototype.moveSymbolSinglePoint=function(t,e,o){var i=he.getSymbol(e),n=c.createLine1(i.startPoint,i.endPoint),s=c.getVerticalLine(n,t);t=c.getIntersectionPoint(s,n);var r={x:(i.startPoint.x+i.endPoint.x)/2,y:(i.startPoint.y+i.endPoint.y)/2},l=he.getWall(i.parent),a=he.getPoint(l.start),h=he.getPoint(l.end);if("start"==o){if(!c.PointInSegment(r,t,i.endPoint))return null;c.getDistance(i.startPoint,a)c.getDistance(a,r)&&c.clonePoint(t,a):c.getDistance(t,r)>c.getDistance(h,r)&&c.clonePoint(t,h)}else if("end"==o){if(!c.PointInSegment(r,t,i.startPoint))return null;c.getDistance(i.endPoint,h)c.getDistance(h,r)&&c.clonePoint(t,h):c.getDistance(t,r)>c.getDistance(a,r)&&c.clonePoint(t,a)}return{dir:o,position:t}},ne.prototype.setSymbolInfo=function(t){var e=he.getSymbol(t.vectorId);return e.openSide=t.openSide,e.startPoint=t.start,e.endPoint=t.end,e.points2d=JSON.parse(JSON.stringify(t.points2d)),e.enter=t.enter,e.parent=t.parent,e},ne.prototype.setEnterImg=function(t){this.enterImg=t},ne.prototype.getEnterImg=function(){return this.enterImg},ne.prototype.createSymbolFromPanorama=function(t,e,o){var i=[],n={x:t.ray.origin.x,y:-1*t.ray.origin.z},s=he.getWalls();for(var r in s){var l=he.getWall(r),a=he.getPoint(l.start),h=he.getPoint(l.end),u=c.raySegmentIntersection(n,t.ray.direction,a,h);null!=u&&i.push({wallId:r,join:u})}if(i.length>0){function t(t,e){return c.getDistance(n,t.join)-c.getDistance(n,e.join)}i=i.sort(t.bind(this));var d=this.addSymbol(i[0].join,e,i[0].wallId);return null!=d?(ie.moveFullSymbol(i[0].join,d,i[0].wallId),he.getSymbol(d),d):(console.error("漫游模式下添加门/窗:门/窗区域太小,加不上"),null)}return console.error("漫游模式下添加门/窗:没有与任何墙相交"),null};var se=new ne,re=function(){this.defaultCenter=null,this.center=null,this.zoom=100,this.res=80,this.ratio=1,this.cadImg_Width=1920,this.cadImg_Height=937,this.initRes=null,this.initWidth=null,this.initHeight=null};re.prototype.init=function(t){var e=he.getBoundingBox();this.setCenter(e),this.updateForCanvas(t)},re.prototype.setInitInfo=function(t,e,o){null==this.initRes&&(this.initRes=t),null==this.initWidth&&(this.initWidth=e),null==this.initHeight&&(this.initHeight=o)},re.prototype.updateResForReSize=function(t,e,o){Math.abs(o)<.01||Math.abs(o-2*Math.PI)<.01?this.res=this.initRes*t/this.initWidth:this.res=this.initRes*e/this.initHeight,a.minRealDis=a.minPixDistance/this.res*a.defaultZoom/this.zoom,a.minAdsorb=a.minPixLen/this.res*a.defaultZoom/this.zoom},re.prototype.setCenter=function(t){this.defaultCenter?this.center={x:this.defaultCenter.x,y:this.defaultCenter.y}:(this.cadBoundingbox=JSON.parse(JSON.stringify(t)),null!=this.cadBoundingbox&&(this.center={x:(this.cadBoundingbox.maxX+this.cadBoundingbox.minX)/2,y:(this.cadBoundingbox.maxY+this.cadBoundingbox.minY)/2}))},re.prototype._setDefaultCenter=function(t){this.defaultCenter={x:t.x,y:t.y}},re.prototype.setDefaultCenter=function(t){this.defaultCenter={x:t.x,y:-t.z}},re.prototype._setRes=function(t){this.res=t,a.minRealDis=a.minPixDistance/this.res*a.defaultZoom/this.zoom,a.minAdsorb=a.minPixLen/this.res*a.defaultZoom/this.zoom},re.prototype.setRes=function(t,e){this.res=this.width/Math.abs(e-t),a.minRealDis=a.minPixDistance/this.res*a.defaultZoom/this.zoom,a.minAdsorb=a.minPixLen/this.res*a.defaultZoom/this.zoom},re.prototype.getScreenXY=function(t){if(null==this.width||null==this.height)return null;var e=t.x,o=t.y,i=this.width/2+(e-this.center.x)*this.res*this.zoom/100,n=this.height/2-(o-this.center.y)*this.res*this.zoom/100;return i=.5+(i*=this.ratio)<<0,n=.5+(n*=this.ratio)<<0,{x:Math.floor(i),y:Math.floor(n)}},re.prototype.getXYFromScreen=function(t){var e={};return e.x=(t.x-this.width/2)/this.res*100/this.zoom+this.center.x,e.y=(this.height/2-t.y)/this.res*100/this.zoom+this.center.y,e},re.prototype.getPointForRevRotate=function(t,e){if(Math.abs(e)<.01||Math.abs(e-2*Math.PI)<.01)return t;var o=(t.x-this.center.x)*Math.cos(e)-(t.y-this.center.y)*Math.sin(e)+this.center.x,i=(t.y-this.center.y)*Math.cos(e)+(t.x-this.center.x)*Math.sin(e)+this.center.y;return t.x=o,t.y=i,t},re.prototype.getVectorForRotate=function(t,e){if(e=-e,Math.abs(e)<.01||Math.abs(e-2*Math.PI)<.01)return t;var o=(t.x-this.center.x)*Math.cos(e)-(t.y-this.center.y)*Math.sin(e)+this.center.x,i=(t.y-this.center.y)*Math.cos(e)+(t.x-this.center.x)*Math.sin(e)+this.center.y;return t.x=o,t.y=i,t},re.prototype.updateCenterForRotate=function(t){if(!(Math.abs(t)<.01||Math.abs(t-2*Math.PI)<.01)){var e=this.center.x*Math.cos(t)-this.center.y*Math.sin(t),o=this.center.y*Math.cos(t)+this.center.x*Math.sin(t);return this.center.x=e,this.center.y=o,this.center}},re.prototype.updateForCanvas=function(t){t&&(this.width=t.clientWidth,this.height=t.clientHeight,t.width=t.clientWidth,t.height=t.clientHeight)},re.prototype.updateZoom=function(t){this.zoom=t,a.minRealDis=a.minPixDistance/this.res*a.defaultZoom/this.zoom,a.minAdsorb=a.minPixLen/this.res*a.defaultZoom/this.zoom},re.prototype.moveTo=function(t,e){var o=this.getXYFromScreen(e);this.zoom=t;var i=(100*e.x/this.zoom-this.width/2)/this.res,n=(this.height/2-100*e.y/this.zoom)/this.res;this.center.x=o.x-i,this.center.y=o.y-n},re.prototype.getXYFromScreenForDefaultZoom=function(t){var e={};return e.x=(t.x-this.width/2)/this.res+this.center.x,e.y=(this.height/2-t.y)/this.res+this.center.y,e},re.prototype.getScreenInfoForCAD=function(){var t=this.getXYFromScreen({x:this.width,y:this.height}),e=this.getXYFromScreen({x:0,y:0}),o={x:this.center.x,y:this.center.y};return{width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y),center:{x:o.x,y:o.y},defaultCenter:this.defaultCenter}},re.prototype.getPixelRatio=function(t){var e=t.backingStorePixelRatio||t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/e},re.prototype.reSet=function(){this.center={x:this.defaultCenter.x,y:this.defaultCenter.y},this.zoom=100},re.prototype.updateForRotate=function(t){void 0===t&&(t=Math.PI/2);for(var e=0;el.floors[s].boundingBox.minX)&&(e=l.floors[s].boundingBox.minX),(null==o||ol.floors[s].boundingBox.minY)&&(i=l.floors[s].boundingBox.minY),(null==n||ns.minX)&&(t=s.minX),(null==e||e>s.minY)&&(e=s.minY),(null==o||ol.x)&&(o=l.x),(null==i||il.y)&&(n=l.y),(null==s||sh)&&(o=h),(void 0===n||nc)&&(i=c),(void 0===s||s=h&&e[u].x<=c)continue;(h=Math.min(h,e[u].x))!=(c=Math.max(c,e[u].x))&&this.measureLines.top.push({x:e[u].x,y:this.region.top})}e=this.measureLines.top.sort(C.bind(this)),this.measureLines.top=[],this.measureLines.top.push(e[0]);for(var d=0;d=h&&o[x].x<=c)continue;(h=Math.min(h,o[x].x))!=(c=Math.max(c,o[x].x))&&this.measureLines.bottom.push({x:o[x].x,y:this.region.bottom})}o=this.measureLines.bottom.sort(C.bind(this)),this.measureLines.bottom=[],this.measureLines.bottom.push(o[0]);for(var g=0;g=h&&i[v].y<=c)continue;(h=Math.min(h,i[v].y))!=(c=Math.max(c,i[v].y))&&this.measureLines.left.push({x:this.region.left,y:i[v].y})}i=this.measureLines.left.sort(w.bind(this)),this.measureLines.left=[],this.measureLines.left.push(i[0]);for(var S=0;S=h&&n[I].y<=c)continue;(h=Math.min(h,n[I].y))!=(c=Math.max(c,n[I].y))&&this.measureLines.right.push({x:this.region.right,y:n[I].y})}n=this.measureLines.right.sort(w.bind(this)),this.measureLines.right=[],this.measureLines.right.push(n[0]);for(var k=0;k=i})).reduce((function(t,e){return e.fromBase(o)=1?e:t}));return l?[l.fromBase(o),l]:void 0},fe.prototype.getMostRelevantMeasurement2=function(t,e,o,i){void 0===i&&(i=0);var n=[],s=xe.getUnitsOfMeasurementByDomainAndSystem(t,e);for(var r in s)n.push(s[r]);var l=n.filter((function(t){return t.factor>=i})).reduce((function(t,e){return e.toBase(o)=1?e:t}));return l?[l.toBase(o),l]:void 0},fe.prototype.convertBack=function(t,e,o,i,n){if(void 0===o&&(o=2),!t)return"";t=t.trim().replace(",","");var s=xe.getDefaultUnitByDomainAndSystem(e,"metric"),r=this.getMostRelevantMeasurement2(e,i,t,n);return this.getFormattedMeasurementString(r[0],s,o)};var me=new fe,ve=function(){};ve.prototype.createTag=function(t,e,o){var i=new ce(t,e);return i.setPoints2d(),he.addTag(i,o),i},ve.prototype.setTagInfo=function(t){var e=he.getTag(t.vectorId);e.vectorId=t.vectorId,e.center=JSON.parse(JSON.stringify(t.center)),e.points2d=JSON.parse(JSON.stringify(t.points2d)),e.title=t.title,e.des=t.des,e.unit=t.unit,e.adding=t.adding},ve.prototype.deleteTag=function(t,e){he.deleteTag(t,e)},ve.prototype.clearDefaultTags=function(){for(var t=0;tx)&&(i={distance:x,pointId:d.start},c.getDistance(f,t)c.getDistance(t,y)&&(s.x=y.x,s.linkedPointIdX=d.start)}else s.x=y.x,s.linkedPointIdX=d.start;if(Math.abs(t.y-y.y)c.getDistance(t,y)&&(s.y=y.y,s.linkedPointIdY=d.start)}else s.y=y.y,s.linkedPointIdY=d.start}if(-1==l.indexOf(d.end)){if(l.push(d.end),x=c.getDistance(t,p),(null==i||i.distance>x)&&(i={distance:x,pointId:d.end},c.getDistance(f,t)c.getDistance(t,p)&&(s.x=p.x,s.linkedPointIdX=d.end)}else s.x=p.x,s.linkedPointIdX=d.end;if(Math.abs(t.y-p.y)c.getDistance(t,p)&&(s.y=p.y,s.linkedPointIdY=d.end)}else s.y=p.y,s.linkedPointIdY=d.end}x=c.getDistance(t,f);var b=ct.isContain(d,f);b&&(null==n||n.distance>x)&&(n={distance:x,wallId:u}),b&&c.getDistance(t,f)0};var Ye=new _e;window.historyService=Ye;var Ne=function(t){this.layer=t,this.app=this.layer.app,this.houseData=null};Ne.prototype.initVectors=function(t){for(var e=t.floors,o=-1,i=0,n=0,s=0;sf.x)&&(h=f.x),(null==c||c>f.y)&&(c=f.y),(null==d||ds.x||o.x===s.x&&o.y>s.y)&&(o={x:s.x,y:s.y},i=n)}return i},no.prototype.createPolygon=function(t,e,o){if(0!==Object.keys(o).length&&0!==Object.keys(e).length){this.matrix={};var i=[];this.preHandle(o,e);var n=Object.keys(e).length;if(0!==Object.keys(o).length&&0!==Object.keys(e).length){null!==t&&o[t]||(t=this.getStartPoint(o)),i.push(t);var s=this.getNextForMinAngleX(t,o,e);if(null!==s){i.push(s);var r=this.getMaxPolygon(i,o,e);this.checkPolygonSegmentIds(r,o,e);var l=this.splitPolygon(r);if(l){var a=this.getPolygonData(l,o,e),h=Object.keys(a.points),c=Object.keys(a.segments);if(a.segments=this.getChildSegments(a.points,a.segments,e),this.createPolygon(l[0],a.segments,a.points),this.updateMartix2(h,c,o,e),this.preHandle(o,e),0===Object.keys(o).length||0===Object.keys(e).length)return;this.createPolygon(t,e,o)}else if(0!==Object.keys(o).length&&0!==Object.keys(e).length){this.maxPolygons.push(r),this.updateMartix(r,o,e),o[t]||(t=this.getStartPoint(o),s=this.getNextForMinAngleX(t,o,e));var u=[];u.push(t),u.push(s);var d=this.getMinPolygon(u,o,e);if(this.checkPolygonSegmentIds(d,o,e),l=this.splitPolygon(d)){var y=this.getPolygonData(l,o,e),p=Object.keys(y.points),x=Object.keys(y.segments);if(this.createPolygon(l[0],y.segments,y.points),this.updateMartix2(p,x,o,e),this.preHandle(o,e),0===Object.keys(o).length||0===Object.keys(e).length)return;this.createPolygon(t,e,o)}else if(0!==r.length&&0!==d.length){if(this.addPolygon(d,o,e)){var g=d.slice(0);if(g.push(d[0]),this.updateMartix(g,o,e),this.preHandle(o,e),0===Object.keys(o).length||0===Object.keys(e).length)return}if(n===Object.keys(e).length){this.addPolygon(r,o,e);var f=r.slice(0);if(f.push(r[0]),this.updateMartix(f,o,e),this.updateMartix(f,o,e),this.preHandle(o,e),0===Object.keys(o).length||0===Object.keys(e).length)return}var m=this.getStartPoint(o,t);this.createPolygon(m,e,o)}else console.error("createPolygon——————————————————————————————————————————————————————————————出错!")}}}}},no.prototype.splitPolygon=function(t){for(var e=[],o=0;o-1||h.indexOf(d)>-1)){var y=e[d];if(c.isPointInPoly(y,s)){h.push(d);var p=y.parent;for(var x in p)if(o[x]&&!n[x]&&-1===u.indexOf(x)){var g=null;o[x].start===d?g=o[x].end:o[x].end===d&&(g=o[x].start);var f=e[g];t.indexOf(g)>-1||h.indexOf(g)>-1?u.push(x):c.isPointInPoly(f,s)&&(u.push(x),h.push(g))}}}for(var m=0;mh)&&(s=h,r=n[l])}}return r},no.prototype.getNextForMaxMinAngle=function(t,e,o,i){var n=o[t],s=o[e];n&&s||console.error("getNextForMaxMinAngle******************************************");for(var r=s.x-n.x,l=s.y-n.y,a={x:s.x+r,y:s.y+l},h=this.getAllLinkedPoint(e,o,i),u=null,d=null,y=null,p=null,x=0;xf)&&(y=f,p=h[x])}}return{max:d,min:p}},no.prototype.updateMartix=function(t,e,o){for(var i=0;i1)continue;delete t[i]}}return o},no.prototype.getPoint=function(t,e){return e[t]},no.prototype.isClockwise=function(t,e){for(var o=[],i=0;i-1))for(var l=t[r],a=e[l.start],h=e[l.end],c=0;c-1||this.containPoint(y,a))&&(u=!0),(y.pointIds.indexOf(l.end)>-1||this.containPoint(y,h))&&(d=!0),u&&d&&y.childrenSegmentIds.push(r)}},no.prototype.isContain=function(t,e){for(var o=[],i=[],n=0;n-1&&(e=e.concat(n.pointIds),o=o.concat(n.segmentIds))}for(var s={},r={},l=0;l-1){e.splice(l,1),--l;break}this.getChildMaxPolygons(t,e)}else if(1===e.length){var c=this.getPolygon(e[0]);t.caves.push(c.pointIds)}},no.prototype.getPolygon=function(t){for(var e=0;e-1||i.indexOf(r.end)>-1)){var l=he.getPoint(r.start),h=he.getPoint(r.end),u=!1;if(o.indexOf(r.start)<0){o.push(r.start);var d=c.getJoinLinePoint(l,n);c.PointInSegment(d,this.startInfo.position,this.endInfo.position,a.minAdsorb)&&c.getDistance(l,d)>e/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t)},nth:function(t){return 1===(t%=10)?t+"st":2===t?t+"nd":3===t?t+"rd":t+"th"},extendObject:function(t,e){return Object.keys(e).forEach((function(o){t[o]=e[o]})),t},deepExtend:function t(e){var o=arguments;e=e||{};for(var i=1;i=e&&(t.apply(n,o),lastCallTime=s)}:function(){for(var o=[],n=arguments.length;n--;)o[n]=arguments[n];i&&clearTimeout(i);var s=this;i=setTimeout((function(){t.apply(s,o)}),e)}},getMixedSet:function(t,e){return t.filter((function(t){return e.includes(t)}))},getUnionSet:function(t,e){return t.concat(e.filter((function(e){return!t.includes(e)})))},getDifferenceSet:function(t,e){var o=t.filter((function(t){return!e.includes(t)})),i=e.filter((function(e){return!t.includes(e)}));return o.concat(i)},getDifferenceSetMuti:function(t){var e=[];return t.forEach((function(t){t.forEach((function(t){var o=e.indexOf(t);o>-1?e.splice(o,1):e.push(t)}))})),e},getMAXCUBETEXTURESIZE:function(){try{var t=document.createElement("canvas"),e=t.getContext("webgl");return e||(e=t.getContext("experimental-webgl")),e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE)}catch(t){return 0}}},mo=((po=new THREE.TextureLoader).setCrossOrigin("Anonymous"),po.crossOrigin=!0,function(t,e,o,i){var n=po.load(t,e,o,i);return n.magFilter=n.minFilter=THREE.LinearFilter,n.needsUpadte=!0,n});fo.dataURLtoBlob=function(t){for(var e=t.split(","),o=e[0].match(/:(.*?);/)[1],i=atob(e[1]),n=i.length,s=new Uint8Array(n);n--;)s[n]=i.charCodeAt(n);return new Blob([s],{type:o})},fo.dataURLtoFile=function(t,e){for(var o=t.split(","),i=o[0].match(/:(.*?);/)[1],n=atob(o[1]),s=n.length,r=new Uint8Array(s);s--;)r[s]=n.charCodeAt(s);return new File([r],e,{type:i})},fo.saveFile=function(t,e,o){var i=document.createElementNS("http://www.w3.org/1999/xhtml","a");i.href=t,i.download=e;var n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),i.dispatchEvent(n),o&&o()},fo.PrefixPng="data:image/png;base64,",fo.getBlobSrc=function(t,e){var o=fo.dataURLtoBlob((e?fo.PrefixPng:"")+t);return window.URL.createObjectURL(o)},fo.replaceAll=function(t,e,o){var i=new RegExp(e,"g");return t.replace(i,o)},fo.randomWord=function(t,e,o){var i="",n=e,s=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];t&&(n=Math.round(Math.random()*(o-e))+e);for(var r=0;r-1&&(n="cancel",t.unvisibleReasons.splice(s,1)),"add"==n&&(t.visibleReasons.some((function(t){return t.reason==e}))||t.visibleReasons.push({reason:e,level:i}))):((s=t.visibleReasons.findIndex((function(t){return t.reason==e})))>-1&&(n="cancel",t.visibleReasons.splice(s,1)),"cancel"!=n&&(t.unvisibleReasons.some((function(t){return t.reason==e}))||t.unvisibleReasons.push({reason:e,level:i})));!function(){t.unvisibleReasons=t.unvisibleReasons.sort((function(t,e){return e.level-t.level})),t.visibleReasons=t.visibleReasons.sort((function(t,e){return e.level-t.level}));var o=(t.visibleReasons[0]?t.visibleReasons[0].level:-1)>=(t.unvisibleReasons[0]?t.unvisibleReasons[0].level:-1);t.visible!=o&&(t.visible=o,t.dispatchEvent({type:"isVisible",visible:o,reason:e}))}()},fo.getObjVisiByReason=function(t,e){return!!t.visible||(!t.unvisibleReasons||!t.unvisibleReasons.some((function(t){return t.reason==e})))},fo.setCameraLayers=function(t,e,o){void 0===o&&(o=[]),t.layers.disableAll(),e.concat(o).forEach((function(e){var o=Potree.config.renderLayers[e];null!=o?t.layers.enable(o):console.error("setCameraLayer没找到layer!")}))},fo.setObjectLayers=function(t,e){var o=Potree.config.renderLayers[e];null!=o?t.traverse((function(t){t.layers.set(o)})):console.error("setCameraLayer没找到layer!")},fo.intervalTool={list:[],isWaiting:function(t,e,o){var i=this,n=this.list.find((function(e){return e.name==t}));if(n)n.requestUpdate=!0;else{var s=e();n={name:t},this.list.push(n),setTimeout((function(){var r=i.list.indexOf(n);i.list.splice(r,1),(n.requestUpdate||s)&&i.isWaiting(t,e,o)}),o)}}},fo.batchHandling={lists:[],getSlice:function(t,e,o){var i=o.stopWhenAllUsed,n=o.minCount;void 0===n&&(n=5);var s=o.maxCount;void 0===s&&(s=100);var r=o.durBound1,l=o.durBound2,a=o.maxUseCount;if(0==e.length||!(a=null==a?fo.getBestCount({name:t,minCount:n,maxCount:s,durBound1:r,durBound2:l,ifLog:!1}):a))return{list:[]};this.lists[t]||(this.lists[t]={list:[]});var h=this.lists[t].list.filter((function(t){return e.some((function(e){return t.item==e}))}));this.lists[t].list=h,e.forEach((function(t){h.some((function(e){return e.item==t}))||h.push({item:t,count:0})}));var c=h.filter((function(t){return 0==t.count})),u=[];if(c.slice(0,a).forEach((function(t){u.push(t.item),t.count++})),c.length>a);else{if(!i){var d=Math.min(e.length,a)-u.length;h.slice(0,d).forEach((function(t){u.push(t.item),t.count++}))}h.forEach((function(t){return t.count--}))}return{list:u}},addSliceListen:function(t){var e=t.getList,o=t.callback,i=t.minCount,n=t.maxCount;t.durBound1,t.durBound2,t.maxHistory;var s,r,l=t.player;l.on("update",(function(t){if(!l.flying){var a,h=e(),c=!l.lastFrameChanged,u=l.lastFrameChanged||!r;u?(a=h,s=null):(s||(s=fo.getDifferenceSet(h,r)),a=s);var d=fo.batchHandling.getSlice("ifVideoInsight",a,{stopWhenAllUsed:c,minCount:i,maxCount:n,durBound1:3,durBound2:13,maxHistory:3}).list;d.forEach(o),u||(s=fo.getDifferenceSet(s,d)),r=d}}))}},fo.getBestCount=(vo={},function(t){var e=t.name,o=t.minCount;void 0===o&&(o=1);var i=t.maxCount;void 0===i&&(i=6);var n=t.durBound1;void 0===n&&(n=1);var s=t.durBound2;void 0===s&&(s=4);var r,l=t.ifLog,a=t.maxHistory,h=performance.getEntriesByName("loop-start");if(h.length){var c=performance.now()-h[h.length-1].startTime;r=Math.round(math.linearClamp(c,n,s,i,o)),a&&(vo[e]||(vo[e]=[]),0==r&&vo[e].length>a-1&&!vo[e].some((function(t){return t>0}))&&(r=1),vo[e].push(r),vo[e].length>a&&vo[e].splice(0,1)),l&&console.log(e,r," ,dur:",c.toFixed(3))}else r=i;return r}),fo.getPos2d=function(t,e,o,i){o=o||e.camera,i=i||e.domElement;var n,s,r=t.clone().project(o);n=(r.x+1)/2*i.clientWidth,s=(1-(r.y+1)/2)*i.clientHeight;var l=n<=i.clientWidth&&n>=0&&s<=i.clientHeight&&s>=0;return{pos:new THREE.Vector2(n,s),vector:r,trueSide:r.z<1,inSight:l}},fo.realVisible=function(t){for(var e,o=!0,i=t;i;){if(!1===i.visible){o=!1;break}e=i,i=i.parent}return!o||e instanceof THREE.Scene||(o=!1),o};var So=function(t){this.layer=t,this.showTexture=!0},Po={selectUI:{configurable:!0},currentUI:{configurable:!0},currentFloor:{configurable:!0},currentUnit:{configurable:!0}};Po.selectUI.get=function(){return this.layer.$xui.selectName},Po.selectUI.set=function(t){this.layer.$xui.selectName=t,this.layer.updateEventNameForSelectUI()},Po.currentUI.get=function(){return this.layer.$xui.currentName},Po.currentUI.set=function(t){null===t?this.layer.$xui.hideProps():this.layer.$xui.showProps(t)},Po.currentFloor.get=function(){return this.layer.$xui.currentFloor},Po.currentFloor.set=function(t){this.layer.display&&("image"==this.layer.app.store.getValue("flooruser").type?he.setCurrentFloor(t):(he.setCurrentFloor(t),this.layer.initPanos(he.currentFloor),de.update(!1),Ye.clearHistoryRecord(),this.layer.$xui.toolbar.recall=!1,this.layer.$xui.toolbar.recover=!1,this.layer.history.init(),setTimeout(function(){this.layer.renderer.autoRedraw()}.bind(this),50)))},Po.currentUnit.get=function(){return this.layer.$xui.currentUnit},Po.currentUnit.set=function(t){this.layer.uiControl.currentUI=null,de.unit=t,Se.convertUnit(t),this.layer.history.save(),this.layer.renderer.autoRedraw()},So.prototype.setAttributes=function(t,e,o){console.log(e);var i=ee.getFocusItem();switch(e){case"remove":if(t==y||"OutWall"==t)he.deleteWall(i.vectorId);else if(se.isSymbol(t))se.deleteSymbol(i.vectorId);else if(xt.isComponent(t))he.deleteComponent(i.vectorId);else if(t==T){he.deleteTag(i.vectorId);var n=ee.getDraggingItem();n&&n.vectorId!=i.vectorId&&he.deleteTag(n.vectorId)}else t==d?ct.deleteWallCorner(i.vectorId):Qt.isFurniture(t)&&he.deleteFurniture(i.vectorId);ee.clearItems(),ee.clearEventName(),this.layer.renderer.autoRedraw();break;case"rotate":if(se.isSymbol(t)){var s=he.getSymbol(i.vectorId);if(t==p){if(s.openSide==K)if(c.isClockwise(s.points2d))s.openSide=q;else{var r=s.endPoint;s.endPoint=s.startPoint,s.startPoint=r,s.openSide=q}else if(s.openSide==q)if(c.isClockwise(s.points2d))s.openSide=K;else{var l=s.endPoint;s.endPoint=s.startPoint,s.startPoint=l,s.openSide=K}}else if(t==g||t==x||t==m)s.openSide==K?s.openSide=q:s.openSide==q&&(s.openSide=K);else{var a=s.endPoint;s.endPoint=s.startPoint,s.startPoint=a}s.setPoints2d(),this.layer.renderer.autoRedraw()}break;case"angle":if(xt.isComponent(t)){var h=he.getComponent(i.vectorId);h.angle=o,h.setPoints2d(),this.layer.renderer.autoRedraw()}else if(Qt.isFurniture(t)){he.getFurniture(i.vectorId).angle=o,this.layer.renderer.autoRedraw()}break;case"width":if(se.isSymbol(t)){if(se.updateSymbolForLen(i.vectorId,o).block){var u=he.getSymbol(i.vectorId);console.log("长度阻止:"+c.getDistance(u.startPoint,u.endPoint)),this.layer.$xui.currentAttributes={limit:c.getDistance(u.startPoint,u.endPoint),type:i.type,name:"width",width:c.getDistance(u.startPoint,u.endPoint),thickness:u.thickness}}}else if(xt.isComponent(t)){var f=he.getComponent(i.vectorId);f.sideWidth=o,f.setPoints2d()}this.layer.renderer.autoRedraw();break;case"scale":if(Qt.isFurniture(t))he.getFurniture(i.vectorId).zoom=o,this.layer.renderer.autoRedraw();break;case"thickness":if(xt.isComponent(t)){var v=he.getComponent(i.vectorId);v.sideThickness=o,v.setPoints2d(),this.layer.renderer.autoRedraw()}else if(t==m){var S=he.getSymbol(i.vectorId);S.thickness=o,S.setPoints2d(),this.layer.renderer.autoRedraw()}break;case"split":if(t==y||"OutWall"==t){var P=he.getWall(i.vectorId),b=he.getPoint(P.start),I=he.getPoint(P.end),k={x:(b.x+I.x)/2,y:(b.y+I.y)/2},F=ct.createPoint(k.x,k.y),w=ct.splitWall(i.vectorId,F.vectorId,"start");P=he.getWall(i.vectorId),b=he.getPoint(P.start),I=he.getPoint(P.end);var C={x:(b.x+I.x)/2,y:(b.y+I.y)/2},W={vectorId:w,type:t};(k.xC.y)&&ee.setFocusItem(W),this.layer.renderer.autoRedraw()}break;case"tag":if(t==T){var D=he.getTag(i.vectorId);null!=o&&""!=o.trim()?D.setTitle(o):D.setTitle(KanKan.Config.i18n("cad.input")),this.layer.renderer.autoRedraw()}break;case"area":if(t==T){var z=he.getTag(i.vectorId);z.setDes(o),z.setUnit(de.unit),this.layer.renderer.autoRedraw()}break;case"default":if("compass"==t)return void he.setCompass(0);if(se.isSymbol(t)){var L=se.getDefaultSymbolLen(t),M=se.updateSymbolForLen(i.vectorId,L);he.getSymbol(i.vectorId).enter=null,M.block||(this.layer.$xui.currentAttributes={type:i.type,name:"width",width:c.getFixed(c.getDistance(M.start,M.end),2)})}else if(xt.isComponent(t)){var R=he.getComponent(i.vectorId);R.sideWidth=xt.sideWidth,R.sideThickness=xt.sideThickness,R.angle=0,R.setPoints2d(),this.layer.$xui.currentAttributes={name:i.type,width:c.getFixed(R.sideWidth,2),thickness:c.getFixed(R.sideThickness,2),angle:0}}this.layer.renderer.autoRedraw();break;case"enter":if(t==p||t==x||t==g){var O=he.getSymbol(i.vectorId);O.enter=o?"default":null,this.layer.renderer.autoRedraw()}break;case"enterRotate":if(t==p||t==x||t==g){var A=he.getSymbol(i.vectorId);null==A.enter?A.enter="default":"default"==A.enter?A.enter="reverse":"reverse"==A.enter&&(A.enter="default")}this.layer.renderer.autoRedraw();break;case"important":if(t==y)he.getWall(i.vectorId).setImportant(o),this.layer.renderer.autoRedraw();break;case"wallType":if(t==y){var E=he.getWall(i.vectorId);"OutWall"==o?E.setOut(!0):E.setOut(!1),this.layer.renderer.autoRedraw()}break;case"compass":he.setCompass(parseFloat(o))}},So.prototype.saveAttributes=function(t,e){"compass"==e||"compass"==t&&"default"==e||this.layer.history.save()},So.prototype.showAttributes=function(t){if("compass"!=t){var e=ee.getFocusItem();if(null==e&&(e=ee.getDraggingItem()),se.isSymbol(e.type)){var o=he.getSymbol(e.vectorId),i=c.getDistance(o.startPoint,o.endPoint);i=c.getFixed(i,2),e.type==p||e.type==x||e.type==g?this.layer.$xui.currentAttributes={name:e.type,width:i,enter:o.enter?o.enter:null}:e.type==m?this.layer.$xui.currentAttributes={name:e.type,width:i,thickness:c.getFixed(o.thickness,2)}:this.layer.$xui.currentAttributes={name:e.type,width:i}}else if(xt.isComponent(e.type)){var n=he.getComponent(e.vectorId),s=n.sideWidth,r=n.sideThickness;this.layer.$xui.currentAttributes={name:e.type,width:c.getFixed(s,2),thickness:c.getFixed(r,2),angle:n.angle}}else if(e.type==T){var l=he.getTag(e.vectorId);this.layer.$xui.currentAttributes={name:e.type,tag:l.title,area:l.des}}else if(e.type==y){var a=he.getWall(e.vectorId);this.layer.$xui.currentAttributes={name:a.out?"OutWall":e.type,important:a.important||a.out,wallType:a.out?"OutWall":e.type}}else if(Qt.isFurniture(e.type)){var h=he.getFurniture(e.vectorId),u=h.zoom;this.layer.$xui.currentAttributes={name:e.type,scale:u,angle:h.angle}}}else this.layer.$xui.currentAttributes={name:"compass",compass:he.getCompass()}},So.prototype.clearUI=function(){this.selectUI=null},So.prototype.getSymbolTypeForUI=function(){return this.selectUI==vt?p:this.selectUI==St?x:this.selectUI==Pt?g:this.selectUI==bt?f:this.selectUI==It?m:this.selectUI==kt?v:this.selectUI==Tt?S:void 0},So.prototype.getComponentTypeForUI=function(){return this.selectUI==Ft?P:this.selectUI==wt?b:this.selectUI==Ct?I:void 0},So.prototype.getFurnitureTypeForUI=function(){return this.selectUI==Dt?F:this.selectUI==zt?w:this.selectUI==Lt?C:this.selectUI==Mt?W:this.selectUI==Rt?D:this.selectUI==Ot?z:this.selectUI==At?L:this.selectUI==Et?M:this.selectUI==Bt?R:this.selectUI==_t?O:this.selectUI==Yt?A:this.selectUI==Nt?E:this.selectUI==Xt?B:this.selectUI==jt?_:this.selectUI==Ut?Y:this.selectUI==Jt?N:this.selectUI==Vt?X:this.selectUI==Ht?j:this.selectUI==$t?U:this.selectUI==Zt?J:this.selectUI==Gt?V:void 0},So.prototype.screenShot=function(t){var e=this;return new Promise((function(o){e.menu_flex(),ee.clearItems(),ho.start();var i=e.layer.canvas;le.setRadio(a.ratio),i.width=window.innerWidth*le.ratio,i.height=window.innerHeight*le.ratio,le.width=window.innerWidth,le.height=window.innerHeight;var n=e.layer.app.core.get("CameraControls").activeControl.camera;le.res=Math.min(window.innerWidth/Math.abs(n.right-n.left),window.innerHeight/Math.abs(n.top-n.bottom)),setTimeout(function(){var e=this;if(1==he.getFloorNum())de.update(!0),this.layer.renderer.autoRedrawForDownLoadImg(t),this.downloadCadImg(i,"floorPlan.jpg");else{var s=he.getCurrentFloor();xo.save(le.res,le.center,le.defaultCenter,s),this.layer.app.store.getValue("flooruser").floors.forEach((function(o,n){e.currentFloor=o.subgroup,xo.setTransform(o.subgroup),de.update(!0),e.layer.renderer.autoRedrawForDownLoadImg(t),fo.canvasToImg(i,3,!0,"image/jpeg",o.name+".jpg")})),this.currentFloor=s,xo.recover()}le.updateForCanvas(i),le.setRes(n.left,n.right),le.ratio=1,de.updateRegion(!0),de.update(!1),this.layer.renderer.autoRedraw(),o()}.bind(e),100)}))},So.prototype.downloadPanosImg=function(){var t=this;return new Promise((function(e){var o=__sdk.core.get("Player"),i=go("panoImgcolor",!0)?"#"+go("panoImgcolor",!0):"#fff",n=o.domElement.clientWidth,s=o.domElement.clientHeight,r=t.layer.app.store.getValue("metadata").floorPlanAngle;r=parseFloat(r);var l=o.model.size.clone().applyEuler(new THREE.Euler(0,r,0));l.x=Math.abs(l.x),l.z=Math.abs(l.z),s=Math.round(l.z/l.x*n),o.domElement.clientHeight,o.cameraControls.controls.floorplan.screenshot=!0,o.flyToMode("floorplan",(function(){o.domElement.style.height=s+"px",o.domElement.style.transformOrigin="top",o.$app.core.get("SceneRenderer").updateScreenSize();o.floorplanMode(null,null,null,1.2),o.updateFromControls();var t=Math.max(n,s);n=Math.round(1024/t*n),s=Math.round(1024/t*s);for(var r,a=1/0,h=o.model.currentFloor.panos.filter((function(t){return t.isAligned()})),c=0,u=h.length;c.001&&(a=y,r=[h[c].id,h[d].id])}r&&console.log("最小距离:"+a+", panos: "+r[0]+", "+r[1]);var p=35*Math.max(l.x,l.z)/a*1.2;p>Math.max(n,s)&&(p=Math.min(8192,Math.round(p)),console.log(p),n>s?(s=Math.round(s/n*p),n=p):(n=Math.round(n/s*p),s=p)),o.$app.Camera.screenshot([{width:n,height:s}],!1).done((function(t){var r=document.createElement("canvas");r.width=n,r.height=s;var l=r.getContext("2d"),a=new Image;a.src=t[0].data,a.onload=function(){l.drawImage(a,0,0),l.font="14px sans-serif",l.fillStyle=i,l.shadowColor="rgba(0, 0, 0, 1)",l.shadowOffsetX=1,l.shadowOffsetY=1,l.shadowBlur=2,l.strokeStyle=i,l.lineWidth="2",l.textAlign="center",l.textBaseline="middle",t.o.camera.projectionMatrix.elements[5]=-t.o.camera.projectionMatrix.elements[5],h.forEach((function(e){var i=fo.getPos2d(e.position,o,t.o.camera),r=(i.vector.x+1)/2*n,a=(1-(i.vector.y+1)/2)*s;l.fillText(e.id+"",r,a-10),l.beginPath(),l.arc(r,a,1,0,2*Math.PI),l.stroke()})),fo.canvasToImg(r,.9,!0,"image/jpeg","点位图.jpg"),e()},o.domElement.style.height="",o.domElement.style.transform="",o.domElement.style.transformOrigin="",o.$app.core.get("SceneRenderer").updateScreenSize(),o.floorplanMode(),o.cameraControls.controls.floorplan.screenshot=!1}))}))}))},So.prototype.downloadCadImg=function(t,e){var o=t.toDataURL("jpg",3);o=o.replace(this._fixType("jpg"),"image/octet-stream"),this.saveFile(o,e)},So.prototype.saveFile=function(t,e){var o=document.createElementNS("http://www.w3.org/1999/xhtml","a");o.href=t,o.download=e;var i=document.createEvent("MouseEvents");i.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),o.dispatchEvent(i)},So.prototype._fixType=function(t){return"image/"+(t=t.toLowerCase().replace(/jpg/i,"jpeg")).match(/png|jpeg|bmp|gif/)[0]},So.prototype.execute=function(t,e){var o=this;switch(ee.clearFocusItem(),ee.clearSelectItem(),this.layer.uiControl.currentUI=null,t){case"recall":this.menu_revoke();break;case"recover":this.menu_recovery();break;case"default":this.menu_default();break;case"download":this.layer.div.style.visibility="hidden",this.menu_screenShot(e).then((function(){o.layer.div.style.visibility="visible"}));break;case"texture":this.showTexture=e,this.layer.app.dom.querySelector('.player[name="main"]').style.visibility=this.showTexture?"visible":"hidden";break;case"clear":this.menu_clear();break;case"panos":this.menu_panos(e);break;case"rotate":this.menu_rotate();break;case"flex":this.menu_flex()}},So.prototype.menu_revoke=function(){this.layer.stopAddVector(),this.layer.revokeHistory()},So.prototype.menu_recovery=function(){this.layer.recoveryHistory()},So.prototype.menu_default=function(){var t=this;Ye.clearHistoryRecord();var e=he.angle;he.setAngle(0),this.layer.app.store.getValue("metadata").floorPlanUser=0,this.layer.app.store.getValue("metadata").floorPlanAngle=0,this.menu_flex(!0);var o=le.getScreenInfoForCAD();if(0!=e){o.floorPlanAngle=0,this.layer.app.store.getValue("metadata").floorPlanAngle=0,this.layer.app.core.get("CameraControls").emit("syncCadAnd3DForRotate",o);var i=this.layer.app.core.get("CameraControls").activeControl.camera;le.setRes(i.left,i.right)}var n=he.getCurrentFloor();this.layer.load.loadFloorJson(!0).then((function(){t.layer.app.core.get("Player").model.floorplanCadImg.updateAllCadPlanes(),t.layer.app.core.get("Player").model.floorplanCadImg.changeModelOpacity(1),he.setCurrentFloor(n),t.layer.render(),t.layer.app.MinMap.reload(),t.layer.app.core.get("Player").labelManager.reset()}))},So.prototype.menu_screenShot=function(t){return this.layer.stopAddVector(),this.screenShot(t)},So.prototype.menu_clear=function(t){he.clear(t),ee.clearEventName(),uo.clear(),Be.hideAll(),this.layer.history.save(),this.layer.renderer.autoRedraw()},So.prototype.menu_panos=function(t){this.layer.renderer.displayPanos=t,this.layer.renderer.autoRedraw()},So.prototype.menu_rotate=function(){le.reSet();var t=he.getAngle();t=parseFloat(t)+Math.PI/2,Math.abs(t-2*Math.PI)<.1&&(t=0),t%=360,he.setAngle(t);var e=le.getScreenInfoForCAD();e.floorPlanAngle=t,this.layer.app.store.getValue("metadata").floorPlanAngle=t,this.layer.app.core.get("CameraControls").emit("syncCadAnd3DForRotate",e);var o=this.layer.app.core.get("CameraControls").activeControl.camera;le.setRes(o.left,o.right),le.updateForRotate(),this.layer.initPanos(he.getCurrentFloor()),de.update(!1),this.layer.history.save(),this.layer.renderer.autoRedraw()},So.prototype.menu_flex=function(t){if(le.center){le.reSet(),this.layer.renderer.autoRedraw();var e=le.getScreenInfoForCAD();if(e.floorPlanAngle=he.getAngle(),this.layer.app.core.get("CameraControls").emit("syncCadAnd3D",e),t){var o=this.layer.app.core.get("CameraControls").activeControl.camera;le.setRes(o.left,o.right)}}},Object.defineProperties(So.prototype,Po);var bo={strokeStyle:"#FFFFFF",lineWidth:4,lineWidth_out:8,important:{strokeStyle:"#FFFFFF",lineWidth:8},error:{strokeStyle:"rgba(255,0,0,0.5)",fillStyle:"rgba(255,0,0,0.8)"}},Io={strokeStyle:"green",fillStyle:"rgb(0, 200, 175)",radius:4},ko={strokeStyle:"rgba(255,255,255,1)",fillStyle:"rgba(255,255,255,0)",lineWidth:1,Pass:{}},To={strokeStyle:"rgba(255,255,255,1)",fillStyle:"rgba(255,255,255,0)",lineWidth:1},Fo={strokeStyle:"rgb(255,255,255,1)",fillStyle:"rgb(255,255,255,1)",strokeStyle_adding:"rgba(243, 255, 0, 0.8)",fillStyle_adding:"rgba(243, 255, 0, 0.8)",lineWidth:1},wo={strokeStyle:"rgb(255,255,255,1)",fillStyle:"rgba(0,0,0,0)",lineWidth:1},Co={Wall:{strokeStyle:"rgba(243, 255, 0, 1)"},Wall_out:{strokeStyle:"rgba(243, 255, 0, 1)"},Symbol:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)",lineWidth:2},Component:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)"},Tag:{strokeStyle:"#00C8AF",fillStyle:"#00C8AF"},Furniture:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)"},Point:{radius:4,lineWidth:2,fillStyle:"rgba(245, 255, 0, 1)",strokeStyle:"rgba(245, 255, 255, 1)"}},Wo={Wall:{strokeStyle:"rgba(243, 255, 0, 1)"},Wall_out:{strokeStyle:"rgba(162, 164, 124, 1)"},Symbol:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)"},Component:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)"},Tag:{strokeStyle:"#00C8AF",fillStyle:"#00C8AF"},Furniture:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)"},Point:{radius:4,lineWidth:2,fillStyle:"rgba(245, 255, 0, 1)",strokeStyle:"rgba(245, 255, 255, 1)"}},Do={StartAddWall:{radius:4,fillStyle:"yellow",strokeStyle:"green"},NewWall:{lineWidth:4,lineWidth_out:6,strokeStyle:"rgba(255,255,255,0.3)",strokeStyle_out:"rgba(102,102,102,0.3)",errorStrokeStyle:"rgb(250,63,72,0.3)"},StartSymbolPoints:{radius:4,fillStyle:"yellow",strokeStyle:"green"},EndSymbolPoints:{radius:4,fillStyle:"yellow",strokeStyle:"green"},CheckLinesX:{lineWidth:2,strokeStyle:"#CED806"},CheckLinesY:{lineWidth:2,strokeStyle:"#CED806"},VCheckLinesX:{lineWidth:2,strokeStyle:"#CED806"},VCheckLinesY:{lineWidth:2,strokeStyle:"#CED806"},SignLine1:{lineWidth:2,strokeStyle:"blue"},SignLine2:{lineWidth:2,strokeStyle:"green"}},zo={font:"14px Microsoft YaHei",fillStyle:"#FFFFFF",strokeStyle:"#FFFFFF",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},Lo={radius:10,lineWidth:2,strokeStyle:"rgba(255,255,255,0.4)",fillStyle:"rgba(255,255,255,0.1)"},Mo={txt:"rgba(255,255,255,1)",strokeStyle:"rgba(255,255,255,1)",lineWidth:1},Ro={style1:{Wall:{strokeStyle:"#666666",lineWidth:4,lineWidth_out:6,important:{strokeStyle:"#666666",lineWidth:6}},Symbol:{strokeStyle:"#666666",lineWidth:1},Component:{strokeStyle:"#666666",fillStyle:"#666666",lineWidth:1},Tag:{strokeStyle:"#000000",fillStyle:"#000000",lineWidth:1},Font:{font:"14px Microsoft YaHei",fillStyle:"#000000",strokeStyle:"#000000",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},Measure:{strokeStyle:"#CCCCCC",lineWidth:1},Furniture:{strokeStyle:"#666666",fillStyle:"#666666"}},style2:{Wall:{strokeStyle:"#FFFFFF",lineWidth:4,lineWidth_out:6,important:{strokeStyle:"#FFFFFF",lineWidth:6}},Symbol:{strokeStyle:"#FFFFFF",lineWidth:1},Component:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF",lineWidth:1},Tag:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF",lineWidth:1},Font:{font:"14px Microsoft YaHei",fillStyle:"#FFFFFF",strokeStyle:"#FFFFFF",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},Measure:{strokeStyle:"#FFFFFF",lineWidth:1},Furniture:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF"}},style3:{Wall:{strokeStyle:"#666666",lineWidth:4,lineWidth_out:6,important:{strokeStyle:"#666666",lineWidth:6}},Symbol:{strokeStyle:"#666666",lineWidth:1},Component:{strokeStyle:"#666666",fillStyle:"#666666",lineWidth:1},Tag:{strokeStyle:"#000000",fillStyle:"#000000",strokeStyle_adding:"rgba(243, 255, 0, 0.8)",fillStyle_adding:"rgba(243, 255, 0, 0.8)",lineWidth:1},Font:{font:"14px Microsoft YaHei",fillStyle:"#000000",strokeStyle:"#000000",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},Measure:{strokeStyle:"#CCCCCC",lineWidth:2},Furniture:{strokeStyle:"#666666",fillStyle:"#666666"}},style4:{Wall:{strokeStyle:"#FFFFFF",lineWidth:4,lineWidth_out:6,important:{strokeStyle:"#FFFFFF",lineWidth:6}},Symbol:{strokeStyle:"#FFFFFF",lineWidth:1},Component:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF",lineWidth:1},Tag:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF",lineWidth:1},Font:{font:"14px Microsoft YaHei",fillStyle:"#FFFFFF",strokeStyle:"#FFFFFF",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},Measure:{strokeStyle:"#FFFFFF",lineWidth:1},Furniture:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF"}}},Oo=function(){this.whiteImg=null,this.blackImg=null};Oo.prototype.setWhiteImg=function(t){this.whiteImg=t},Oo.prototype.setBlackImg=function(t){this.blackImg=t},Oo.prototype.getWhiteImg=function(){return this.whiteImg},Oo.prototype.getBlackImg=function(){return this.blackImg};var Ao=new Oo,Eo=function(){this.context=null};Eo.prototype.initContext=function(t){this.context=t?t.getContext("2d"):null},Eo.prototype.clear=function(){this.context.clearRect(0,0,this.context.canvas.width,this.context.canvas.height)},Eo.prototype.drawBackGround=function(t){this.context.save(),this.context.fillStyle=t,this.context.fillRect(0,0,this.context.canvas.width,this.context.canvas.height),this.context.restore()},Eo.prototype.drawWall=function(t,e){var o=he.getPoint(t.start),i=he.getPoint(t.end),n=[];n.push(o);for(var s=0;sthis.context.measureText(P).width?(this.context.beginPath(),this.context.moveTo(r.x,r.y),this.context.lineTo(v.x,v.y),this.context.stroke(),this.context.beginPath(),this.context.moveTo(S.x,S.y),this.context.lineTo(l.x,l.y),this.context.stroke(),this.context.save(),le.ratio==a.ratio?this.context.font="36px Microsoft YaHei":this.context.font="12px Microsoft YaHei","style-1"==o||"style-3"==o?(this.context.fillStyle="#000000",this.context.strokeStyle="#000000"):(this.context.fillStyle="#FFFFFF",this.context.strokeStyle="#FFFFFF"),this.context.textAlign="center",this.context.textBaseline="middle",this.context.miterLimit=10,this.context.direction="ltr",h?(this.context.translate(f.x,f.y),this.context.rotate(h),this.context.fillText(P,0,0)):this.context.fillText(P,f.x,f.y),this.context.restore()):(this.context.beginPath(),this.context.moveTo(r.x,r.y),this.context.lineTo(l.x,l.y),this.context.stroke())}else{var b=c.getDistance(t[s],t[s+1]);b="ft"==de.unit?" "+me.convert(b,"distance",void 0,"imperial",.01,!0)+" ":c.getFixed(b,2)+"m",c.getDistance(r,l)>this.context.measureText(b).width?(this.context.beginPath(),this.context.moveTo(r.x,r.y),this.context.lineTo(S.x,S.y),this.context.stroke(),this.context.beginPath(),this.context.moveTo(v.x,v.y),this.context.lineTo(l.x,l.y),this.context.stroke(),this.context.save(),le.ratio==a.ratio?this.context.font="36px Microsoft YaHei":this.context.font="12px Microsoft YaHei","style-1"==o||"style-3"==o?(this.context.fillStyle="#000000",this.context.strokeStyle="#000000"):(this.context.fillStyle="#FFFFFF",this.context.strokeStyle="#FFFFFF"),this.context.textAlign="center",this.context.textBaseline="middle",this.context.miterLimit=10,this.context.direction="ltr",h?(this.context.translate(f.x,f.y),this.context.rotate(h),this.context.fillText(b,0,0)):this.context.fillText(b,f.x,f.y),this.context.restore()):(this.context.beginPath(),this.context.moveTo(r.x,r.y),this.context.lineTo(l.x,l.y),this.context.stroke())}}}this.context.restore()},Eo.prototype.drawMeasureTxt=function(t,e){var o=le.getScreenXY(t),i=le.getScreenXY(e),n=c.createLine1(o,i);if(null!=n){var s={x:(o.x+i.x)/2,y:(o.y+i.y)/2},r=c.getParallelLineForDistance(n,10),l=null,a=c.getJoinLinePoint(s,r.line1),h=c.getJoinLinePoint(s,r.line2);s.yg.x?c.clonePoint(s,g):x.y0&&(s=r[0].side?this.updateCenterForComponentFurniture2(r[0].vectorId,r[0].type,r[0].side,s):this.updateCenterForComponentFurniture(r[0].vectorId,r[0].type,r[0].sideIndex,r[0].selfSideIndex,s,n,r[0].distance),xt.isComponent(o)?n=xt.getBoundingVertexs(e,s):Qt.isFurniture(o)&&(n=i.getBoundingVertexs(s)),r.length>1&&(s=r[1].side?this.updateCenterForComponentFurniture2(r[1].vectorId,r[1].type,r[1].side,s):this.updateCenterForComponentFurniture(r[1].vectorId,r[1].type,r[1].sideIndex,r[1].selfSideIndex,s,n,r[1].distance))),r.length<2){var l=this.getNearWalls(n);l.length>0&&(s=this.updateCenterForWall(l[0].vectorId,l[0].selfSideIndex,s,n,l[0].distance),xt.isComponent(o)?n=xt.getBoundingVertexs(e,s):Qt.isFurniture(o)&&(n=i.getBoundingVertexs(s)),0==r.length&&l.length>1&&(s=this.updateCenterForWall(l[1].vectorId,l[1].selfSideIndex,s,n,l[1].distance)))}return s.x=c.getFixed(s.x),s.y=c.getFixed(s.y),c.clonePoint(i.center,s),xt.isComponent(o)&&i.setPoints2d(),null},_o.prototype.isInScreen=function(t){return t.x>this.screenPoints[0].x&&t.xthis.screenPoints[3].y},_o.prototype.getNearWalls=function(t){var e=[],o=c.createLine1(t[0],t[1]),i=c.createLine1(t[1],t[2]),n=c.createLine1(t[2],t[3]),s=c.createLine1(t[3],t[0]),r=he.getWalls(),l=null,h=null,u=null,d=null,p=null,x=null;for(var g in r){var f=r[g],m=null;m=f.out?bo.lineWidth_out/le.res/2*a.defaultZoom/le.zoom:bo.lineWidth/le.res/2*a.defaultZoom/le.zoom;var v=he.getPoint(f.start),S=he.getPoint(f.end),P=c.createLine1(v,S),b=null,I=null,k=null,T=null;if(this.isParallel(o,P)&&this.isCloseForTwoSegments(t[0],t[1],v,S)?(b=c.getDisForPoinLine(t[0],P),b-=m,I=[0,1],this.isAdsorb(b)||(b=null,I=null)):this.isParallel(i,P)&&this.isCloseForTwoSegments(t[1],t[2],v,S)&&(k=c.getDisForPoinLine(t[1],P),k-=m,T=[1,2],this.isAdsorb(k)||(k=null,T=null)),this.isParallel(n,P)&&this.isCloseForTwoSegments(t[2],t[3],v,S)){var F=c.getDisForPoinLine(t[2],P);F-=m,this.isAdsorb(F)&&(null==b||Fb)&&(l=b,h=I,u=g):null!=k&&(null==d||d>k)&&(d=k,p=T,x=g))}return null!=l&&e.push({vectorId:u,type:y,distance:l,selfSideIndex:h}),null!=d&&e.push({vectorId:x,type:y,distance:d,selfSideIndex:p}),e},_o.prototype.getNearComponentsFurnitures=function(t,e){var o=c.createLine1(e[0],e[1]),i=c.createLine1(e[1],e[2]),n=[],s=he.getComponents(),r=he.getFurnitures(),l=(e[0].x+e[1].x+e[2].x+e[3].x)/4,a=(e[0].y+e[1].y+e[2].y+e[3].y)/4,h=null,u=null,d=null,y=null,p=null,x=null,g=null,f=null,m=null,v=null,S=null,P=null,b=null,I=null,k=null,T=null;for(var F in s)if(F!=t){var w=s[F];if(this.isInScreen(w.center)){var C=c.createLine1(w.points2d[0],w.points2d[1]),W=c.createLine1(w.points2d[1],w.points2d[2]),D=c.createLine1(w.points2d[2],w.points2d[3]),z=c.createLine1(w.points2d[3],w.points2d[0]),L=null,M=null,R=null,O=null;if(this.isParallel(o,C)&&this.isCloseForTwoSegments(e[0],e[1],w.points2d[0],w.points2d[1])){L=c.getDisForPoinLine(e[0],C),M=c.getDisForPoinLine(e[0],D),R=c.getDisForPoinLine(e[3],C),O=c.getDisForPoinLine(e[3],D);var A=Math.min(L,M,R,O);this.isAdsorb(A)&&(null==y||y>A)&&(A==L?(h=F,p=w.geoType,u=[0,1],d=[0,1],y=A):A==M?(h=F,p=w.geoType,u=[2,3],d=[0,1],y=A):A==R?(h=F,p=w.geoType,u=[0,1],d=[2,3],y=A):A==O&&(h=F,p=w.geoType,u=[2,3],d=[2,3],y=A))}if(this.isParallel(i,W)&&this.isCloseForTwoSegments(e[1],e[2],w.points2d[1],w.points2d[2])){L=c.getDisForPoinLine(e[1],W),M=c.getDisForPoinLine(e[1],z),R=c.getDisForPoinLine(e[0],W),O=c.getDisForPoinLine(e[0],z);var E=Math.min(L,M,R,O);this.isAdsorb(E)&&(null==m||m>E)&&(E==L?(x=F,v=w.geoType,g=[1,2],f=[1,2],m=E):E==M?(x=F,v=w.geoType,g=[0,3],f=[1,2],m=E):E==R?(x=F,v=w.geoType,g=[1,2],f=[0,3],m=E):E==O&&(x=F,v=w.geoType,g=[0,3],f=[0,3],m=E))}this.isAdsorb(Math.abs(w.center.x-l))&&(null==P||P>Math.abs(w.center.x-l))&&(S=F,b=w.geoType,P=Math.abs(w.center.x-l)),this.isAdsorb(Math.abs(w.center.y-a))&&(null==k||k>Math.abs(w.center.y-a))&&(I=F,T=w.geoType,k=Math.abs(w.center.y-a))}}for(var B in r)if(B!=t){var _=r[B];if(this.isInScreen(_.center)){_.points2d=_.getBoundingVertexs(_.center);var Y=c.createLine1(_.points2d[0],_.points2d[1]),N=c.createLine1(_.points2d[1],_.points2d[2]),X=c.createLine1(_.points2d[2],_.points2d[3]),j=c.createLine1(_.points2d[3],_.points2d[0]),U=null,J=null,V=null,H=null;if(this.isParallel(o,Y)&&this.isCloseForTwoSegments(e[0],e[1],_.points2d[0],_.points2d[1])){U=c.getDisForPoinLine(e[0],Y),J=c.getDisForPoinLine(e[0],X),V=c.getDisForPoinLine(e[3],Y),H=c.getDisForPoinLine(e[3],X);var $=Math.min(U,J,V,H);this.isAdsorb($)&&(null==y||y>$)&&($==U?(h=B,p=_.geoType,u=[0,1],d=[0,1],y=$):$==J?(h=B,p=_.geoType,u=[2,3],d=[0,1],y=$):$==V?(h=B,p=_.geoType,u=[0,1],d=[2,3],y=$):$==H&&(h=B,p=_.geoType,u=[2,3],d=[2,3],y=$))}if(this.isParallel(i,N)&&this.isCloseForTwoSegments(e[1],e[2],_.points2d[1],_.points2d[2])){U=c.getDisForPoinLine(e[1],N),J=c.getDisForPoinLine(e[1],j),V=c.getDisForPoinLine(e[0],N),H=c.getDisForPoinLine(e[0],j);var Z=Math.min(U,J,V,H);this.isAdsorb(Z)&&(null==m||m>Z)&&(Z==U?(x=B,v=_.geoType,g=[1,2],f=[1,2],m=Z):Z==J?(x=B,v=_.geoType,g=[0,3],f=[1,2],m=Z):Z==V?(x=B,v=_.geoType,g=[1,2],f=[0,3],m=Z):Z==H&&(x=B,v=_.geoType,g=[0,3],f=[0,3],m=Z))}this.isAdsorb(Math.abs(_.center.x-l))&&(null==P||P>Math.abs(_.center.x-l))&&(S=B,b=_.geoType,P=Math.abs(_.center.x-l)),this.isAdsorb(Math.abs(_.center.y-a))&&(null==k||k>Math.abs(_.center.y-a))&&(I=B,T=_.geoType,k=Math.abs(_.center.y-a))}}return null!=y&&(o.hasOwnProperty("x")&&null!=P?(y>=P&&(n.push({vectorId:S,type:b,distance:P,side:"x"}),y=null),P=null):o.hasOwnProperty("y")&&null!=k&&(y>=k&&(n.push({vectorId:I,type:T,distance:k,side:"y"}),y=null),k=null),null!=y&&n.push({vectorId:h,type:p,distance:y,sideIndex:u,selfSideIndex:d})),null!=m&&(i.hasOwnProperty("x")&&null!=P?(m>=P&&(n.push({vectorId:S,type:b,distance:P,side:"x"}),m=null),P=null):i.hasOwnProperty("y")&&null!=k&&(m>=k&&(n.push({vectorId:I,type:T,distance:k,side:"y"}),m=null),k=null),null!=m&&n.push({vectorId:x,type:v,distance:m,sideIndex:g,selfSideIndex:f})),0==n.length?(null!=P&&n.push({vectorId:S,type:b,distance:P,side:"x"}),null!=k&&n.push({vectorId:I,type:T,distance:k,side:"y"})):1==n.length&&(null!=P?n.push({vectorId:S,type:b,distance:P,side:"x"}):null!=k&&n.push({vectorId:I,type:T,distance:k,side:"y"})),n},_o.prototype.isAdsorb=function(t){return t0){var l=Object.keys(this.adsorbPointWalls)[0],h=he.getWall(this.adsorbPointWalls[l]).getOtherPointId(t),u=he.getPoint(h),d=he.getPoint(l),y=c.createLine1(u,d);e=c.getJoinLinePoint(e,y),i.setPosition(e)}return!1}var p=null;if(null==o){var x=ct.getNeighPoints(t);if(1==x.length?p=Be.checkAngle(e,x[0].vectorId,t):2==x.length&&((p=Be.checkAngle(e,x[0].vectorId,t))||(p=Be.checkAngle(e,x[1].vectorId,t))),p){if(!(r=this.canMoveForPoint(t,p,n,s)))return!1;c.clonePoint(e,p)}i.setPosition(e)}else if(o.hasOwnProperty("linkedPointId")&&null!=o.linkedPointId){if(null!=ct.getWallId(t,o.linkedPointId))return!1;i.setPosition(o),this.needUpdateRoom=!0}else if(o.hasOwnProperty("linkedWallId")){var g=he.getWall(o.linkedWallId),f=he.getPoint(g.start),m=he.getPoint(g.end);if(c.getDistance(f,e)1&&1==Object.keys(h.parent).length||1==Object.keys(l.parent).length&&1==Object.keys(h.parent).length?ct.moveTo(r,s):1==Object.keys(l.parent).length&&Object.keys(h.parent).length>1&&ct.moveTo(s,r),this.moveFlag=!1,i=3,this.needUpdateRoom=!0,i):(this.moveFlag=!1,i=3,this.needUpdateRoom=!0,i);if(s=n.start,r=n.end,!this.isOKForCrossForMoveWall(p,x,t,s,r,g.adsorbPointId,f.adsorbPointId))return i=2,this.moveFlag=!1,this.setStartMoving(!1),i;if(m||null!=v&&va.maxAngle/180*Math.PI&&(o=c.getVerticalLine(h,r),u.startWallId=null,u.newStartWallId=!0)}else{var p,x;n=ct.wallIdForMinAngle(s.start,t);var g=he.getWall(n.min0.wallId),f=he.getPoint(g.start),m=he.getPoint(g.end),v=he.getWall(n.min1.wallId),S=he.getPoint(v.start),P=he.getPoint(v.end),b=c.getIntersectionPoint4(f,m,e),I=c.getIntersectionPoint4(S,P,e);if(null==b&&null==I){var k=ct.AngleForWall(t,n.min0.wallId),T=ct.AngleForWall(t,n.min1.wallId);k>Math.PI&&(k=Math.PI-k),T>Math.PI&&(T=Math.PI-T),x=ka.maxAngle/180*Math.PI||!c.isPointOnSegment(w,C,W))&&(o=c.getVerticalLine(h,r),u.startWallId=null,u.newStartWallId=!0)}if(1==Object.keys(l.parent).length)i=c.getVerticalLine(h,l),u.endWallId=null;else if(2==Object.keys(l.parent).length){var D;Object.keys(l.parent)[0]==t?D=he.getWall(Object.keys(l.parent)[1]):Object.keys(l.parent)[1]==t&&(D=he.getWall(Object.keys(l.parent)[0]));var z=ct.AngleForWall(D.vectorId,t);i=ct.getLine(D),u.endWallId=D.vectorId,z>a.maxAngle/180*Math.PI&&(i=c.getVerticalLine(h,l),u.endWallId=null,u.newEndWallId=!0)}else{var L,M;n=ct.wallIdForMinAngle(s.end,t);var R=he.getWall(n.min0.wallId),O=he.getPoint(R.start),A=he.getPoint(R.end),E=he.getWall(n.min1.wallId),B=he.getPoint(E.start),_=he.getPoint(E.end),Y=c.getIntersectionPoint4(O,A,e),N=c.getIntersectionPoint4(B,_,e);if(null==Y&&null==N){var X=ct.AngleForWall(t,n.min0.wallId),j=ct.AngleForWall(t,n.min1.wallId);X>Math.PI&&(X=Math.PI-X),j>Math.PI&&(j=Math.PI-j),M=Xa.maxAngle/180*Math.PI||!c.isPointOnSegment(J,V,H))&&(i=c.getVerticalLine(h,l),u.endWallId=null,u.newEndWallId=!0)}return u.startLimitLine=o,u.endLimitLine=i,u},jo.prototype.canMoveForPoint=function(t,e,o,i){var n=he.getPoint(t),s=this.isOKForMinAngleWall(t,e);return s&&(s=this.isOKForCross(t,e,n.parent,o,i)),s},jo.prototype.isOKForMinAngleWall=function(t,e){var o=he.getPoint(t).parent,i=this.getMinAngle(t,e);if(Math.abs(i)Math.PI){var b=2*Math.PI+S-P;bu)&&(a={angle:l=u,pointId:s})}return a},jo.prototype.isOKForCross=function(t,e,o,i,n){var s=he.getWalls();for(var r in s)if(!o.hasOwnProperty(r)&&n!=r)for(var l in o)if(!ct.isWallLink(r,l)){var a=he.getWall(l),h=a.getOtherPointId(t),c=he.getPoint(h);if(!this.isOKForCrossTwoWall(e,c,r,i,n,a.vectorId))return this.adsorbPointWalls={},!1}return!(Object.keys(this.adsorbPointWalls).length>0)&&null==this.splitWallId},jo.prototype.isOKForCrossTwoWall=function(t,e,o,i,n,s){var r=he.getWall(o),l=he.getPoint(r.start),h=he.getPoint(r.end);if(c.getIntersectionPoint3(t,e,l,h)&&r.start!=i&&r.end!=i)return this.splitWallId=o,!0;if(c.equalPoint(t,e))return!0;var u=c.createLine1(t,e),d=c.getJoinLinePoint(l,u),y=c.getJoinLinePoint(h,u);if(c.getDistance(d,l)a.maxAngle/180*Math.PI)s.setPosition(o.virtualPosition);else{var c=ct.getDirction(e,t);ct.subtraWallFromIntersect(e,t);var u=r.getPointId(c);he.getPoint(u).setPosition(o.virtualPosition),ct.splitWall(i,u,c),this.needUpdateRoom=!0}}},jo.prototype.createWallForMoveWall=function(t,e,o){var i=he.getWall(e),n=ct.getDirction(t,e);ct.subtraWallFromIntersect(t,e);var s=i.getPointId(n);he.getPoint(s).setPosition(o),ct.createWall(t,s)},jo.prototype.deleteWallForLinked=function(t){var e=he.getWall(t);ct.subtraWallFromIntersect(e.start,t),ct.subtraWallFromIntersect(e.end,t),he.deleteWall(t)};var Uo=new jo,Jo=function(t){this.layer=t,this.displayPanos=!1};Jo.prototype.drawGeometry=function(t,e,o){if(null!=Bo.context){switch(t.geoType){case y:return void Bo.drawWall(t,e);case u:return void Bo.drawPoint(t);case p:return void Bo.drawSingleDoor(t,e,o);case x:return void Bo.drawDoubleDoor(t,e,o);case g:return void Bo.drawSlideDoor(t,e,o);case f:return void Bo.drawSingleWindow(t,e);case v:return void Bo.drawFrenchWindow(t,e);case m:return void Bo.drawBayWindow(t,e);case S:return void Bo.drawPass(t,e);case P:return void Bo.drawBeam(t,e);case b:return void Bo.drawFlue(t,e);case I:return void Bo.drawCorridor(t,e);case T:return void Bo.drawTag(t,e,o)}Qt.isFurniture(t.geoType)&&Bo.drawFurniture(t,e)}},Jo.prototype.drawElement=function(t){if(null!=Bo.context)switch(t.geoType){case u:Bo.drawCircle(t);break;case k:Bo.drawLine(t)}},Jo.prototype.drawPanos=function(t){for(var e=0;e0?(this.layer.$xui.toolbar.clear=!0,this.layer.$xui.toolbar.download=!0):(this.layer.$xui.toolbar.clear=!1,this.layer.$xui.toolbar.download=!1)},xi.prototype.save=function(){if(pi.operate()){de.update(!1),Ye.addHistoryRecord(pi.elements),pi.saveCurrentInfo(),this.setState(),Ye.getHistoryState().pre&&(this.layer.$xui.toolbar.recall=!0),this.layer.$xui.toolbar.recover=!1;var t=he.getPoints();return Object.keys(t).length>0?(this.layer.$xui.toolbar.clear=!0,this.layer.$xui.toolbar.download=!0):(this.layer.$xui.toolbar.clear=!1,this.layer.$xui.toolbar.download=!1),this.layer.emit("change"),pi.elements}},xi.prototype.setState=function(){var t={pre:0,next:0},e=Ye.getCurrentRecordIndex(),o=Ye.getHistoryRecords();e>-1&&(t.pre=1),e0?(this.layer.$xui.toolbar.clear=!0,this.layer.$xui.toolbar.download=!0):(this.layer.$xui.toolbar.clear=!1,this.layer.$xui.toolbar.download=!1)}else console.error("goPreState超出范围!")},xi.prototype.goPreForPoints=function(t){for(var e=0;e0?(this.layer.$xui.toolbar.clear=!0,this.layer.$xui.toolbar.download=!0):(this.layer.$xui.toolbar.clear=!1,this.layer.$xui.toolbar.download=!1)}else Ye.undoHistoryRecord(),console.error("goNextState超出范围!")};var gi={export:{Wall:{strokeStyle:"#70707a",fillStyle:"#70707a",lineWidth:7,lineWidth_out:10},Symbol:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1},Component:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1},Font:[{font:"bold 14px Microsoft YaHei",fillStyle:"rgb(65,65,65)",screen:{x:520,y:856},text:"© "},{font:"bold 14px Microsoft YaHei",fillStyle:"#70707a",screen:{x:538,y:855},text:"版权归58同城、赶集网、安居客、四维时代、正顺所有"},{font:"bold 14px Microsoft YaHei",fillStyle:"rgb(65,65,65)",screen:{x:30,y:840},text:["单位:毫米(mm)","提示:户型图中所有室内装饰、设计、摆设、间隔、尺寸、设备仅供参考。","具体房源标准以室内查勘和测量为准。"]}],compass:{screen:{x:66,y:88}},BackGround:{fillStyle:"#FFFFFF"}},cover:{Wall:{strokeStyle:"#70707a",fillStyle:"#70707a"},Symbol:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1},Component:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1}},default:{Wall:{strokeStyle:"#70707a",fillStyle:"#70707a"},Symbol:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1},Component:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1}},Font:{font:"12px Microsoft YaHei",fillStyle:"rgba(0,0,0,1)",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},Measure:{strokeStyle:"#70707a"}},fi=function(){this.context=null};fi.prototype.initContext=function(t){this.context=t},fi.prototype.clear=function(){this.context.clearRect(0,0,this.context.canvas.width,this.context.canvas.height)},fi.prototype.drawWall=function(t,e){var o=he.getPoint(t.start),i=he.getPoint(t.end),n=[];n.push(o);for(var s=0;s-1?mi.drawRoomBackGround(t.pointIds,this.imgCache.room1):this.roomInfo2.indexOf(t.name)>-1?mi.drawRoomBackGround(t.pointIds,this.imgCache.room2):(this.roomInfo3.indexOf(t.name),mi.drawRoomBackGround(t.pointIds,this.imgCache.room3)),"export"==this.type&&t.name&&(mi.drawText(t.center,t.name,!1,0),null!=t.area&&""!=t.area.trim()&&mi.drawText({x:t.center.x,y:t.center.y-16/le.res},t.area+"m²",!1,0))};var Si=new vi,Pi=function(t,e){this.app=t.app,this.layer=t,Si.layer=t,this.ajkJson={},this.cameraJson={},this.floorPlanJson={},this.getCameraJson(e),this.loadImg()};Pi.prototype.loadImg=function(){this.app.store.getAppImage("images/ajk/cad_compass_ajk.png").then((function(t){Si.imgCache.compass=t})),this.app.store.getAppImage("images/ajk/room1_ajk.png").then((function(t){Si.imgCache.room1=t})),this.app.store.getAppImage("images/ajk/room2_ajk.png").then((function(t){Si.imgCache.room2=t})),this.app.store.getAppImage("images/ajk/room3_ajk.png").then((function(t){Si.imgCache.room3=t})),Si.roomInfo1=["书房","厨房","卫生间","多功能室","阳台","储物间","步入式衣柜","外景","露台(无顶)","影视间","入房花园"],Si.roomInfo2=["主卧","儿童房","次卧","客卧","老人房","卧室"],Si.roomInfo3=["整套","客厅","走廊","餐厅","起居室","客餐厅","玄关","门厅"]},Pi.prototype.start=function(){var t=this;return new Promise((function(e,o){ho.start(),t.getFloorPlanJson().then((function(i){t.floor=i,he.updateBoundingBox(),Si.init();var n=he.getTags();if(0!=Object.keys(n).length)if(s=t.getAJKRooms(n)){var s=t.getEntrance();s?(t.getSceneName(),t.getPictureRotate(),t.getImgInfo(),t.layer.renderer.clear(),Si.start(),e({ajkJson:t.ajkJson,cameraJson:t.cameraJson,floorPlanJson:{floors:[t.floor.floors[0]]},files:{bgmgdCZp_anjuke:Si.anjuke,bgmgdCZp_anjuke_cover:Si.anjuke_cover,bgmgdCZp_anjuke_export:Si.anjuke_export}})):o({type:"toast",msg:"平面图至少包含要给入户门,且入户门应为单开门"})}else o({type:"toast",msg:"标注应包含房间名称、面积"});else o({type:"toast",msg:"平面图应至少包含一个标注"})}))}))},Pi.prototype.getAJKRooms=function(t){Si.rooms=[];var e=he.getRooms();this.ajkJson.rooms=this.createAjkRoomForTag(t);for(var o=[],i=0;i-1))if(e[s].containPoint(this.ajkJson.rooms[i].labelPos)){o.push(s),console.log("匹配:"+this.ajkJson.rooms[i].name+"&"+e[s].tagName),Si.rooms.push({center:JSON.parse(JSON.stringify(this.ajkJson.rooms[i].labelPos)),pointIds:JSON.parse(JSON.stringify(e[s].wallPointIDs)),name:this.ajkJson.rooms[i].name,area:this.ajkJson.rooms[i].area});break}}n==Si.rooms.length&&(this.ajkJson.rooms.splice(i,1),--i)}return this.setRoomsGroup(),!0},Pi.prototype.getCameraJson=function(t){this.cameraJson={},this.cameraJson.sweepLocations=[];for(var e=0;eMath.PI/2&&(l.add(c.clone().multiplyScalar(s.distanceTo(r))),c.multiplyScalar(-1)),l.add(c.clone().multiplyScalar(-.5));var u={Position:new THREE.Vector3(l.x,-l.z,l.y),Direction:new THREE.Vector3(c.x,-c.z,c.y)};return this.ajkJson.Entrance=u,!0}return!1},Pi.prototype.getSceneName=function(){var t=this.app.store.getValue("metadata");this.ajkJson.scene_name=t.title},Pi.prototype.getPictureRotate=function(){var t=he.getAngle(),e=new THREE.Euler(0,t,0),o=new THREE.Vector3(0,0,-1);o.applyEuler(e),o=new THREE.Vector3(o.x,-o.z,o.y),this.ajkJson.picture_rotate=o},Pi.prototype.getFootPoint=function(t,e,o,i){var n=t.clone().sub(e),s=e.clone().sub(o),r=s.length(),l=n.dot(s)/r,a=e.clone().add(s.multiplyScalar(l/r));return i&&a.clone().sub(e).dot(a.clone().sub(o))>0&&(a=a.distanceTo(e)1&&(ee.clearEventName(),uo.clear(),this.uiControl.clearUI(),Be.hideAll())}break;case Je:if(null!=s&&s.type==y){var h=he.getWall(s.vectorId);h.import||h.out?this.uiControl.currentUI="OutWall":this.uiControl.currentUI=s.type,this.history.save()}else this.history.save();Uo.setStartMoving(!1);break;case He:if(null==n)return void this.setEventName("mouseUp");s={vectorId:n.vectorId,type:n.type,cursor:{x:this.lastX,y:this.lastY}},ee.setFocusItem(s),this.uiControl.showAttributes(),this.uiControl.currentUI=s.type,this.history.save();break;case $e:r=he.getSymbol(n.vectorId),null!=s&&se.isSymbol(s.type)?(this.uiControl.currentUI=s.type,this.history.save()):r&&(r.len=null,this.history.save());break;case Ze:null!=s&&se.isSymbol(s.type)?(this.uiControl.currentUI=s.type,this.history.save()):this.history.save();break;case Ge:Be.hideSignLine1(),Be.hideSignLine2(),Yo.clear(),s={vectorId:n.vectorId,type:n.type,cursor:{x:this.lastX,y:this.lastY}},ee.setFocusItem(s),this.uiControl.showAttributes(),this.uiControl.currentUI=s.type,this.history.save();break;case Ke:Be.hideSignLine1(),Be.hideSignLine2(),Yo.clear(),null!=s&&xt.isComponent(s.type)?(this.uiControl.currentUI=s.type,this.history.save()):this.history.save(),Be.hideAll();break;case Qe:null!=s&&s.type==T?(this.uiControl.currentUI=s.type,this.history.save()):this.history.save();break;case qe:he.getTag(n.vectorId).setAdding(!1),s={vectorId:n.vectorId,type:n.type,cursor:{x:this.lastX,y:this.lastY}},ee.setFocusItem(s),this.history.save(),this.uiControl.currentUI=s.type;break;case to:Be.hideSignLine1(),Be.hideSignLine2(),Yo.clear(),s={vectorId:n.vectorId,type:n.type,cursor:{x:this.lastX,y:this.lastY}},ee.setFocusItem(s),this.uiControl.showAttributes(),this.uiControl.currentUI=s.type,this.history.save();break;case eo:Be.hideSignLine1(),Be.hideSignLine2(),Yo.clear(),null!=s&&Qt.isFurniture(s.type)?(this.uiControl.currentUI=s.type,this.history.save()):this.history.save()}this.setEventName("mouseUp"),ee.clearDraggingItem(),this.renderer.autoRedraw()}},e.prototype.onWheel=function(t){if(null!=le.defaultCenter){t.preventDefault();var e=t.type;if("DOMMouseScroll"==e||"mousewheel"==e){var o=t.wheelDelta?t.wheelDelta/120*20:-(t.detail||0)/3*20,i=le.zoom+o;if(i<14)return;le.updateZoom(i);var n=le.getScreenInfoForCAD();n.floorPlanAngle=he.getAngle(),this.app.core.get("CameraControls").emit("syncCadAnd3D",n),this.renderer.autoRedraw()}}},e.prototype.onKeydown=function(t){if(this.display)if(t.ctrlKey&&"KeyZ"==t.code){if(this.stopAddVector(),!this.$xui.toolbar.recall)return void this.renderer.autoRedraw();if("image"==this.app.store.getValue("flooruser").type)return void this.renderer.autoRedraw();this.revokeHistory(),console.log("ctrl+z")}else if(t.ctrlKey&&"KeyY"==t.code){if(!this.$xui.toolbar.recover)return;this.recoveryHistory(),console.log("ctrl+y")}else if("Delete"==t.code)this.deleteItem(),this.uiControl.currentUI=null,this.history.save(),this.renderer.autoRedraw(),console.log("Delete");else if("Escape"==t.code)this.stopAddVector(),this.renderer.autoRedraw(),console.log("Esc");else{var e=ee.getFocusItem(),o=ee.getDraggingItem();e&&!o&&t.ctrlKey&&"KeyC"==t.code&&(Ti.copy(e,this.mousePosition),this.renderer.autoRedraw(),this.history.save())}},e.prototype.updateEventNameForSelectUI=function(){if(Be.hideAll(),ee.getEventName()==qe){var t=ee.getDraggingItem();t&&t.type==T&&he.deleteTag(t.vectorId)}ee.clearItems(),this.uiControl.selectUI==ft||this.uiControl.selectUI==mt?ee.setEventName(je):this.uiControl.selectUI==vt||this.uiControl.selectUI==St||this.uiControl.selectUI==Pt||this.uiControl.selectUI==bt||this.uiControl.selectUI==It||this.uiControl.selectUI==kt||this.uiControl.selectUI==Tt?ee.setEventName(He):this.uiControl.selectUI==Ft||this.uiControl.selectUI==wt||this.uiControl.selectUI==Ct?ee.setEventName(Ge):this.uiControl.selectUI==Wt?ee.setEventName(qe):this.uiControl.selectUI!=Dt&&this.uiControl.selectUI!=zt&&this.uiControl.selectUI!=Lt&&this.uiControl.selectUI!=Mt&&this.uiControl.selectUI!=Rt&&this.uiControl.selectUI!=Ot&&this.uiControl.selectUI!=At&&this.uiControl.selectUI!=Et&&this.uiControl.selectUI!=Bt&&this.uiControl.selectUI!=_t&&this.uiControl.selectUI!=Yt&&this.uiControl.selectUI!=Nt&&this.uiControl.selectUI!=Xt&&this.uiControl.selectUI!=jt&&this.uiControl.selectUI!=Ut&&this.uiControl.selectUI!=Jt&&this.uiControl.selectUI!=Vt&&this.uiControl.selectUI!=Ht&&this.uiControl.selectUI!=$t&&this.uiControl.selectUI!=Zt&&this.uiControl.selectUI!=Gt||ee.setEventName(to)},e.prototype.setEventName=function(t){var e=ee.getEventName();if("mouseDown"==t)if(null==e){var o=ee.getSelectItem();if(null==o)ee.setEventName(Xe);else if(o.type==y)ee.setEventName(Je);else if(o.type==d)ee.setEventName(Ve);else if(se.isSymbol(o.type))if(o.selectIndex==H||o.selectIndex==G){ee.setEventName($e);var i=he.getSymbol(o.vectorId);i.len=c.getDistance(i.startPoint,i.endPoint)}else o.selectIndex!=$&&o.selectIndex!=Z||ee.setEventName(Ze);else xt.isComponent(o.type)?ee.setEventName(Ke):o.type==T?ee.setEventName(Qe):Qt.isFurniture(o.type)&&ee.setEventName(eo)}else e==je&&ee.setEventName(Ue);else"mouseUp"==t&&(e==qe||e!=je&&e!=Ue&&ee.clearEventName())},e.prototype.exit=function(){ee.clearItems(),ee.clearEventName(),this.uiControl.clearUI()},e.prototype.stopAddVector=function(){var t=ee.getEventName();if(t!=Ue){ee.clearEventName();var e=ee.getDraggingItem();t==He?e&&e.vectorId&&(se.deleteSymbol(e.vectorId),ee.clearDraggingItem()):t==Ge?e&&e.vectorId&&he.deleteComponent(e.vectorId):t==qe?e&&e.vectorId&&(Se.deleteTag(e.vectorId),this.uiControl.currentUI=null):t==to&&e&&e.vectorId&&he.deleteFurniture(e.vectorId)}else ee.setEventName(je);this.uiControl.clearUI(),Be.hideAll()},e.prototype.setNewWallPoint=function(t,e){return"select"!=Ae.symbolInfo.state&&(("start"==t||"end"==t)&&(Ae.modifyPoint?uo.setPointInfo(t,Ae.modifyPoint):uo.setPointInfo(t,le.getXYFromScreen(e)),!0))},e.prototype.reload=function(){var t=this;Ye.clearHistoryRecord(),this.$xui.toolbar.recall=!1,this.$xui.toolbar.recover=!1,he.clear(),le.clear(),ee.clearItems(),ee.clearEventName(),this.stopAddVector();var e=he.getCurrentFloor();return this.load.loadFloorJson(!0).then((function(){var o=t.app.store.getValue("flooruser");t.app.store.getValue("metadata").floorPlanAngle=o.angle||0,t.app.core.get("Player").model.floorplanCadImg.updateAllCadPlanes(),"image"==o.type?(t.initCoordinate(),t.player.model.floorplanCadImg.displayCadPlane(!0),t.player.model.floorplanCadImg.showCadPlane()):(t.app.core.get("Player").model.floorplanCadImg.hideCadPlane(),t.reRender()),he.setCurrentFloor(e),t.renderer.autoRedraw()}))},e.prototype.update=function(){var t=this;this.app.store.getValue("metadata").floorPlanUser=1,this.app.MinMap.reload().then((function(){"image"==t.app.store.getValue("flooruser").type?he.clear():(t.app.core.get("Player").model.floorplanCadImg.updateAllCadPlanes(),t.renderer.autoRedraw())})),this.div.style.visibility="visible"},e.prototype.exportImages=function(){this.div.style.visibility="hidden",this.stopAddVector();var t=he.getFloorData();return 0==Object.keys(t.points).length&&0==Object.keys(t.components).length&&0==Object.keys(t.tags).length&&0==Object.keys(t.furnitures).length?(this.div.style.visibility="visible",null):this.load.uploadCad()},e.prototype.exportJSON=function(t,e){if(e){var o=JSON.parse(JSON.stringify(l.floors));e.forEach((function(t,e){t.boundingBox=o[e].boundingBox}))}ho.start(),this.app.store.getValue("flooruser").cadInfo=t;var i=JSON.parse(JSON.stringify(e||l.floors));i.sort((function(t,e){return t.id-e.id}));var n={cadInfo:t,version:l.version,floors:i,unit:de.unit,angle:he.getAngle(),currentId:he.getCurrentId(),compass:he.getCompass()};return n.type=e?"image":"cad",n},e.prototype.exportHouseData=function(){return this.analyService.houseData},e.prototype.importJSON=function(){},o.isChanged.get=function(){return Ye.hasRecords()},o.isCurrentFloorEmpty.get=function(){return!1},e.prototype.revokeHistory=function(){this.history.goPreState(),this.renderer.autoRedraw(),Ye.getHistoryState().pre?this.$xui.toolbar.recall=!0:this.$xui.toolbar.recall=!1,this.$xui.toolbar.recover=!0},e.prototype.recoveryHistory=function(){this.history.goNextState(),this.renderer.autoRedraw(),Ye.getHistoryState().next?this.$xui.toolbar.recover=!0:this.$xui.toolbar.recover=!1,this.$xui.toolbar.recall=!0},e.prototype.deleteItem=function(){var t=ee.getFocusItem();t&&(t.type==y?he.deleteWall(t.vectorId):se.isSymbol(t.type)?se.deleteSymbol(t.vectorId):xt.isComponent(t.type)?he.deleteComponent(t.vectorId):t.type==T?he.deleteTag(t.vectorId):Qt.isFurniture(t.type)?he.deleteComponent(t.vectorId):t.type==d&&ct.deleteWallCorner(t.vectorId),this.history.save(),this.renderer.autoRedraw())},e.prototype.uploadCadImg=function(t,e,o,i){this.app.store.getValue("flooruser").type="image",this.player.model.floorplanCadImg.displayCadPlane(!0),this.uiControl.execute("clear",!0),this.uiControl.execute("panos",!1),this.uiControl.execute("texture",!0),this.$xui.toolbars.forEach((function(t){var e=t.list.find((function(t){return"viewSetting"==t.type}));e&&e.data.forEach((function(t){"panos"==t.type?t.checked=!1:"texture"==t.type&&(t.checked=!0)}))})),this.load.uploadCadImg(t,e,o,i)},e.prototype.deleteCadImg=function(t){this.player.model.floorplanCadImg.deleteCustomFloorTexture(t)},e.prototype.setCadImgVisible=function(t,e){this.player.model.floorplanCadImg.setCustomFloorVisible(t,e)},e.prototype.getBoundingBox2DPosition=function(t){return he.getBoundingBox2DPosition(this.player.model.floors.index[t].boundingBox)},e.prototype.recoverForCadImg=function(t,e){this.load.recoverForCadImg(t,e)},e.prototype.createSymbolFromPanorama=function(t,e,o){ee.clearEventName();var i=se.createSymbolFromPanorama(t,e,o);return this.history.save(),i},e.prototype.syncFloorplanAngel=function(t){var e=le.getScreenInfoForCAD();e.floorPlanAngle=null!=t?t:he.getAngle(),this.app.core.get("CameraControls").emit("syncCadAnd3DForRotate",e)},e.prototype.disable=function(){this.app.dom.querySelector("[xui_edit_cad]").style.pointerEvents="none"},e.prototype.enable=function(){this.app.dom.querySelector("[xui_edit_cad]").style.pointerEvents="all"},o.floors.get=function(){return l.floors},Object.defineProperties(e.prototype,o),e}(KanKan.MITT.Emiter);function wi(t){return{$template:"#kankan-xui-combox",expanded:!1,index:t.index||0,list:t.list||[],style:t.style||{},dropdown:function(){this.expanded=!this.expanded},selected:function(e){this.index!=e&&(this.index=e,t.change&&t.change(this.list[this.index]))}}}return document.querySelector("#kankan-xui-combox")||document.body.insertAdjacentHTML("beforeend",'
{{ metadata.title }}
  • 全部
  • {{item.name}}
\x3c!-- --\x3e \x3c!-- \n\n --\x3e '),function(t){var e=KanKan.Deferred();return t.Scene.on("loaded",(function(){var o=new Fi(t);o.$load=function(){PetiteVue.createApp({compassURL:t.resource.getAppURL("images/cad_compass.png"),show:!1,props:{},floors:t.store.getValue("flooruser").floors.map((function(t){return{value:t.subgroup,text:t.name}})),selectName:null,currentName:null,currentAttributes:{},currentFloor:0,currentUnit:"m",compassRate:0,type:"draw",toolbar:{recall:!1,recover:!1,clear:!1,default:!0,rotate:!0,download:!0,flex:!0,panos:!0,texture:!0,unit:!0},values:{panos:!0,texture:!0},list:[{name:"wall",list:[{icon:"sdk-neiqiang",name:"Wall",text:"内墙"},{icon:"sdk-waiqiang",name:"OutWall",text:"外墙"}]},{name:"door",list:[{icon:"sdk-men",name:"SingleDoor",text:"门"},{icon:"sdk-shuangkaimen",name:"DoubleDoor",text:"双开门"},{icon:"sdk-yimen",name:"SlideDoor",text:"移门"},{icon:"sdk-yakou",name:"Pass",text:"垭口"}]},{name:"window",list:[{icon:"sdk-chuang",name:"SingleWindow",text:"窗"},{icon:"sdk-piaochuang",name:"BayWindow",text:"飘窗"},{icon:"sdk-luodichuang",name:"FrenchWindow",text:"落地窗"}]},{name:"structure",list:[{icon:"sdk-zhuzi",name:"Beam",text:"柱子"},{icon:"sdk-yandao",name:"Flue",text:"烟道"},{icon:"sdk-loudao",name:"Corridor",text:"楼道"}]},{name:"tag",list:[{icon:"sdk-dange",name:"Tag",text:"标注"}]}],create:function(){o.$xui=this},hide:function(){o.hide()},showProps:function(t){"compass"==t&&(o.uiControl.showAttributes("compass"),this.compassRate=this.currentAttributes.compass),this.currentName=t;for(var e=null,i=0;i=360&&(console.log("超过了"),e=360,this.compassRate=0,this.currentAttributes.compass=360)),o.uiControl.setAttributes(this.props.name,t,e),-1!="split,default,remove".indexOf(t)&&this.hideProps()},$t:s,Combox:wi}).mount(t.dom.querySelector("[xui_design_cad]")),t.CadManager.install(o)},o.$html='
  • {{$t(\'cad.floor\')}}
  • \x3c!--
    \n
    绘制结构
    \n
    {{$t(\'cad.wall.s\')}}
    \n
    --\x3e
    {{$t(\'cad.classify.\'+cate.name)}}
  • {{$t(\'cad.items.\'+props.name)}}{{$t(\'cad.attribute\')}}
  • 翻转
    宽度  {{currentUnit}}
    入户门
    进入方向
  • 翻转
    宽度  {{currentUnit}}
  • 翻转角度    °
    宽度  {{currentUnit}}
    厚度  {{currentUnit}}
    高度  {{currentUnit}}
  • {{currentUnit == \'ft\'?\'ft² \':\'m²\'}}
  • 旋转角度
      °
  • \x3c!--
  • --\x3e
',o.$name="DesignCAD",e.resolve(o)})),e}}();