mxdraw 0.1.94 → 0.1.95
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,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
|
|
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 a(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(a.prototype=i.prototype,new a)}}();Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),MxDbEntity_1=require("../MxDbEntity"),MxFun_1=require("../MxFun"),MxDbImage=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.imagePath="",e.isLoadMaterialFromPath=!0,e.material=null,e.angle=0,e}return __extends(e,t),e.prototype.getTypeName=function(){return"MxDbImage"},e.prototype.getAngle=function(){return this.angle},e.prototype.setAngle=function(t){this.angle=t},e.prototype.worldDraw=function(t){var e=this,i=new THREE.Vector3(this.pt1.x,this.pt2.y),a=new THREE.Vector3(this.pt2.x,this.pt1.y);if(Math.abs(this.angle)>1e-5){var r=new THREE.Vector3(.5*(this.pt1.x-this.pt2.x)+this.pt2.x,.5*(this.pt1.y-this.pt2.y)+this.pt2.y),n=new THREE.Matrix4;n.makeRotationZ(this.angle);var s=(new THREE.Matrix4).makeTranslation(r.x,r.y,r.z).multiply(n).multiply((new THREE.Matrix4).makeTranslation(-r.x,-r.y,-r.z));t.setMatrix(s)}if(1==t.getType()){if(t.drawSelectLine(this.pt1,i),t.drawSelectLine(i,this.pt2),t.drawSelectLine(this.pt2,a),t.drawSelectLine(a,this.pt1),this.material){for(var o=Math.abs(this.pt1.x-this.pt2.x),h=Math.abs(this.pt1.y-this.pt2.y),p=new THREE.PlaneGeometry(o,h),l=Math.min(this.pt1.x,this.pt2.x),u=Math.min(this.pt1.y,this.pt2.y),y=0;y<p.vertices.length;y++)p.vertices[y].x+=l+.5*o,p.vertices[y].y+=u+.5*h,p.vertices[y].z=0;(d=new THREE.Mesh(p,this.material)).material.depthTest=!1,t.drawEntity(d)}else if(this.imagePath.length>0&&this.isLoadMaterialFromPath){var c=this,m=t.getMxObject();MxFun_1.default.loadImageMaterial(this.imagePath,function(t){e.isLoadMaterialFromPath=!1,t&&(c.setMaterial(t),c.setNeedUpdateDisplay(),m.updateDisplay())})}}else if(this.material){for(o=Math.abs(this.pt1.x-this.pt2.x),h=Math.abs(this.pt1.y-this.pt2.y),p=new THREE.PlaneGeometry(o,h),l=Math.min(this.pt1.x,this.pt2.x),u=Math.min(this.pt1.y,this.pt2.y),y=0;y<p.vertices.length;y++)p.vertices[y].x+=l+.5*o,p.vertices[y].y+=u+.5*h,p.vertices[y].z=0;var d;(d=new THREE.Mesh(p,this.material)).material.depthTest=!1,t.drawEntity(d)}else t.drawLine(this.pt1,i),t.drawLine(i,this.pt2),t.drawLine(this.pt2,a),t.drawLine(a,this.pt1);t.setMatrix(null)},e.prototype.setImagePath=function(t){this.imagePath=t,this.isLoadMaterialFromPath=!0,this.material=null},e.prototype.getImagePath=function(){return this.imagePath},e.prototype.setMaterial=function(t){this.material=t},e.prototype.loadMaterial=function(t){var e=this;t&&(this.imagePath=t),this.isLoadMaterialFromPath=!1,this.material=null;var i=this;MxFun_1.default.loadImageMaterial(this.imagePath,function(t){e.isLoadMaterialFromPath=!1,i.setMaterial(t)})},e.prototype.setPoint1=function(t){this.pt1=t},e.prototype.getPoint1=function(){return this.pt1},e.prototype.setPoint2=function(t){this.pt2=t},e.prototype.getPoint2=function(){return this.pt2},e.prototype.getGripPoints=function(){var t=[];t.push(this.pt1),t.push(this.pt2);var e=new THREE.Vector3(this.pt1.x+.5*(this.pt2.x-this.pt1.x),this.pt1.y+.5*(this.pt2.y-this.pt1.y));return t.push(e),t},e.prototype.moveGripPointsAt=function(t,e){return 0==t?this.pt1.add(e):1==t?this.pt2.add(e):2==t&&(this.pt1.add(e),this.pt2.add(e)),!0},e.prototype.dwgIn=function(t){return this.onDwgIn(t),this.pt1.copy(t.pt1),this.pt2.copy(t.pt2),this.imagePath=t.imagePath.substr(0),this.isLoadMaterialFromPath=!0,t.angle&&(this.angle=t.angle),!0},e.prototype.dwgOut=function(t){return this.onDwgOut(t),t.pt1=this.pt1,t.pt2=this.pt2,t.imagePath=this.imagePath,t.angle=this.angle,t},e.prototype.create=function(){return new e},e}(MxDbEntity_1.default);exports.default=MxDbImage;
|