mxdraw 0.1.139 → 0.1.141

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
- var __awaiter=this&&this.__awaiter||function(t,e,i,o){return new(i||(i=Promise))(function(s,h){function r(t){try{a(o.next(t))}catch(t){h(t)}}function n(t){try{a(o.throw(t))}catch(t){h(t)}}function a(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,n)}a((o=o.apply(t,e||[])).next())})};let _SpriteText;export function getSpriteTextColor(t){return t?t instanceof THREE.Color?t.getStyle():"number"==typeof t?new THREE.Color(t).getStyle():t:"#fff"};export function toCSSFont(t,e,i,o,s){let h=document.createElement("span");return h.style.font="1px serif",h.style.fontFamily=t,h.style.fontSize=`${e}px`,h.style.fontStyle=i,h.style.fontVariant=o,h.style.fontWeight=s,h.style.font};export function getSpriteTextClass(){if(!_SpriteText){class t extends THREE.Sprite{constructor(t){super(new THREE.SpriteMaterial);const{text:e,textHeight:i,color:o,backgroundColor:s,padding:h,borderWidth:r,borderRadius:n,borderColor:a,strokeWidth:d,strokeColor:l,fontFace:g,fontSize:f,fontWeight:c,textAlign:_,textShadowBlur:u,textShadowColor:x,textShadowOffsetX:S,textShadowOffsetY:C,angle:w,scale:p,underline:b,fontStyle:v,fontVariant:m}=t||{};this._text=`${e}`,this._textHeight=i||10,this._color=o,this._backgroundColor=s,this._padding=h||0,this._borderWidth=r||0,this._borderRadius=n||0,this._borderColor=a||"white",this._strokeWidth=d||0,this._strokeColor=l||"white",this._fontFace=g||"Arial",this._fontSize=f||90,this._fontWeight=(null===c||void 0===c?void 0:c.toString())||"normal",this._textAlign=_||"start",this._fontStyle=v||"normal",this._fontVariant=m||"normal",this._textShadowBlur=u||0,this._textShadowColor=x,this._textShadowOffsetX=S||0,this._textShadowOffsetY=C||0,this._angle=w||0,this._textScale=p||1,this._underline=b||!1,this._canvas=document.createElement("canvas"),this._genCanvas()}get text(){return this._text}set text(t){this._text=t,this._genCanvas()}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t,this._genCanvas()}get color(){return this._color}set color(t){this._color=t,this._genCanvas()}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){this._backgroundColor=t,this._genCanvas()}get padding(){return this._padding}set padding(t){this._padding=t,this._genCanvas()}get borderWidth(){return this._borderWidth}set borderWidth(t){this._borderWidth=t,this._genCanvas()}get borderRadius(){return this._borderRadius}set borderRadius(t){this._borderRadius=t,this._genCanvas()}get borderColor(){return this._borderColor}set borderColor(t){this._borderColor=t,this._genCanvas()}get fontFace(){return this._fontFace}set fontFace(t){this._fontFace=t,this._genCanvas()}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize=t,this._genCanvas()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this._genCanvas()}get strokeWidth(){return this._strokeWidth}set strokeWidth(t){this._strokeWidth=t,this._genCanvas()}get strokeColor(){return this._strokeColor}set strokeColor(t){this._strokeColor=t,this._genCanvas()}get textAlign(){return this._textAlign}set textAlign(t){this._textAlign=t,this._genCanvas()}get textShadowBlur(){return this._textShadowBlur}set textShadowBlur(t){this._textShadowBlur=t,this._genCanvas()}get textShadowColor(){return this._textShadowColor}set textShadowColor(t){this._textShadowColor=t,this._genCanvas()}get textShadowOffsetX(){return this._textShadowOffsetX}set textShadowOffsetX(t){this._textShadowOffsetX=t,this._genCanvas()}get textShadowOffsetY(){return this._textShadowOffsetY}set textShadowOffsetY(t){this._textShadowOffsetY=t,this._genCanvas()}get angle(){return this._angle}set angle(t){this._angle=t,this._genCanvas()}get textScale(){return this._textScale}set textScale(t){this._textScale=t,this._genCanvas()}get underline(){return this._underline}set underline(t){this._underline=t,this._genCanvas()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t,this._genCanvas()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this._genCanvas()}_genCanvas(){const t=this._canvas,e=t.getContext("2d"),i=Array.isArray(this.borderWidth)?this.borderWidth:[this.borderWidth,this.borderWidth],o=i.map(t=>t*this.fontSize*.1),s=(Array.isArray(this.borderRadius)?this.borderRadius:[this.borderRadius,this.borderRadius,this.borderRadius,this.borderRadius]).map(t=>t*this.fontSize*.1),h=Array.isArray(this.padding)?this.padding:[this.padding,this.padding],r=h.map(t=>t*this.fontSize*.1),n=this.text.split("\n"),a=this.font;e.font=a;const d=Math.max(...n.map(t=>e.measureText(t).width)),l=4*this.strokeWidth+(this.underline?this.fontSize/15*4:this.fontSize/15),g=(this.fontSize+l)*n.length;if(t.width=d+2*o[0]+2*r[0],t.height=g+2*o[1]+2*r[1],this.borderWidth){if(e.strokeStyle=getSpriteTextColor(this.borderColor),o[0]){const i=o[0]/2;e.lineWidth=o[0],e.beginPath(),e.moveTo(i,s[0]),e.lineTo(i,t.height-s[3]),e.moveTo(t.width-i,s[1]),e.lineTo(t.width-i,t.height-s[2]),e.stroke()}if(o[1]){const i=o[1]/2;e.lineWidth=o[1],e.beginPath(),e.moveTo(Math.max(o[0],s[0]),i),e.lineTo(t.width-Math.max(o[0],s[1]),i),e.moveTo(Math.max(o[0],s[3]),t.height-i),e.lineTo(t.width-Math.max(o[0],s[2]),t.height-i),e.stroke()}if(this.borderRadius){const i=Math.max(...o),h=i/2;e.lineWidth=i,e.beginPath(),[!!s[0]&&[s[0],h,h,s[0]],!!s[1]&&[t.width-s[1],t.width-h,h,s[1]],!!s[2]&&[t.width-s[2],t.width-h,t.height-h,t.height-s[2]],!!s[3]&&[s[3],h,t.height-h,t.height-s[3]]].filter(t=>t).forEach(t=>{const[i,o,s,h]=t;e.moveTo(i,s),e.quadraticCurveTo(o,s,o,h)}),e.stroke()}}this.backgroundColor&&(e.fillStyle=getSpriteTextColor(this.backgroundColor),this.borderRadius?(e.beginPath(),e.moveTo(o[0],s[0]),[[o[0],s[0],t.width-s[1],o[1],o[1],o[1]],[t.width-o[0],t.width-o[0],t.width-o[0],o[1],s[1],t.height-s[2]],[t.width-o[0],t.width-s[2],s[3],t.height-o[1],t.height-o[1],t.height-o[1]],[o[0],o[0],o[0],t.height-o[1],t.height-s[3],s[0]]].forEach(([t,i,o,s,h,r])=>{e.quadraticCurveTo(t,s,i,h),e.lineTo(o,r)}),e.closePath(),e.fill()):e.fillRect(o[0],o[1],t.width-2*o[0],t.height-2*o[1])),e.translate(o[0],o[1]),e.translate(r[0],r[1]),e.font=a,e.fillStyle=getSpriteTextColor(this.color),e.textBaseline="bottom",e.shadowBlur=this.textShadowBlur,e.shadowColor=new THREE.Color(this.textShadowColor).getStyle(),e.shadowOffsetX=this.textShadowOffsetX,e.shadowOffsetY=this.textShadowOffsetY;const f=this.strokeWidth>0;f&&(e.lineWidth=this.strokeWidth*this.fontSize/10,e.strokeStyle=getSpriteTextColor(this.strokeColor));const c="center"===this.textAlign,_="start"===this.textAlign||"left"===this.textAlign;n.forEach((t,i)=>__awaiter(this,void 0,void 0,function*(){let o=c?2:1;const s=e.measureText(t).width,h=_?0:(d-s)/o,r=(i+1)*(this.fontSize+l);f&&e.strokeText(t,h,r),e.fillText(t,h,r),this.underline&&e.fillRect(h,r,s,this.fontSize/15)})),this.material.map&&this.material.map.dispose();const u=this.material.map=new THREE.Texture(t);u.minFilter=THREE.LinearFilter,u.needsUpdate=!0;const x=this.textHeight*n.length+2*i[1]+2*h[1],S=x*t.width/t.height;this.scale.set(S,x,this.scale.z),this.material.rotation=this.angle,this.scale.applyMatrix4((new THREE.Matrix4).makeScale(this.textScale,this.textScale,1))}clone(){return new(0,this.constructor)(this.text,this.textHeight,this.color).copy(this)}copy(t){return THREE.Sprite.prototype.copy.call(this,t),this.color=t.color,this.backgroundColor=t.backgroundColor,this.padding=t.padding,this.borderWidth=t.borderWidth,this.borderColor=t.borderColor,this.fontFace=t.fontFace,this.fontSize=t.fontSize,this.fontWeight=t.fontWeight,this.strokeWidth=t.strokeWidth,this.strokeColor=t.strokeColor,this.textAlign=t.textAlign,this.textShadowBlur=t.textShadowBlur,this.textShadowColor=t.textShadowColor,this.textShadowOffsetX=t.textShadowOffsetX,this.textShadowOffsetY=t.textShadowOffsetY,this.angle=t.angle,this.textScale=t.textScale,this}get font(){return toCSSFont(this.fontFace,this.fontSize,this.fontStyle,this.fontVariant,this.fontWeight)}checkFontFace(){try{const{fontFace:t}=this;return document.fonts.check(t)}catch(t){}return!0}loadFontFace(){return __awaiter(this,void 0,void 0,function*(){try{const{fontFace:t}=this;yield document.fonts.load(t)}catch(t){}})}dispose(){var t;null===(t=this.material.map)||void 0===t||t.dispose(),this.material.dispose(),this.geometry.dispose(),this.dispatchEvent({type:"dispose"})}}_SpriteText=t}return _SpriteText};
1
+ var __awaiter=this&&this.__awaiter||function(t,e,i,o){return new(i||(i=Promise))(function(s,h){function r(t){try{a(o.next(t))}catch(t){h(t)}}function n(t){try{a(o.throw(t))}catch(t){h(t)}}function a(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,n)}a((o=o.apply(t,e||[])).next())})};let _SpriteText;export function getSpriteTextColor(t){return t?t instanceof THREE.Color?t.getStyle():"number"==typeof t?new THREE.Color(t).getStyle():t:"#fff"};export function toCSSFont(t,e,i,o,s){let h=document.createElement("span");return h.style.font="1px serif",h.style.fontFamily=t,h.style.fontSize=`${e}px`,h.style.fontStyle=i,h.style.fontVariant=o,h.style.fontWeight=s,h.style.font};export function getSpriteTextClass(){if(!_SpriteText){class t extends THREE.Sprite{constructor(t){super(new THREE.SpriteMaterial);const{text:e,textHeight:i,color:o,backgroundColor:s,padding:h,borderWidth:r,borderRadius:n,borderColor:a,strokeWidth:d,strokeColor:l,fontFace:g,fontSize:f,fontWeight:c,textAlign:_,textShadowBlur:u,textShadowColor:x,textShadowOffsetX:S,textShadowOffsetY:C,angle:w,scale:p,underline:b,fontStyle:v,fontVariant:m}=t||{};this._text=`${e}`,this._textHeight=i||10,this._color=o,this._backgroundColor=s,this._padding=h||0,this._borderWidth=r||0,this._borderRadius=n||0,this._borderColor=a||"white",this._strokeWidth=d||0,this._strokeColor=l||"white",this._fontFace=g||"Arial",this._fontSize=f||90,this._fontWeight=(null===c||void 0===c?void 0:c.toString())||"normal",this._textAlign=_||"start",this._fontStyle=v||"normal",this._fontVariant=m||"normal",this._textShadowBlur=u||0,this._textShadowColor=x,this._textShadowOffsetX=S||0,this._textShadowOffsetY=C||0,this._angle=w||0,this._textScale=p||1,this._underline=b||!1,this._canvas=document.createElement("canvas"),this._genCanvas()}get text(){return this._text}set text(t){this._text=t,this._genCanvas()}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t,this._genCanvas()}get color(){return this._color}set color(t){this._color=t,this._genCanvas()}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){this._backgroundColor=t,this._genCanvas()}get padding(){return this._padding}set padding(t){this._padding=t,this._genCanvas()}get borderWidth(){return this._borderWidth}set borderWidth(t){this._borderWidth=t,this._genCanvas()}get borderRadius(){return this._borderRadius}set borderRadius(t){this._borderRadius=t,this._genCanvas()}get borderColor(){return this._borderColor}set borderColor(t){this._borderColor=t,this._genCanvas()}get fontFace(){return this._fontFace}set fontFace(t){this._fontFace=t,this._genCanvas()}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize=t,this._genCanvas()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this._genCanvas()}get strokeWidth(){return this._strokeWidth}set strokeWidth(t){this._strokeWidth=t,this._genCanvas()}get strokeColor(){return this._strokeColor}set strokeColor(t){this._strokeColor=t,this._genCanvas()}get textAlign(){return this._textAlign}set textAlign(t){this._textAlign=t,this._genCanvas()}get textShadowBlur(){return this._textShadowBlur}set textShadowBlur(t){this._textShadowBlur=t,this._genCanvas()}get textShadowColor(){return this._textShadowColor}set textShadowColor(t){this._textShadowColor=t,this._genCanvas()}get textShadowOffsetX(){return this._textShadowOffsetX}set textShadowOffsetX(t){this._textShadowOffsetX=t,this._genCanvas()}get textShadowOffsetY(){return this._textShadowOffsetY}set textShadowOffsetY(t){this._textShadowOffsetY=t,this._genCanvas()}get angle(){return this._angle}set angle(t){this._angle=t,this._genCanvas()}get textScale(){return this._textScale}set textScale(t){this._textScale=t,this._genCanvas()}get underline(){return this._underline}set underline(t){this._underline=t,this._genCanvas()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t,this._genCanvas()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this._genCanvas()}_genCanvas(){const t=this._canvas,e=t.getContext("2d"),i=Array.isArray(this.borderWidth)?this.borderWidth:[this.borderWidth,this.borderWidth],o=i.map(t=>t*this.fontSize*.1),s=(Array.isArray(this.borderRadius)?this.borderRadius:[this.borderRadius,this.borderRadius,this.borderRadius,this.borderRadius]).map(t=>t*this.fontSize*.1),h=Array.isArray(this.padding)?this.padding:[this.padding,this.padding],r=h.map(t=>t*this.fontSize*.1),n=this.text.split("\n"),a=this.font;e.font=a;const d=Math.max(...n.map(t=>e.measureText(t).width)),l=4*this.strokeWidth+(this.underline?this.fontSize/15*4:this.fontSize/15),g=(this.fontSize+l)*n.length;if(t.width=d+2*o[0]+2*r[0],t.height=g+2*o[1]+2*r[1],this.borderWidth){if(e.strokeStyle=getSpriteTextColor(this.borderColor),o[0]){const i=o[0]/2;e.lineWidth=o[0],e.beginPath(),e.moveTo(i,s[0]),e.lineTo(i,t.height-s[3]),e.moveTo(t.width-i,s[1]),e.lineTo(t.width-i,t.height-s[2]),e.stroke()}if(o[1]){const i=o[1]/2;e.lineWidth=o[1],e.beginPath(),e.moveTo(Math.max(o[0],s[0]),i),e.lineTo(t.width-Math.max(o[0],s[1]),i),e.moveTo(Math.max(o[0],s[3]),t.height-i),e.lineTo(t.width-Math.max(o[0],s[2]),t.height-i),e.stroke()}if(this.borderRadius){const i=Math.max(...o),h=i/2;e.lineWidth=i,e.beginPath(),[!!s[0]&&[s[0],h,h,s[0]],!!s[1]&&[t.width-s[1],t.width-h,h,s[1]],!!s[2]&&[t.width-s[2],t.width-h,t.height-h,t.height-s[2]],!!s[3]&&[s[3],h,t.height-h,t.height-s[3]]].filter(t=>t).forEach(t=>{const[i,o,s,h]=t;e.moveTo(i,s),e.quadraticCurveTo(o,s,o,h)}),e.stroke()}}this.backgroundColor&&(e.fillStyle=getSpriteTextColor(this.backgroundColor),this.borderRadius?(e.beginPath(),e.moveTo(o[0],s[0]),[[o[0],s[0],t.width-s[1],o[1],o[1],o[1]],[t.width-o[0],t.width-o[0],t.width-o[0],o[1],s[1],t.height-s[2]],[t.width-o[0],t.width-s[2],s[3],t.height-o[1],t.height-o[1],t.height-o[1]],[o[0],o[0],o[0],t.height-o[1],t.height-s[3],s[0]]].forEach(([t,i,o,s,h,r])=>{e.quadraticCurveTo(t,s,i,h),e.lineTo(o,r)}),e.closePath(),e.fill()):e.fillRect(o[0],o[1],t.width-2*o[0],t.height-2*o[1])),e.translate(o[0],o[1]),e.translate(r[0],r[1]),e.font=a,e.fillStyle=getSpriteTextColor(this.color),e.textBaseline="bottom",e.shadowBlur=this.textShadowBlur,e.shadowColor=new THREE.Color(this.textShadowColor).getStyle(),e.shadowOffsetX=this.textShadowOffsetX,e.shadowOffsetY=this.textShadowOffsetY;const f=this.strokeWidth>0;f&&(e.lineWidth=this.strokeWidth*this.fontSize/10,e.strokeStyle=getSpriteTextColor(this.strokeColor));const c="center"===this.textAlign,_="start"===this.textAlign||"left"===this.textAlign;n.forEach((i,o)=>__awaiter(this,void 0,void 0,function*(){let s=c?2:1;const h=e.measureText(i).width,r=_?0:(d-h)/s,n=(o+1)*(this.fontSize+l);f&&e.strokeText(i,r,n),e.fillText(i,r,n),this.underline&&e.fillRect(r,t.height-this.fontSize/25,h,this.fontSize/25)})),this.material.map&&this.material.map.dispose();const u=this.material.map=new THREE.Texture(t);u.minFilter=THREE.LinearFilter,u.needsUpdate=!0;const x=this.textHeight*n.length+2*i[1]+2*h[1],S=x*t.width/t.height;this.scale.set(S,x,this.scale.z),this.material.rotation=this.angle,this.scale.applyMatrix4((new THREE.Matrix4).makeScale(this.textScale,this.textScale,1))}clone(){return new(0,this.constructor)(this.text,this.textHeight,this.color).copy(this)}copy(t){return THREE.Sprite.prototype.copy.call(this,t),this.color=t.color,this.backgroundColor=t.backgroundColor,this.padding=t.padding,this.borderWidth=t.borderWidth,this.borderColor=t.borderColor,this.fontFace=t.fontFace,this.fontSize=t.fontSize,this.fontWeight=t.fontWeight,this.strokeWidth=t.strokeWidth,this.strokeColor=t.strokeColor,this.textAlign=t.textAlign,this.textShadowBlur=t.textShadowBlur,this.textShadowColor=t.textShadowColor,this.textShadowOffsetX=t.textShadowOffsetX,this.textShadowOffsetY=t.textShadowOffsetY,this.angle=t.angle,this.textScale=t.textScale,this}get font(){return toCSSFont(this.fontFace,this.fontSize,this.fontStyle,this.fontVariant,this.fontWeight)}checkFontFace(){try{const{fontFace:t}=this;return document.fonts.check(t)}catch(t){}return!0}loadFontFace(){return __awaiter(this,void 0,void 0,function*(){try{const{fontFace:t}=this;yield document.fonts.load(t)}catch(t){}})}dispose(){var t;null===(t=this.material.map)||void 0===t||t.dispose(),this.material.dispose(),this.geometry.dispose(),this.dispatchEvent({type:"dispose"})}}_SpriteText=t}return _SpriteText};
@@ -46,7 +46,7 @@ export interface MxDrawObjectType {
46
46
  clearMxCurrentSelect(): boolean;
47
47
  getMxEntityUserObject(id: number): MxDbEntity;
48
48
  findMxEntityAtPoint(ptMouse: THREE.Vector3, isDocCoord?: boolean, retWordDrawXDataCall?: (id: number, data: any) => void): Array<MxDbEntity>;
49
- setMouseMiddlePan(isPan: boolean): void;
49
+ setMouseMiddlePan(isPan: boolean | number): void;
50
50
  resetThreeJSControls(): void;
51
51
  getAllMxEntity(): Array<MxDbEntity>;
52
52
  enableZoom(isEnable: boolean): void;
@@ -558,7 +558,10 @@ export default class MxDrawObject {
558
558
  getAllMxEntity(): Array<MxDbEntity>;
559
559
  /**
560
560
  * 设置鼠标中键移动视区。
561
- * @param isPan 设置是否可以鼠标中键移动视区
561
+ * @param iPan 设置是否可以鼠标中键移动视区,
562
+ * iPan = 0,中键不移动视区,左键移动
563
+ * iPan = 1,中键移动视区,左键不移动
564
+ * iPan = 2,中键移动视区,左键移动视区
562
565
  * @returns
563
566
  * @example
564
567
  * ```typescript
@@ -566,7 +569,7 @@ export default class MxDrawObject {
566
569
  *
567
570
  * ```
568
571
  */
569
- setMouseMiddlePan(isPan: boolean): void;
572
+ setMouseMiddlePan(iPan: boolean | number): void;
570
573
  /**
571
574
  *重新设置ThreeJS Controls状态.
572
575
  * @returns