mxdraw 0.1.27 → 0.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),McGiWorldDrawType_1=require("../McGiWorldDrawType"),MxDbEntity_1=require("../MxDbEntity"),MxThreeJS_1=require("../MxThreeJS"),MxDbAlignedDimension=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.pt1=new THREE.Vector3,e.pt2=new THREE.Vector3,e}return __extends(e,t),e.prototype.getTypeName=function(){return"MxDbAlignedDimension"},e.prototype.getDirection=function(t,e,r){var n=new THREE.Vector3(t.x,t.y,0),o=new THREE.Vector3(1,0,0),a=t.angleTo(o),i=-1;(a<7*Math.PI/18||a>10*Math.PI/18)&&e.x>r.x&&(i=1);var p=new THREE.Matrix4;return p.makeRotationZ(Math.PI/2*i),n.applyMatrix4(p),n},e.prototype.worldDraw=function(t){if(t.getType()==McGiWorldDrawType_1.default.kWorldDraw||t.getType()==McGiWorldDrawType_1.default.kDynDragDraw){var e,r,n,o,a,i,p,y=this.pt1,c=this.pt2,x=new THREE.Vector3(y.x-c.x,y.y-c.y,0),E=this.getDirection(x,y,c),u=x.length(),l=new THREE.Matrix4;l.makeScale(.01,.01,.01),(d=new THREE.Vector3(E.x,E.y,0)).applyMatrix4(l);var w=new THREE.Vector3(y.x+d.x,y.y+d.y,0),T=new THREE.Vector3(c.x+d.x,c.y+d.y,0),s=16777215;i=MxThreeJS_1.default.createPoint(y,s),p=MxThreeJS_1.default.createPoint(c,s),l.identity(),l.makeScale(.2,.2,0),new THREE.Vector3(E.x,E.y,0).applyMatrix4(l),l.identity(),l.makeScale(.02,.02,0);var h=new THREE.Vector3(E.x,E.y,0);h.applyMatrix4(l),t.drawLine(w,T),e=MxThreeJS_1.default.createLine(new THREE.Vector3(w.x+2*h.x,w.y+2*h.y,0),new THREE.Vector3(y.x+h.x,y.y+h.y,0),s),r=MxThreeJS_1.default.createLine(new THREE.Vector3(T.x+2*h.x,T.y+2*h.y,0),new THREE.Vector3(c.x+h.x,c.y+h.y,0),s);var d,M=new THREE.Vector3(1,0,0),f=x.angleTo(M);(d=new THREE.Vector3(E.x,E.y,0)).normalize();var R=y.distanceTo(c);x.y<0?f=f<Math.PI/2?2*Math.PI-f:Math.PI-f:f>Math.PI/2&&(f=Math.PI+f),null!=(n=MxThreeJS_1.default.creatTextSprite(u.toFixed(3),new THREE.Vector3(T.x+x.x/2+d.x*R/30,T.y+x.y/2+d.y*R/30,0),.07*R,f,s))&&t.drawEntity(n),l.identity(),l.makeScale(.08,.08,.08);var H=new THREE.Matrix4;H.makeRotationZ(17*Math.PI/18);var _=new THREE.Vector3(x.x,x.y,0);_.applyMatrix4(l),_.applyMatrix4(H),H.identity(),H.makeRotationZ(17*-Math.PI/18);var V=new THREE.Vector3(x.x,x.y,0);V.applyMatrix4(l),V.applyMatrix4(H);var D=new Array;D.push(new THREE.Vector3(w.x,w.y,0),new THREE.Vector3(w.x+_.x,w.y+_.y,0),new THREE.Vector3(w.x+V.x,w.y+V.y,0)),o=MxThreeJS_1.default.createTriangle(D,s),H.identity(),H.makeRotationZ(Math.PI/18),(_=new THREE.Vector3(x.x,x.y,0)).applyMatrix4(l),_.applyMatrix4(H),H.identity(),H.makeRotationZ(-Math.PI/18),(V=new THREE.Vector3(x.x,x.y,0)).applyMatrix4(l),V.applyMatrix4(H);var v=new Array;v.push(new THREE.Vector3(T.x,T.y,0),new THREE.Vector3(T.x+_.x,T.y+_.y,0),new THREE.Vector3(T.x+V.x,T.y+V.y,0)),a=MxThreeJS_1.default.createTriangle(v,s),t.drawEntity(e),t.drawEntity(r),o&&t.drawEntity(o),a&&t.drawEntity(a),t.drawEntity(i),t.drawEntity(p)}else t.drawLine(this.pt1,this.pt2)},e.prototype.setPoint1=function(t){this.pt1=t},e.prototype.setPoint2=function(t){this.pt2=t},e.prototype.getGripPoints=function(){var t=[];return t.push(this.pt1),t.push(this.pt2),t},e.prototype.moveGripPointsAt=function(t,e){return 0==t?this.pt1.add(e):(t=1)&&this.pt2.add(e),!0},e.prototype.dwgIn=function(t){return this.onDwgIn(t),this.pt1.copy(t.pt1),this.pt2.copy(t.pt2),!0},e.prototype.dwgOut=function(t){return this.onDwgOut(t),t.pt1=this.pt1,t.pt2=this.pt2,t},e.prototype.create=function(){return new e},e}(MxDbEntity_1.default);exports.default=MxDbAlignedDimension;
1
+ "use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),McGiWorldDrawType_1=require("../McGiWorldDrawType"),MxDbEntity_1=require("../MxDbEntity"),MxThreeJS_1=require("../MxThreeJS"),MxDbAlignedDimension=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.point1=new THREE.Vector3,e.point2=new THREE.Vector3,e}return __extends(e,t),e.prototype.getTypeName=function(){return"MxDbAlignedDimension"},e.prototype.getDirection=function(t,e,r){var n=new THREE.Vector3(t.x,t.y,0),i=new THREE.Vector3(1,0,0),o=t.angleTo(i),a=-1;(o<7*Math.PI/18||o>10*Math.PI/18)&&e.x>r.x&&(a=1);var p=new THREE.Matrix4;return p.makeRotationZ(Math.PI/2*a),n.applyMatrix4(p),n},e.prototype.getDimText=function(){return new THREE.Vector3(this.point1.x-this.point2.x,this.point1.y-this.point2.y,0).length().toFixed(3)},e.prototype.worldDraw=function(t){if(t.getType()==McGiWorldDrawType_1.default.kWorldDraw||t.getType()==McGiWorldDrawType_1.default.kDynDragDraw){var e,r,n,i,o,a,p,y=this.point1,c=this.point2,x=new THREE.Vector3(y.x-c.x,y.y-c.y,0),E=this.getDirection(x,y,c),u=new THREE.Matrix4;u.makeScale(.01,.01,.01),(h=new THREE.Vector3(E.x,E.y,0)).applyMatrix4(u);var l=new THREE.Vector3(y.x+h.x,y.y+h.y,0),w=new THREE.Vector3(c.x+h.x,c.y+h.y,0),s=16777215;a=MxThreeJS_1.default.createPoint(y,s),p=MxThreeJS_1.default.createPoint(c,s),u.identity(),u.makeScale(.2,.2,0),new THREE.Vector3(E.x,E.y,0).applyMatrix4(u),u.identity(),u.makeScale(.02,.02,0);var T=new THREE.Vector3(E.x,E.y,0);T.applyMatrix4(u),t.drawLine(l,w),e=MxThreeJS_1.default.createLine(new THREE.Vector3(l.x+2*T.x,l.y+2*T.y,0),new THREE.Vector3(y.x+T.x,y.y+T.y,0),s),r=MxThreeJS_1.default.createLine(new THREE.Vector3(w.x+2*T.x,w.y+2*T.y,0),new THREE.Vector3(c.x+T.x,c.y+T.y,0),s);var h,d=new THREE.Vector3(1,0,0),M=x.angleTo(d);(h=new THREE.Vector3(E.x,E.y,0)).normalize();var f=y.distanceTo(c);x.y<0?M=M<Math.PI/2?2*Math.PI-M:Math.PI-M:M>Math.PI/2&&(M=Math.PI+M);var R=this.getDimText();null!=(n=MxThreeJS_1.default.creatTextSprite(R,new THREE.Vector3(w.x+x.x/2+h.x*f/30,w.y+x.y/2+h.y*f/30,0),.07*f,M,s))&&t.drawEntity(n),u.identity(),u.makeScale(.08,.08,.08);var H=new THREE.Matrix4;H.makeRotationZ(17*Math.PI/18);var _=new THREE.Vector3(x.x,x.y,0);_.applyMatrix4(u),_.applyMatrix4(H),H.identity(),H.makeRotationZ(17*-Math.PI/18);var V=new THREE.Vector3(x.x,x.y,0);V.applyMatrix4(u),V.applyMatrix4(H);var D=new Array;D.push(new THREE.Vector3(l.x,l.y,0),new THREE.Vector3(l.x+_.x,l.y+_.y,0),new THREE.Vector3(l.x+V.x,l.y+V.y,0)),i=MxThreeJS_1.default.createTriangle(D,s),H.identity(),H.makeRotationZ(Math.PI/18),(_=new THREE.Vector3(x.x,x.y,0)).applyMatrix4(u),_.applyMatrix4(H),H.identity(),H.makeRotationZ(-Math.PI/18),(V=new THREE.Vector3(x.x,x.y,0)).applyMatrix4(u),V.applyMatrix4(H);var g=new Array;g.push(new THREE.Vector3(w.x,w.y,0),new THREE.Vector3(w.x+_.x,w.y+_.y,0),new THREE.Vector3(w.x+V.x,w.y+V.y,0)),o=MxThreeJS_1.default.createTriangle(g,s),t.drawEntity(e),t.drawEntity(r),i&&t.drawEntity(i),o&&t.drawEntity(o),t.drawEntity(a),t.drawEntity(p)}else t.drawLine(this.point1,this.point2)},e.prototype.setPoint1=function(t){this.point1=t},e.prototype.setPoint2=function(t){this.point2=t},e.prototype.getGripPoints=function(){var t=[];return t.push(this.point1),t.push(this.point2),t},e.prototype.moveGripPointsAt=function(t,e){return 0==t?this.point1.add(e):(t=1)&&this.point2.add(e),!0},e.prototype.dwgIn=function(t){return this.onDwgIn(t),this.point1.copy(t.point1),this.point2.copy(t.point2),!0},e.prototype.dwgOut=function(t){return this.onDwgOut(t),t.point1=this.point1,t.point2=this.point2,t},e.prototype.create=function(){return new e},e}(MxDbEntity_1.default);exports.default=MxDbAlignedDimension;
@@ -1 +1 @@
1
- "use strict";var __extends=this&&this.__extends||function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),McGeTool_1=require("../McGeTool"),MxDbEntity_1=require("../MxDbEntity"),MxFun_1=require("../MxFun"),MxThreeJS_1=require("../MxThreeJS"),MxDbArea=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.points=[],n}return __extends(n,t),n.prototype.getTypeName=function(){return"MxDbArea"},n.prototype.create=function(){return new n},n.prototype.worldDraw=function(t){if(this.points.length<3)2==this.points.length&&t.drawLine(this.points[0],this.points[1]);else{for(var n=this.points[0],e=n.clone(),o=n.clone(),r=this.points.length,i=1;i<r;i++){var s=this.points[i];e.x>s.x&&(e.x=s.x),e.y>s.y&&(e.y=s.y),o.x<s.x&&(o.x=s.x),o.y<s.y&&(o.y=s.y),t.drawLine(n,s),n=s}t.drawLine(n,this.points[0]);var p=McGeTool_1.default.calcArea(this.points),u=new THREE.Vector3(e.x+.5*(o.x-e.x),e.y+.5*(o.y-e.y)),c=t.getColor(),a=MxFun_1.default.screenCoordLong2Doc(20),h=MxThreeJS_1.default.creatTextSprite(p.toFixed(2),u,a,0,c);null!=h&&t.drawEntity(h)}},n.prototype.getGripPoints=function(){return this.points},n.prototype.moveGripPointsAt=function(t,n){return!(t>=this.points.length)&&(this.points[t].add(n),!0)},n.prototype.dwgIn=function(t){var n=this;this.onDwgIn(t);var e=t.points;return this.points=[],e.forEach(function(t){n.points.push(new THREE.Vector3(t.x,t.y,t.z))}),!0},n.prototype.dwgOut=function(t){return this.onDwgOut(t),t.points=this.points,t},n.prototype.addPoint=function(t){this.points.push(t.clone())},n.prototype.getPoints=function(){return this.points},n.prototype.clearPoint=function(){this.points=[]},n}(MxDbEntity_1.default);exports.default=MxDbArea;
1
+ "use strict";var __extends=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),McGeTool_1=require("../McGeTool"),MxDbEntity_1=require("../MxDbEntity"),MxFun_1=require("../MxFun"),MxThreeJS_1=require("../MxThreeJS"),MxDbArea=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.points=[],e}return __extends(e,t),e.prototype.getTypeName=function(){return"MxDbArea"},e.prototype.create=function(){return new e},e.prototype.getDimText=function(){return McGeTool_1.default.calcArea(this.points).toFixed(2)},e.prototype.worldDraw=function(t){if(this.points.length<3)2==this.points.length&&t.drawLine(this.points[0],this.points[1]);else{for(var e=this.points[0],n=e.clone(),o=e.clone(),r=this.points.length,i=1;i<r;i++){var s=this.points[i];n.x>s.x&&(n.x=s.x),n.y>s.y&&(n.y=s.y),o.x<s.x&&(o.x=s.x),o.y<s.y&&(o.y=s.y),t.drawLine(e,s),e=s}t.drawLine(e,this.points[0]);var p=new THREE.Vector3(n.x+.5*(o.x-n.x),n.y+.5*(o.y-n.y)),u=t.getColor(),c=MxFun_1.default.screenCoordLong2Doc(20),a=MxThreeJS_1.default.creatTextSprite(this.getDimText(),p,c,0,u);null!=a&&t.drawEntity(a)}},e.prototype.getGripPoints=function(){return this.points},e.prototype.moveGripPointsAt=function(t,e){return!(t>=this.points.length)&&(this.points[t].add(e),!0)},e.prototype.dwgIn=function(t){var e=this;this.onDwgIn(t);var n=t.points;return this.points=[],n.forEach(function(t){e.points.push(new THREE.Vector3(t.x,t.y,t.z))}),!0},e.prototype.dwgOut=function(t){return this.onDwgOut(t),t.points=this.points,t},e.prototype.addPoint=function(t){this.points.push(t.clone())},e.prototype.getPoints=function(){return this.points},e.prototype.clearPoint=function(){this.points=[]},e}(MxDbEntity_1.default);exports.default=MxDbArea;
@@ -1 +1 @@
1
- "use strict";var __extends=this&&this.__extends||function(){var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function i(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(i.prototype=o.prototype,new i)}}(),__awaiter=this&&this.__awaiter||function(t,e,o,i){return new(o||(o=Promise))(function(s,r){function n(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof o?e:new o(function(t){t(e)})).then(n,a)}c((i=i.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var o,i,s,r,n={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(o)throw new TypeError("Generator is already executing.");for(;n;)try{if(o=1,i&&(s=2&r[0]?i.return:r[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,r[1])).done)return s;switch(i=0,s&&(r=[2&r[0],s.value]),r[0]){case 0:case 1:s=r;break;case 4:return n.label++,{value:r[1],done:!1};case 5:n.label++,i=r[1],r=[0];continue;case 7:r=n.ops.pop(),n.trys.pop();continue;default:if(!(s=(s=n.trys).length>0&&s[s.length-1])&&(6===r[0]||2===r[0])){n=0;continue}if(3===r[0]&&(!s||r[1]>s[0]&&r[1]<s[3])){n.label=r[1];break}if(6===r[0]&&n.label<s[1]){n.label=s[1],s=r;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(r);break}s[2]&&n.ops.pop(),n.trys.pop();continue}r=e.call(t,n)}catch(t){r=[6,t],i=0}finally{o=s=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}};Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),MxDbEntity_1=require("../MxDbEntity"),MxDbSVGText_1=require("../MxDbSVGText"),MxThreeJS_1=require("../MxThreeJS"),MxType_1=require("../MxType"),MxDbSVG=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.svgPos=new THREE.Vector3,e.svg=null,e.svgPath="",e.svgSize=new THREE.Vector2(50,50),e.svgAlignmentRatio=new THREE.Vector2(0,0),e.svgRotate=0,e.svgReverse=!1,e.svgMargin=new THREE.Vector2(0,0),e.isSvgDirtyLocation=!1,e.isLoadFromPath=!0,e.aryText=[],e.svgBoxSize=null,e.fixedSize=!1,e.useSvgColor=!1,e}return __extends(e,t),e.prototype.calcVewSize=function(t){var e=this.svgSize.x,o=this.svgSize.y;return o<=0&&(o=this.svgBoxSize?this.svgBoxSize.y/this.svgBoxSize.x*e:e),this.fixedSize&&(e=t.screenCoordLong2Doc(e),o=t.screenCoordLong2Doc(o)),[e,o]},e.prototype.worldDraw=function(t){var e=this,o=t.getMxObject();this.calcSvgPosition(o);var i=this.calcVewSize(o),s=i[0],r=i[1],n=new THREE.Matrix4;this.svgReverse&&n.makeScale(1,-1,1);var a=new THREE.Matrix4;a.makeRotationZ(this.svgRotate);var c=new THREE.Matrix4,g=new THREE.Vector3(this.svgPos.x-s*this.svgAlignmentRatio.x,this.svgPos.y-r*this.svgAlignmentRatio.y,0);c.makeTranslation(g.x,g.y,g.z),a.multiply(n),a.premultiply(c);var v=new THREE.Vector3(0,0,0),h=new THREE.Vector3(s,0,0),x=new THREE.Vector3(s,r,0),l=new THREE.Vector3(0,r,0);if(v.applyMatrix4(a),h.applyMatrix4(a),x.applyMatrix4(a),l.applyMatrix4(a),1==t.getType()){if(this.aryText.forEach(function(i){if(i.txt.length>0){var s=new THREE.Vector3(i.txtPos.x,i.txtPos.y,0);e.fixedSize&&(i.txtPos.x>0?s.x=e.svgPos.x+o.screenCoordLong2Doc(i.txtPos.x):s.x=e.svgPos.x-o.screenCoordLong2Doc(i.txtPos.x),i.txtPos.y>0?s.y=e.svgPos.y+o.screenCoordLong2Doc(i.txtPos.y):s.y=e.svgPos.y-o.screenCoordLong2Doc(i.txtPos.y));var r=void 0;i.color&&(r=t.getColor(),t.setColor(i.color));var n=i.txtHeight;e.fixedSize&&(n=o.screenCoordLong2Doc(i.txtHeight)),i._txtObject=t.drawText(i.txt,n,0,s),i._txtAspectRatio=-1,r&&t.setColor(r)}}),this.svg)t.drawEntity(this.svg);else if(this.svgPath.length>0&&this.isLoadFromPath){var u=this,y=t.getMxObject();MxThreeJS_1.default.loadSVG(this.svgPath,void 0,function(e){if(e){var i=(new THREE.Box3).setFromObject(e);u.svgBoxSize||(u.svgBoxSize=new THREE.Vector3),u.svgBoxSize.x=i.max.x-i.min.x,u.svgBoxSize.y=i.max.y-i.min.y;var s=u.calcVewSize(o),r=s[0],n=s[1];e.scale.x=r/u.svgBoxSize.x,e.scale.y=n/u.svgBoxSize.y,e.scale.z=e.scale.x,u.svgReverse&&(e.scale.y*=-1),e.rotateZ(u.svgRotate),u.isSvgDirtyLocation=!0;var a=new THREE.Color(t.getColor());e.traverse(function(t){t.material&&(t.material=t.material.clone(),t.material.transparent=!0,u.useSvgColor||(t.material.color=a))}),u.svg=e,u.setNeedUpdateDisplay(),y.updateDisplay()}u.isLoadFromPath=!1})}t.drawSelectLine(v,x),t.drawSelectLine(h,l)}else t.drawLine(v,h),t.drawLine(h,x),t.drawLine(x,l),t.drawLine(l,v)},e.prototype.setSvgPath=function(t,e){return void 0===e&&(e=!1),__awaiter(this,void 0,void 0,function(){return __generator(this,function(o){switch(o.label){case 0:return this.svgPath=t,this.svg=null,this.isLoadFromPath=!0,this.svgBoxSize=null,e?[4,MxThreeJS_1.default.loadSVG(t)]:[3,2];case 1:o.sent(),o.label=2;case 2:return[2]}})})},e.prototype.getSvgPath=function(){return this.svgPath},e.prototype.setSvgPostion=function(t){this.svgPos=t.clone(),this.isSvgDirtyLocation=!0},e.prototype.getSvgPostion=function(){return this.svgPos},e.prototype.setSvgSize=function(t){this.svgSize=t,this.isSvgDirtyLocation=!0},e.prototype.getSvgSize=function(){return this.svgSize},e.prototype.setSvgAlignmentRatio=function(t){this.svgAlignmentRatio=t,this.isSvgDirtyLocation=!0},e.prototype.getSvgAlignmentRatio=function(){return this.svgAlignmentRatio},e.prototype.getText=function(t){return t<this.aryText.length?this.aryText[t]:null},e.prototype.addText=function(t){this.aryText.push(t)},e.prototype.getGripPoints=function(){var t=[];return t.push(this.svgPos),t},e.prototype.moveGripPointsAt=function(t,e){return 0==t&&(this.svgPos.add(e),this.fixedSize||this.aryText.forEach(function(t){t.txtPos.add(e)})),this.isSvgDirtyLocation=!0,!0},e.prototype.calcSvgPosition=function(t){if(this.svg&&this.isSvgDirtyLocation){this.isSvgDirtyLocation=!1;var e=this.calcVewSize(t),o=e[0],i=e[1];this.svg.position.x=this.svgPos.x-o*this.svgAlignmentRatio.x-this.svgMargin.x*o,this.svg.position.y=this.svgPos.y-i*this.svgAlignmentRatio.y-this.svgMargin.y*i}},e.prototype.dwgIn=function(t){var e=this;this.onDwgIn(t),this.fixedSize=t.fixedSize,this.fixedSize?this.svg=null:t.type==MxType_1.default.MxCloneType.kClone&&t.svg&&(this.svg=t.svg.clone()),this.svgPos.copy(t.svgPos),this.svgPath=t.svgPath.substr(0),this.svgSize.copy(t.svgSize),this.svgAlignmentRatio.copy(t.svgAlignmentRatio),this.isSvgDirtyLocation=!0,this.svg||(this.isLoadFromPath=!0),this.svgBoxSize=null;var o=t.txts;return this.aryText=[],o.forEach(function(t){var o=new MxDbSVGText_1.default;o.txt=t.txt,o.txtHeight=t.txtHeight,o.txtPos.copy(t.txtPos),e.aryText.push(o)}),this.svgRotate=t.svgRotate,this.useSvgColor=t.useSvgColor,this.svgReverse=t.svgReverse,this.svgMargin=t.svgMargin,!0},e.prototype.dwgOut=function(t){return this.onDwgOut(t),t.type==MxType_1.default.MxCloneType.kClone&&(t.svg=this.svg),t.svgPath=this.svgPath,t.svgPos=this.svgPos,t.svgSize=this.svgSize,t.svgAlignmentRatio=this.svgAlignmentRatio,t.txts=this.aryText,t.fixedSize=this.fixedSize,t.svgRotate=this.svgRotate,t.useSvgColor=this.useSvgColor,t.svgReverse=this.svgReverse,t.svgMargin=this.svgMargin,t},e.prototype.create=function(){return new e},e.prototype.transformBy=function(t){this.svgPos.applyMatrix4(t),this.isSvgDirtyLocation=!0,this.fixedSize||this.aryText.forEach(function(e){e.txtPos.applyMatrix4(t)})},e.prototype.getTypeName=function(){return"MxDbSVG"},e.prototype.setColor=function(e){if(t.prototype.setColor.call(this,e),this.svg){var o=new THREE.Color(this.color);this.svg.traverse(function(t){t.material&&(t.material.color=o)})}},e.prototype.onViewChange=function(){if(!this.fixedSize)return!1;var t=this.getMxObject();if(null==t)return!1;if(this.svg){if(!this.svgBoxSize){this.svgBoxSize=new THREE.Vector3;var e=(new THREE.Box3).setFromObject(this.svg);this.svgBoxSize.x=e.max.x-e.min.x,this.svgBoxSize.y=e.max.y-e.min.y}var o=this.calcVewSize(t),i=o[0],s=o[1];this.svg.scale.x=i/this.svgBoxSize.x,this.svg.scale.y=s/this.svgBoxSize.y,this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}var r=this;return this.aryText.forEach(function(e){if(e._txtObject&&t){var o=t.screenCoordLong2Doc(e.txtHeight);o>1e-5&&(e._txtAspectRatio<=0&&(e._txtAspectRatio=e._txtObject.scale.x/e._txtObject.scale.y),e._txtObject.scale.set(e._txtAspectRatio*o,o,1),e.txtPos.x>0?e._txtObject.position.x=r.svgPos.x+t.screenCoordLong2Doc(e.txtPos.x):e._txtObject.position.x=r.svgPos.x-t.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?e._txtObject.position.y=r.svgPos.y+t.screenCoordLong2Doc(e.txtPos.y):e._txtObject.position.y=r.svgPos.y-t.screenCoordLong2Doc(e.txtPos.y),e._txtObject.updateMatrix())}}),!0},e}(MxDbEntity_1.default);exports.default=MxDbSVG;
1
+ "use strict";var __extends=this&&this.__extends||function(){var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function o(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}(),__awaiter=this&&this.__awaiter||function(t,e,i,o){return new(i||(i=Promise))(function(s,r){function n(t){try{c(o.next(t))}catch(t){r(t)}}function a(t){try{c(o.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,a)}c((o=o.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var i,o,s,r,n={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(i)throw new TypeError("Generator is already executing.");for(;n;)try{if(i=1,o&&(s=2&r[0]?o.return:r[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,r[1])).done)return s;switch(o=0,s&&(r=[2&r[0],s.value]),r[0]){case 0:case 1:s=r;break;case 4:return n.label++,{value:r[1],done:!1};case 5:n.label++,o=r[1],r=[0];continue;case 7:r=n.ops.pop(),n.trys.pop();continue;default:if(!(s=(s=n.trys).length>0&&s[s.length-1])&&(6===r[0]||2===r[0])){n=0;continue}if(3===r[0]&&(!s||r[1]>s[0]&&r[1]<s[3])){n.label=r[1];break}if(6===r[0]&&n.label<s[1]){n.label=s[1],s=r;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(r);break}s[2]&&n.ops.pop(),n.trys.pop();continue}r=e.call(t,n)}catch(t){r=[6,t],o=0}finally{i=s=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}};Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),MxDbEntity_1=require("../MxDbEntity"),MxDbSVGText_1=require("../MxDbSVGText"),MxThreeJS_1=require("../MxThreeJS"),MxType_1=require("../MxType"),MxDbSVG=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.svgPos=new THREE.Vector3,e.svg=null,e.svgPath="",e.svgSize=new THREE.Vector2(50,50),e.svgAlignmentRatio=new THREE.Vector2(0,0),e.svgRotate=0,e.svgReverse=!1,e.svgMargin=new THREE.Vector2(0,0),e.isSvgDirtyLocation=!1,e.isLoadFromPath=!0,e.aryText=[],e.svgBoxSize=null,e.fixedSize=!1,e.useSvgColor=!1,e}return __extends(e,t),e.prototype.calcVewSize=function(t){var e=this.svgSize.x,i=this.svgSize.y;return i<=0&&(i=this.svgBoxSize?this.svgBoxSize.y/this.svgBoxSize.x*e:e),this.fixedSize&&(e=t.screenCoordLong2Doc(e),i=t.screenCoordLong2Doc(i)),[e,i]},e.prototype.worldDraw=function(t){var e=this,i=t.getMxObject();this.calcSvgPosition(i);var o=this.calcVewSize(i),s=o[0],r=o[1],n=new THREE.Matrix4;this.svgReverse&&n.makeScale(1,-1,1);var a=new THREE.Matrix4;a.makeRotationZ(this.svgRotate);var c=new THREE.Matrix4,g=new THREE.Vector3(this.svgPos.x-s*this.svgAlignmentRatio.x,this.svgPos.y-r*this.svgAlignmentRatio.y,0);c.makeTranslation(g.x,g.y,g.z),a.multiply(n),a.premultiply(c);var v=new THREE.Vector3(0,0,0),h=new THREE.Vector3(s,0,0),x=new THREE.Vector3(s,r,0),l=new THREE.Vector3(0,r,0);if(v.applyMatrix4(a),h.applyMatrix4(a),x.applyMatrix4(a),l.applyMatrix4(a),1==t.getType()){if(this.aryText.forEach(function(o){if(o.txt.length>0){var s=new THREE.Vector3(o.txtPos.x,o.txtPos.y,0);e.fixedSize&&(o.txtPos.x>0?s.x=e.svgPos.x+i.screenCoordLong2Doc(o.txtPos.x):s.x=e.svgPos.x-i.screenCoordLong2Doc(o.txtPos.x),o.txtPos.y>0?s.y=e.svgPos.y+i.screenCoordLong2Doc(o.txtPos.y):s.y=e.svgPos.y-i.screenCoordLong2Doc(o.txtPos.y));var r=void 0;o.color&&(r=t.getColor(),t.setColor(o.color));var n=o.txtHeight;e.fixedSize&&(n=i.screenCoordLong2Doc(o.txtHeight)),o._txtObject=t.drawText(o.txt,n,0,s),o._txtAspectRatio=-1,r&&t.setColor(r)}}),this.svg)t.drawEntity(this.svg);else if(this.svgPath.length>0&&this.isLoadFromPath){var u=this,y=t.getMxObject();MxThreeJS_1.default.loadSVG(this.svgPath,void 0,function(e){if(e){var o=(new THREE.Box3).setFromObject(e);u.svgBoxSize||(u.svgBoxSize=new THREE.Vector3),u.svgBoxSize.x=o.max.x-o.min.x,u.svgBoxSize.y=o.max.y-o.min.y;var s=u.calcVewSize(i),r=s[0],n=s[1];e.scale.x=r/u.svgBoxSize.x,e.scale.y=n/u.svgBoxSize.y,e.scale.z=e.scale.x,u.svgReverse&&(e.scale.y*=-1),e.rotateZ(u.svgRotate),u.isSvgDirtyLocation=!0;var a=new THREE.Color(t.getColor());e.traverse(function(t){t.material&&(t.material=t.material.clone(),t.material.transparent=!0,u.useSvgColor||(t.material.color=a))}),u.svg=e,u.setNeedUpdateDisplay(),y.updateDisplay()}u.isLoadFromPath=!1})}t.drawSelectLine(v,x),t.drawSelectLine(h,l),t.drawSelectLine(v,h),t.drawSelectLine(h,x),t.drawSelectLine(x,l),t.drawSelectLine(l,v)}else t.drawLine(v,h),t.drawLine(h,x),t.drawLine(x,l),t.drawLine(l,v)},e.prototype.setSvgPath=function(t,e){return void 0===e&&(e=!1),__awaiter(this,void 0,void 0,function(){return __generator(this,function(i){switch(i.label){case 0:return this.svgPath=t,this.svg=null,this.isLoadFromPath=!0,this.svgBoxSize=null,e?[4,MxThreeJS_1.default.loadSVG(t)]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}})})},e.prototype.getSvgPath=function(){return this.svgPath},e.prototype.setSvgPostion=function(t){this.svgPos=t.clone(),this.isSvgDirtyLocation=!0},e.prototype.getSvgPostion=function(){return this.svgPos},e.prototype.setSvgSize=function(t){this.svgSize=t,this.isSvgDirtyLocation=!0},e.prototype.getSvgSize=function(){return this.svgSize},e.prototype.setSvgAlignmentRatio=function(t){this.svgAlignmentRatio=t,this.isSvgDirtyLocation=!0},e.prototype.getSvgAlignmentRatio=function(){return this.svgAlignmentRatio},e.prototype.getText=function(t){return t<this.aryText.length?this.aryText[t]:null},e.prototype.addText=function(t){this.aryText.push(t)},e.prototype.getGripPoints=function(){var t=[];return t.push(this.svgPos),t},e.prototype.moveGripPointsAt=function(t,e){return 0==t&&(this.svgPos.add(e),this.fixedSize||this.aryText.forEach(function(t){t.txtPos.add(e)})),this.isSvgDirtyLocation=!0,!0},e.prototype.calcSvgPosition=function(t){if(this.svg&&this.isSvgDirtyLocation){this.isSvgDirtyLocation=!1;var e=this.calcVewSize(t),i=e[0],o=e[1];this.svg.position.x=this.svgPos.x-i*this.svgAlignmentRatio.x-this.svgMargin.x*i,this.svg.position.y=this.svgPos.y-o*this.svgAlignmentRatio.y-this.svgMargin.y*o}},e.prototype.dwgIn=function(t){var e=this;this.onDwgIn(t),this.fixedSize=t.fixedSize,this.fixedSize?this.svg=null:t.type==MxType_1.default.MxCloneType.kClone&&t.svg&&(this.svg=t.svg.clone()),this.svgPos.copy(t.svgPos),this.svgPath=t.svgPath.substr(0),this.svgSize.copy(t.svgSize),this.svgAlignmentRatio.copy(t.svgAlignmentRatio),this.isSvgDirtyLocation=!0,this.svg||(this.isLoadFromPath=!0),this.svgBoxSize=null;var i=t.txts;return this.aryText=[],i.forEach(function(t){var i=new MxDbSVGText_1.default;i.txt=t.txt,i.txtHeight=t.txtHeight,i.txtPos.copy(t.txtPos),e.aryText.push(i)}),this.svgRotate=t.svgRotate,this.useSvgColor=t.useSvgColor,this.svgReverse=t.svgReverse,this.svgMargin=t.svgMargin,!0},e.prototype.dwgOut=function(t){return this.onDwgOut(t),t.type==MxType_1.default.MxCloneType.kClone&&(t.svg=this.svg),t.svgPath=this.svgPath,t.svgPos=this.svgPos,t.svgSize=this.svgSize,t.svgAlignmentRatio=this.svgAlignmentRatio,t.txts=this.aryText,t.fixedSize=this.fixedSize,t.svgRotate=this.svgRotate,t.useSvgColor=this.useSvgColor,t.svgReverse=this.svgReverse,t.svgMargin=this.svgMargin,t},e.prototype.create=function(){return new e},e.prototype.transformBy=function(t){this.svgPos.applyMatrix4(t),this.isSvgDirtyLocation=!0,this.fixedSize||this.aryText.forEach(function(e){e.txtPos.applyMatrix4(t)})},e.prototype.getTypeName=function(){return"MxDbSVG"},e.prototype.setColor=function(e){if(t.prototype.setColor.call(this,e),this.svg){var i=new THREE.Color(this.color);this.svg.traverse(function(t){t.material&&(t.material.color=i)})}},e.prototype.onViewChange=function(){if(!this.fixedSize)return!1;var t=this.getMxObject();if(null==t)return!1;if(this.svg){if(!this.svgBoxSize){this.svgBoxSize=new THREE.Vector3;var e=(new THREE.Box3).setFromObject(this.svg);this.svgBoxSize.x=e.max.x-e.min.x,this.svgBoxSize.y=e.max.y-e.min.y}var i=this.calcVewSize(t),o=i[0],s=i[1];this.svg.scale.x=o/this.svgBoxSize.x,this.svg.scale.y=s/this.svgBoxSize.y,this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}var r=this;return this.aryText.forEach(function(e){if(e._txtObject&&t){var i=t.screenCoordLong2Doc(e.txtHeight);i>1e-5&&(e._txtAspectRatio<=0&&(e._txtAspectRatio=e._txtObject.scale.x/e._txtObject.scale.y),e._txtObject.scale.set(e._txtAspectRatio*i,i,1),e.txtPos.x>0?e._txtObject.position.x=r.svgPos.x+t.screenCoordLong2Doc(e.txtPos.x):e._txtObject.position.x=r.svgPos.x-t.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?e._txtObject.position.y=r.svgPos.y+t.screenCoordLong2Doc(e.txtPos.y):e._txtObject.position.y=r.svgPos.y-t.screenCoordLong2Doc(e.txtPos.y),e._txtObject.updateMatrix())}}),!0},e}(MxDbEntity_1.default);exports.default=MxDbSVG;