mxdraw 0.1.115 → 0.1.116

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.
package/dist/index.d.ts CHANGED
@@ -292,7 +292,7 @@ interface McGiWorldDraw {
292
292
  * ```
293
293
  *
294
294
  */
295
- drawText(sText: string, iSize: number, dAngle: number, pt: THREE.Vector3, width?: number): THREE.Sprite | null;
295
+ drawText(sText: string, iSize: number, dAngle: number, pt: THREE.Vector3, width?: number, callGetFontStyle?: (iFontSize: number) => string): THREE.Sprite | null;
296
296
  /**
297
297
  * 设置DrawOrder,默认值为100.
298
298
  * @returns
@@ -3161,10 +3161,12 @@ declare class MxDbSVGText {
3161
3161
  move: boolean;
3162
3162
  /** 文字移动到距图片远处,自动绘制一个连接线 */
3163
3163
  drawConnectingLine: boolean;
3164
+ /** 字体样式 */
3165
+ fontStyle: string;
3166
+ /** 下划线 */
3167
+ underline: boolean;
3164
3168
  }
3165
3169
 
3166
- /** @module MxDbSVG*/
3167
-
3168
3170
  /**
3169
3171
  * MxDbSVG 绘制SVG图形.
3170
3172
  */
@@ -142,7 +142,7 @@ export default interface McGiWorldDraw {
142
142
  * ```
143
143
  *
144
144
  */
145
- drawText(sText: string, iSize: number, dAngle: number, pt: THREE.Vector3, width?: number): THREE.Sprite | null;
145
+ drawText(sText: string, iSize: number, dAngle: number, pt: THREE.Vector3, width?: number, callGetFontStyle?: (iFontSize: number) => string): THREE.Sprite | null;
146
146
  /**
147
147
  * 设置DrawOrder,默认值为100.
148
148
  * @returns
@@ -1,4 +1,3 @@
1
- /** @module MxDbSVG*/
2
1
  import McGiWorldDraw from '../McGiWorldDraw';
3
2
  import MxDbEntity from '../MxDbEntity';
4
3
  import MxDbSVGText from '../MxDbSVGText';
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(t,s,e,i){return new(e||(e=Promise))(function(o,r){function g(t){try{n(i.next(t))}catch(t){r(t)}}function h(t){try{n(i.throw(t))}catch(t){r(t)}}function n(t){var s;t.done?o(t.value):(s=t.value,s instanceof e?s:new e(function(t){t(s)})).then(g,h)}n((i=i.apply(t,s||[])).next())})};import MxDbEntity from"../MxDbEntity";import MxDbSVGText from"../MxDbSVGText";import MxFun from"../MxFun";import MxThreeJS from"../MxThreeJS";import MxType from"../MxType";export default class MxDbSVG extends MxDbEntity{constructor(){super(...arguments),this.svgPos=new THREE.Vector3,this.svg=null,this.svgPath="",this.svgSize=new THREE.Vector2(50,50),this.svgAlignmentRatio=new THREE.Vector2(0,0),this.svgRotate=0,this.svgReverse=!1,this.svgMirror=!1,this.svgChildColor=[],this.svgMargin=new THREE.Vector2(0,0),this.isSvgDirtyLocation=!1,this.isLoadFromPath=!0,this.aryText=[],this.svgBoxSize=null,this.fixedSize=!1,this.useSvgColor=!1}setSvgChildColor(t){if(this.svgChildColor=t,!this.useSvgColor&&this.svg){let t=new THREE.Color(this.getColor()),s=0,e=this;this.svg.traverse(function(i){i.material&&(s<e.svgChildColor.length?i.material.color=new THREE.Color(e.svgChildColor[s]):i.material.color=t,s++)}),this.setNeedUpdateDisplay(!0)}}getSvgChildColor(){return this.svgChildColor}calcVewSize(t){let s=this.svgSize.x,e=this.svgSize.y;return e<=0&&(e=this.svgBoxSize?this.svgBoxSize.y/this.svgBoxSize.x*s:s),this.fixedSize&&(s=t.screenCoordLong2Doc(s),e=t.screenCoordLong2Doc(e)),[s,e]}calcSvgDrawRect(t){if(!t)return;this.calcSvgPosition(t);let[s,e]=this.calcVewSize(t),i=new THREE.Matrix4;i.makeScale(this.svgMirror?-1:1,this.svgReverse?-1:1,1);let o=new THREE.Matrix4;o.makeRotationZ(this.svgRotate);let r=new THREE.Matrix4,g=new THREE.Vector3(this.svgPos.x-s*this.svgAlignmentRatio.x,this.svgPos.y-e*this.svgAlignmentRatio.y,0);r.makeTranslation(g.x,g.y,g.z),o.multiply(i),o.premultiply(r);let h=new THREE.Vector3(0,0,0),n=new THREE.Vector3(s,0,0),a=new THREE.Vector3(s,e,0),l=new THREE.Vector3(0,e,0);return h.applyMatrix4(o),n.applyMatrix4(o),a.applyMatrix4(o),l.applyMatrix4(o),{pt1:h,pt2:a,pt3:n,pt4:l,cenpt:a.clone().add(h.clone().sub(a).multiplyScalar(.5)),sizew:s,sizeh:e}}worldDraw(t){let s=t.getMxObject(),e=this.calcSvgDrawRect(s),i=e.pt1,o=e.pt2,r=e.pt3,g=e.pt4,h=e.cenpt,n=e.sizew;if(this.aryText.forEach((e,i)=>{if(e.txt.length>0){let o=new THREE.Vector3(e.txtPos.x,e.txtPos.y,0);this.fixedSize&&(e.txtPos.x>0?o.x=this.svgPos.x+s.screenCoordLong2Doc(e.txtPos.x):o.x=this.svgPos.x-s.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?o.y=this.svgPos.y+s.screenCoordLong2Doc(e.txtPos.y):o.y=this.svgPos.y-s.screenCoordLong2Doc(e.txtPos.y));let r=void 0;e.color&&(r=t.getColor(),t.setColor(e.color));let g=e.txtHeight;if(this.fixedSize&&(g=s.screenCoordLong2Doc(e.txtHeight)),t.setXData({type:"text",txt:e.txt,index:i}),e._txtObject=t.drawText(e.txt,g,0,o),e._txtAspectRatio=-1,r&&t.setColor(r),e.drawConnectingLine){let s=h.clone().sub(o);if(s.length()>e.txtHeight+n){s.normalize();let i=h.clone().sub(s.clone().multiplyScalar(n)),r=o.clone().add(s.clone().multiplyScalar(e.txtHeight));t.setXData({type:"line"}),t.drawLine(i,r)}}}}),1==t.getType()){if(this.svg)t.setXData({type:"svg"}),t.drawEntity(this.svg);else if(this.svgPath.length>0&&this.isLoadFromPath){let e=this,i=t.getMxObject();MxThreeJS.loadSVG(this.svgPath,void 0,o=>{if(o){let r=o;if(r.boxSize)e.svgBoxSize=r.boxSize.clone();else{let t=(new THREE.Box3).setFromObject(o);e.svgBoxSize||(e.svgBoxSize=new THREE.Vector3),e.svgBoxSize.x=t.max.x-t.min.x,e.svgBoxSize.y=t.max.y-t.min.y}let[g,h]=e.calcVewSize(s);e.svgBoxSize&&(o.scale.x=g/e.svgBoxSize.x,o.scale.y=h/e.svgBoxSize.y),o.scale.z=o.scale.x,e.svgReverse&&(o.scale.y*=-1),e.svgMirror&&(o.scale.x*=-1),o.rotateZ(e.svgRotate),e.isSvgDirtyLocation=!0;let n=new THREE.Color(t.getColor()),a=0;o.traverse(function(t){t.material&&(t.material=t.material.clone(),t.material.transparent=!0,t.material.depthTest=!1,e.useSvgColor||(a<e.svgChildColor.length?t.material.color=new THREE.Color(e.svgChildColor[a]):t.material.color=n),a++)}),e.svg=o,e.setNeedUpdateDisplay(),i.updateDisplay()}else console.log("mx LoadSVG:"+e.svgPath+" failed");e.isLoadFromPath=!1})}}else t.drawLine(i,r),t.drawLine(r,o),t.drawLine(o,g),t.drawLine(g,i)}setSvgPath(t,s=!1){return __awaiter(this,void 0,void 0,function*(){this.svgPath=t,this.svg=null,this.isLoadFromPath=!0,this.svgBoxSize=null,s&&(yield MxThreeJS.loadSVG(t))})}getSvgPath(){return this.svgPath}setSvgPostion(t){this.svgPos=t.clone(),this.isSvgDirtyLocation=!0}getSvgPostion(){return this.svgPos}setSvgSize(t){this.svgSize=t,this.isSvgDirtyLocation=!0}getSvgSize(){return this.svgSize}setSvgAlignmentRatio(t){this.svgAlignmentRatio=t,this.isSvgDirtyLocation=!0}getSvgAlignmentRatio(){return this.svgAlignmentRatio}getText(t){return t<this.aryText.length?this.aryText[t]:null}addText(t){this.aryText.push(t)}getGripPoints(){let t=[];t.push(this.svgPos);let s=0;for(;s<this.aryText.length;s++){let e=this.aryText[s];if(e.move){let s=new THREE.Vector3(e.txtPos.x,e.txtPos.y,0);if(this.fixedSize){let t=MxFun.getCurrentDraw();e.txtPos.x>0?s.x=this.svgPos.x+t.screenCoordLong2Doc(e.txtPos.x):s.x=this.svgPos.x-t.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?s.y=this.svgPos.y+t.screenCoordLong2Doc(e.txtPos.y):s.y=this.svgPos.y-t.screenCoordLong2Doc(e.txtPos.y)}t.push(s)}}return t}moveGripPointsAt(t,s){if(0==t)this.svgPos.add(s),this.fixedSize||this.aryText.forEach(t=>{t.txtPos.add(s)});else if(t-1>=0&&t-1<this.aryText.length){let e=this.aryText[t-1];if(e.move)if(this.fixedSize){let t=MxFun.getCurrentDraw();e.txtPos.x+=t.docCoordLong2Screen(s.x),e.txtPos.y+=t.docCoordLong2Screen(s.y)}else e.txtPos.add(s)}return this.isSvgDirtyLocation=!0,!0}calcSvgPosition(t){if(!this.svg||!this.isSvgDirtyLocation)return;this.isSvgDirtyLocation=!1;let[s,e]=this.calcVewSize(t);this.svg.position.x=this.svgPos.x-s*this.svgAlignmentRatio.x-this.svgMargin.x*s,this.svg.position.y=this.svgPos.y-e*this.svgAlignmentRatio.y-this.svgMargin.y*e}dwgIn(t){this.onDwgIn(t),this.fixedSize=t.fixedSize,this.fixedSize?this.svg=null:t.type==MxType.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;let s=t.txts;return this.aryText=[],s.forEach(t=>{let s=new MxDbSVGText;s.txt=t.txt,s.txtHeight=t.txtHeight,s.txtPos.copy(t.txtPos),s.move=t.move,s.drawConnectingLine=t.drawConnectingLine,this.aryText.push(s)}),this.svgRotate=t.svgRotate,this.useSvgColor=t.useSvgColor,this.svgReverse=t.svgReverse,this.svgMirror=t.svgMirror,this.svgMargin=t.svgMargin,t.svgChildColor?this.svgChildColor=t.svgChildColor:this.svgChildColor=[],!0}dwgOut(t){return this.onDwgOut(t),t.type==MxType.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.forEach(s=>{let e={txtPos:s.txtPos,txt:s.txt,txtHeight:s.txtHeight,color:s.color,_txtAspectRatio:s._txtAspectRatio,move:s.move,drawConnectingLine:s.drawConnectingLine};t.txts.push(e)}),t.fixedSize=this.fixedSize,t.svgRotate=this.svgRotate,t.useSvgColor=this.useSvgColor,t.svgReverse=this.svgReverse,t.svgMirror=this.svgMirror,t.svgMargin=this.svgMargin,t.svgChildColor=this.svgChildColor,t}create(){return new MxDbSVG}transformBy(t){this.svgPos.applyMatrix4(t),this.isSvgDirtyLocation=!0,this.fixedSize||this.aryText.forEach(s=>{s.txtPos.applyMatrix4(t)})}getTypeName(){return"MxDbSVG"}setColor(t){if(super.setColor(t),this.svg){let t=new THREE.Color(this.color);this.svg.traverse(function(s){s.material&&(s.material.color=t)})}return this}setSvg(t){this.svg=t,this.isLoadFromPath=!1,this.svgBoxSize=null}calcSvgBoxSize(t){if(!this.svgBoxSize)if(t.boxSize)this.svgBoxSize=t.boxSize.clone();else{let s=(new THREE.Box3).setFromObject(t);this.svgBoxSize||(this.svgBoxSize=new THREE.Vector3),this.svgBoxSize.x=s.max.x-s.min.x,this.svgBoxSize.y=s.max.y-s.min.y}}reComputeSVG(){if(!this.svg)return;let t=this.getMxObject();if(!t)return;this.calcSvgBoxSize(this.svg);let[s,e]=this.calcVewSize(t);this.svgBoxSize&&(this.svg.scale.x=s/this.svgBoxSize.x,this.svg.scale.y=e/this.svgBoxSize.y),this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.svgMirror&&(this.svg.scale.x*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}onViewChange(){if(!this.fixedSize)return!1;let t=this.getMxObject();if(null==t)return!1;if(this.svg){this.calcSvgBoxSize(this.svg);let[s,e]=this.calcVewSize(t);this.svgBoxSize&&(this.svg.scale.x=s/this.svgBoxSize.x,this.svg.scale.y=e/this.svgBoxSize.y),this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.svgMirror&&(this.svg.scale.x*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}let s=this;return this.aryText.forEach(e=>{if(e._txtObject&&t){let 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=s.svgPos.x+t.screenCoordLong2Doc(e.txtPos.x):e._txtObject.position.x=s.svgPos.x-t.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?e._txtObject.position.y=s.svgPos.y+t.screenCoordLong2Doc(e.txtPos.y):e._txtObject.position.y=s.svgPos.y-t.screenCoordLong2Doc(e.txtPos.y),e._txtObject.updateMatrix())}}),!0}};
1
+ var __awaiter=this&&this.__awaiter||function(t,s,e,i){return new(e||(e=Promise))(function(o,r){function g(t){try{h(i.next(t))}catch(t){r(t)}}function n(t){try{h(i.throw(t))}catch(t){r(t)}}function h(t){var s;t.done?o(t.value):(s=t.value,s instanceof e?s:new e(function(t){t(s)})).then(g,n)}h((i=i.apply(t,s||[])).next())})};import MxDbEntity from"../MxDbEntity";import MxDbSVGText from"../MxDbSVGText";import MxFun from"../MxFun";import MxThreeJS from"../MxThreeJS";import MxType from"../MxType";export default class MxDbSVG extends MxDbEntity{constructor(){super(...arguments),this.svgPos=new THREE.Vector3,this.svg=null,this.svgPath="",this.svgSize=new THREE.Vector2(50,50),this.svgAlignmentRatio=new THREE.Vector2(0,0),this.svgRotate=0,this.svgReverse=!1,this.svgMirror=!1,this.svgChildColor=[],this.svgMargin=new THREE.Vector2(0,0),this.isSvgDirtyLocation=!1,this.isLoadFromPath=!0,this.aryText=[],this.svgBoxSize=null,this.fixedSize=!1,this.useSvgColor=!1}setSvgChildColor(t){if(this.svgChildColor=t,!this.useSvgColor&&this.svg){let t=new THREE.Color(this.getColor()),s=0,e=this;this.svg.traverse(function(i){i.material&&(s<e.svgChildColor.length?i.material.color=new THREE.Color(e.svgChildColor[s]):i.material.color=t,s++)}),this.setNeedUpdateDisplay(!0)}}getSvgChildColor(){return this.svgChildColor}calcVewSize(t){let s=this.svgSize.x,e=this.svgSize.y;return e<=0&&(e=this.svgBoxSize?this.svgBoxSize.y/this.svgBoxSize.x*s:s),this.fixedSize&&(s=t.screenCoordLong2Doc(s),e=t.screenCoordLong2Doc(e)),[s,e]}calcSvgDrawRect(t){if(!t)return;this.calcSvgPosition(t);let[s,e]=this.calcVewSize(t),i=new THREE.Matrix4;i.makeScale(this.svgMirror?-1:1,this.svgReverse?-1:1,1);let o=new THREE.Matrix4;o.makeRotationZ(this.svgRotate);let r=new THREE.Matrix4,g=new THREE.Vector3(this.svgPos.x-s*this.svgAlignmentRatio.x,this.svgPos.y-e*this.svgAlignmentRatio.y,0);r.makeTranslation(g.x,g.y,g.z),o.multiply(i),o.premultiply(r);let n=new THREE.Vector3(0,0,0),h=new THREE.Vector3(s,0,0),a=new THREE.Vector3(s,e,0),l=new THREE.Vector3(0,e,0);return n.applyMatrix4(o),h.applyMatrix4(o),a.applyMatrix4(o),l.applyMatrix4(o),{pt1:n,pt2:a,pt3:h,pt4:l,cenpt:a.clone().add(n.clone().sub(a).multiplyScalar(.5)),sizew:s,sizeh:e}}worldDraw(t){let s=t.getMxObject(),e=this.calcSvgDrawRect(s),i=e.pt1,o=e.pt2,r=e.pt3,g=e.pt4,n=e.cenpt,h=e.sizew;if(this.aryText.forEach((e,i)=>{if(e.txt.length>0){let o=new THREE.Vector3(e.txtPos.x,e.txtPos.y,0);this.fixedSize&&(e.txtPos.x>0?o.x=this.svgPos.x+s.screenCoordLong2Doc(e.txtPos.x):o.x=this.svgPos.x-s.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?o.y=this.svgPos.y+s.screenCoordLong2Doc(e.txtPos.y):o.y=this.svgPos.y-s.screenCoordLong2Doc(e.txtPos.y));let r=void 0;e.color&&(r=t.getColor(),t.setColor(e.color));let g=e.txtHeight;if(this.fixedSize&&(g=s.screenCoordLong2Doc(e.txtHeight)),t.setXData({type:"text",txt:e.txt,index:i}),e._txtObject=t.drawText(e.txt,g,0,o,void 0,t=>{let s="";return s=e.fontStyle.length>0?`${e.fontStyle} ${t}px Arial`:`normal ${t}px Arial`}),e.underline&&e._txtObject){const s=new THREE.Box3;s.expandByObject(e._txtObject);let i=new THREE.Vector3(s.min.x,s.min.y,0),o=new THREE.Vector3(s.max.x,s.min.y,0);t.drawLine(i,o)}if(e._txtAspectRatio=-1,r&&t.setColor(r),e.drawConnectingLine){let s=n.clone().sub(o);if(s.length()>e.txtHeight+h){s.normalize();let i=n.clone().sub(s.clone().multiplyScalar(h)),r=o.clone().add(s.clone().multiplyScalar(e.txtHeight));t.setXData({type:"line"}),t.drawLine(i,r)}}}}),1==t.getType()){if(this.svg)t.setXData({type:"svg"}),t.drawEntity(this.svg);else if(this.svgPath.length>0&&this.isLoadFromPath){let e=this,i=t.getMxObject();MxThreeJS.loadSVG(this.svgPath,void 0,o=>{if(o){let r=o;if(r.boxSize)e.svgBoxSize=r.boxSize.clone();else{let t=(new THREE.Box3).setFromObject(o);e.svgBoxSize||(e.svgBoxSize=new THREE.Vector3),e.svgBoxSize.x=t.max.x-t.min.x,e.svgBoxSize.y=t.max.y-t.min.y}let[g,n]=e.calcVewSize(s);e.svgBoxSize&&(o.scale.x=g/e.svgBoxSize.x,o.scale.y=n/e.svgBoxSize.y),o.scale.z=o.scale.x,e.svgReverse&&(o.scale.y*=-1),e.svgMirror&&(o.scale.x*=-1),o.rotateZ(e.svgRotate),e.isSvgDirtyLocation=!0;let h=new THREE.Color(t.getColor()),a=0;o.traverse(function(t){t.material&&(t.material=t.material.clone(),t.material.transparent=!0,t.material.depthTest=!1,e.useSvgColor||(a<e.svgChildColor.length?t.material.color=new THREE.Color(e.svgChildColor[a]):t.material.color=h),a++)}),e.svg=o,e.setNeedUpdateDisplay(),i.updateDisplay()}else console.log("mx LoadSVG:"+e.svgPath+" failed");e.isLoadFromPath=!1})}}else t.drawLine(i,r),t.drawLine(r,o),t.drawLine(o,g),t.drawLine(g,i)}setSvgPath(t,s=!1){return __awaiter(this,void 0,void 0,function*(){this.svgPath=t,this.svg=null,this.isLoadFromPath=!0,this.svgBoxSize=null,s&&(yield MxThreeJS.loadSVG(t))})}getSvgPath(){return this.svgPath}setSvgPostion(t){this.svgPos=t.clone(),this.isSvgDirtyLocation=!0}getSvgPostion(){return this.svgPos}setSvgSize(t){this.svgSize=t,this.isSvgDirtyLocation=!0}getSvgSize(){return this.svgSize}setSvgAlignmentRatio(t){this.svgAlignmentRatio=t,this.isSvgDirtyLocation=!0}getSvgAlignmentRatio(){return this.svgAlignmentRatio}getText(t){return t<this.aryText.length?this.aryText[t]:null}addText(t){this.aryText.push(t)}getGripPoints(){let t=[];t.push(this.svgPos);let s=0;for(;s<this.aryText.length;s++){let e=this.aryText[s];if(e.move){let s=new THREE.Vector3(e.txtPos.x,e.txtPos.y,0);if(this.fixedSize){let t=MxFun.getCurrentDraw();e.txtPos.x>0?s.x=this.svgPos.x+t.screenCoordLong2Doc(e.txtPos.x):s.x=this.svgPos.x-t.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?s.y=this.svgPos.y+t.screenCoordLong2Doc(e.txtPos.y):s.y=this.svgPos.y-t.screenCoordLong2Doc(e.txtPos.y)}t.push(s)}}return t}moveGripPointsAt(t,s){if(0==t)this.svgPos.add(s),this.fixedSize||this.aryText.forEach(t=>{t.txtPos.add(s)});else if(t-1>=0&&t-1<this.aryText.length){let e=this.aryText[t-1];if(e.move)if(this.fixedSize){let t=MxFun.getCurrentDraw();e.txtPos.x+=t.docCoordLong2Screen(s.x),e.txtPos.y+=t.docCoordLong2Screen(s.y)}else e.txtPos.add(s)}return this.isSvgDirtyLocation=!0,!0}calcSvgPosition(t){if(!this.svg||!this.isSvgDirtyLocation)return;this.isSvgDirtyLocation=!1;let[s,e]=this.calcVewSize(t);this.svg.position.x=this.svgPos.x-s*this.svgAlignmentRatio.x-this.svgMargin.x*s,this.svg.position.y=this.svgPos.y-e*this.svgAlignmentRatio.y-this.svgMargin.y*e}dwgIn(t){this.onDwgIn(t),this.fixedSize=t.fixedSize,this.fixedSize?this.svg=null:t.type==MxType.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;let s=t.txts;return this.aryText=[],s.forEach(t=>{let s=new MxDbSVGText;s.txt=t.txt,s.txtHeight=t.txtHeight,s.txtPos.copy(t.txtPos),s.move=t.move,s.drawConnectingLine=t.drawConnectingLine,this.aryText.push(s)}),this.svgRotate=t.svgRotate,this.useSvgColor=t.useSvgColor,this.svgReverse=t.svgReverse,this.svgMirror=t.svgMirror,this.svgMargin=t.svgMargin,t.svgChildColor?this.svgChildColor=t.svgChildColor:this.svgChildColor=[],!0}dwgOut(t){return this.onDwgOut(t),t.type==MxType.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.forEach(s=>{let e={txtPos:s.txtPos,txt:s.txt,txtHeight:s.txtHeight,color:s.color,_txtAspectRatio:s._txtAspectRatio,move:s.move,drawConnectingLine:s.drawConnectingLine};t.txts.push(e)}),t.fixedSize=this.fixedSize,t.svgRotate=this.svgRotate,t.useSvgColor=this.useSvgColor,t.svgReverse=this.svgReverse,t.svgMirror=this.svgMirror,t.svgMargin=this.svgMargin,t.svgChildColor=this.svgChildColor,t}create(){return new MxDbSVG}transformBy(t){this.svgPos.applyMatrix4(t),this.isSvgDirtyLocation=!0,this.fixedSize||this.aryText.forEach(s=>{s.txtPos.applyMatrix4(t)})}getTypeName(){return"MxDbSVG"}setColor(t){if(super.setColor(t),this.svg){let t=new THREE.Color(this.color);this.svg.traverse(function(s){s.material&&(s.material.color=t)})}return this}setSvg(t){this.svg=t,this.isLoadFromPath=!1,this.svgBoxSize=null}calcSvgBoxSize(t){if(!this.svgBoxSize)if(t.boxSize)this.svgBoxSize=t.boxSize.clone();else{let s=(new THREE.Box3).setFromObject(t);this.svgBoxSize||(this.svgBoxSize=new THREE.Vector3),this.svgBoxSize.x=s.max.x-s.min.x,this.svgBoxSize.y=s.max.y-s.min.y}}reComputeSVG(){if(!this.svg)return;let t=this.getMxObject();if(!t)return;this.calcSvgBoxSize(this.svg);let[s,e]=this.calcVewSize(t);this.svgBoxSize&&(this.svg.scale.x=s/this.svgBoxSize.x,this.svg.scale.y=e/this.svgBoxSize.y),this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.svgMirror&&(this.svg.scale.x*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}onViewChange(){if(!this.fixedSize)return!1;let t=this.getMxObject();if(null==t)return!1;if(this.svg){this.calcSvgBoxSize(this.svg);let[s,e]=this.calcVewSize(t);this.svgBoxSize&&(this.svg.scale.x=s/this.svgBoxSize.x,this.svg.scale.y=e/this.svgBoxSize.y),this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.svgMirror&&(this.svg.scale.x*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}let s=this;return this.aryText.forEach(e=>{if(e._txtObject&&t){let 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=s.svgPos.x+t.screenCoordLong2Doc(e.txtPos.x):e._txtObject.position.x=s.svgPos.x-t.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?e._txtObject.position.y=s.svgPos.y+t.screenCoordLong2Doc(e.txtPos.y):e._txtObject.position.y=s.svgPos.y-t.screenCoordLong2Doc(e.txtPos.y),e._txtObject.updateMatrix())}}),!0}};
@@ -19,4 +19,8 @@ export default class MxDbSVGText {
19
19
  move: boolean;
20
20
  /** 文字移动到距图片远处,自动绘制一个连接线 */
21
21
  drawConnectingLine: boolean;
22
+ /** 字体样式 */
23
+ fontStyle: string;
24
+ /** 下划线 */
25
+ underline: boolean;
22
26
  }
@@ -1 +1 @@
1
- export default class MxDbSVGText{constructor(){this.txtPos=new THREE.Vector3,this.txt="",this.txtHeight=1,this.color=void 0,this._txtObject=null,this._txtAspectRatio=-1,this.move=!1,this.drawConnectingLine=!1}};
1
+ export default class MxDbSVGText{constructor(){this.txtPos=new THREE.Vector3,this.txt="",this.txtHeight=1,this.color=void 0,this._txtObject=null,this._txtAspectRatio=-1,this.move=!1,this.drawConnectingLine=!1,this.fontStyle="",this.underline=!1}};