mxdraw 0.1.110 → 0.1.112

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.
Files changed (53) hide show
  1. package/README.md +17 -17
  2. package/dist/index.d.ts +284 -112
  3. package/dist/lib/MxModule/McEdGetPointWorldDrawObject/index.js +1 -1
  4. package/dist/lib/MxModule/McGeTool/index.js +1 -1
  5. package/dist/lib/MxModule/McGiWorldDraw/index.d.ts +3 -2
  6. package/dist/lib/MxModule/MrxDbgUiPrPoint/index.js +1 -1
  7. package/dist/lib/MxModule/MrxDbgUtils/index.js +1 -1
  8. package/dist/lib/MxModule/MxDb2LineAngularDimension/index.d.ts +49 -11
  9. package/dist/lib/MxModule/MxDb2LineAngularDimension/index.js +1 -1
  10. package/dist/lib/MxModule/MxDbAlignedDimension/index.d.ts +35 -1
  11. package/dist/lib/MxModule/MxDbAlignedDimension/index.js +1 -1
  12. package/dist/lib/MxModule/MxDbAnyLine/index.d.ts +5 -1
  13. package/dist/lib/MxModule/MxDbAnyLine/index.js +1 -1
  14. package/dist/lib/MxModule/MxDbCloudLine/index.d.ts +2 -2
  15. package/dist/lib/MxModule/MxDbCloudLine/index.js +1 -1
  16. package/dist/lib/MxModule/MxDbEntity/index.d.ts +47 -25
  17. package/dist/lib/MxModule/MxDbEntity/index.js +1 -1
  18. package/dist/lib/MxModule/MxDbGradientLine/index.d.ts +62 -0
  19. package/dist/lib/MxModule/MxDbGradientLine/index.js +1 -0
  20. package/dist/lib/MxModule/MxDbLeadComment/index.d.ts +0 -1
  21. package/dist/lib/MxModule/MxDbLeadComment/index.js +1 -1
  22. package/dist/lib/MxModule/MxDbSVG/index.d.ts +2 -2
  23. package/dist/lib/MxModule/MxDbSVG/index.js +1 -1
  24. package/dist/lib/MxModule/MxDrawObject/index.d.ts +20 -1
  25. package/dist/lib/MxModule/MxDrawObject/index.js +1 -1
  26. package/dist/lib/MxModule/MxFun/index.d.ts +7 -7
  27. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.d.ts +13 -7
  28. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js +1 -1
  29. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +1 -1
  30. package/dist/lib/MxModule/MxType/index.d.ts +13 -12
  31. package/dist/lib/MxModule/MxType/index.js +1 -1
  32. package/dist/lib/MxModule/Mxassembly/index.js +1 -1
  33. package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +1 -1
  34. package/dist/lib/MxModule/store/{PubsubClass.d.ts → Pubsub.d.ts} +0 -0
  35. package/dist/lib/MxModule/store/{PubsubClass.js → Pubsub.js} +0 -0
  36. package/dist/lib/MxModule/store/{StoreClass.d.ts → Store.d.ts} +1 -1
  37. package/dist/lib/MxModule/store/Store.js +1 -0
  38. package/dist/lib/MxModule/store/index.d.ts +11 -2
  39. package/dist/lib/MxModule/store/index.js +1 -1
  40. package/dist/lib/MxModule/useCanvasResizeListener/index.js +1 -1
  41. package/dist/lib/doc.d.ts +3 -1
  42. package/dist/lib/doc.js +1 -1
  43. package/dist/lib/index.js +1 -1
  44. package/dist/lib/mxdraw.d.ts +1 -0
  45. package/dist/lib/mxdraw.js +1 -1
  46. package/dist/lib/test/jestsetup.d.ts +0 -0
  47. package/dist/lib/test/jestsetup.js +1 -0
  48. package/dist/mxdraw.es.js +1 -0
  49. package/dist/mxdraw.umd.js +1 -1
  50. package/package.json +6 -1
  51. package/dist/lib/MxModule/store/StoreClass.js +0 -1
  52. package/dist/lib/MxModule/store/store.d.ts +0 -11
  53. package/dist/lib/MxModule/store/store.js +0 -1
@@ -1 +1 @@
1
- import store from"../store/store";export default class McEdGetPointWorldDrawObject{constructor(){var t;this._McEdGetPointWorldDraw=new(null===(t=store.state.MxFun)||void 0===t?void 0:t.getMxJigCmdManager().McEdGetPointWorldDrawObjectClass()),this._get=(()=>this._McEdGetPointWorldDraw)}drawCircle(t,r){return this._McEdGetPointWorldDraw.drawCircle(t,r)}drawLine(t,r){return this._McEdGetPointWorldDraw.drawLine(t,r)}drawEntity(t,r){return this._McEdGetPointWorldDraw.drawEntity(t,r)}drawText(t,r,e,o){return this._McEdGetPointWorldDraw.drawText(t,r,e,o)}setDraw(t){return this._McEdGetPointWorldDraw.setDraw(t)}setColor(t){return this._McEdGetPointWorldDraw.setColor(t)}getColor(){return this._McEdGetPointWorldDraw.getColor()}drawCustomEntity(t,r){return this._McEdGetPointWorldDraw.drawCustomEntity(t,r)}};
1
+ import store from"../store";export default class McEdGetPointWorldDrawObject{constructor(){var t;this._McEdGetPointWorldDraw=new(null===(t=store.state.MxFun)||void 0===t?void 0:t.getMxJigCmdManager().McEdGetPointWorldDrawObjectClass()),this._get=(()=>this._McEdGetPointWorldDraw)}drawCircle(t,r){return this._McEdGetPointWorldDraw.drawCircle(t,r)}drawLine(t,r){return this._McEdGetPointWorldDraw.drawLine(t,r)}drawEntity(t,r){return this._McEdGetPointWorldDraw.drawEntity(t,r)}drawText(t,r,e,o){return this._McEdGetPointWorldDraw.drawText(t,r,e,o)}setDraw(t){return this._McEdGetPointWorldDraw.setDraw(t)}setColor(t){return this._McEdGetPointWorldDraw.setColor(t)}getColor(){return this._McEdGetPointWorldDraw.getColor()}drawCustomEntity(t,r){return this._McEdGetPointWorldDraw.drawCustomEntity(t,r)}};
@@ -1 +1 @@
1
- import Mxassembly from"../Mxassembly";import store from"../store/store";class McGeToolClass{constructor(){this.mxgeTool=null}initImp(){this.mxgeTool||store.state.Mxassembly&&(this.mxgeTool=new store.state.Mxassembly.McGeTool)}calcArea(e){if(this.initImp(),e instanceof Array){let o=Mxassembly.NewMcGePoint3dArray(e);return this.mxgeTool.calcArea(o)}return this.mxgeTool.calcArea(e)}pointInPolyline(e,o){this.initImp();let t=o;o instanceof Array&&(t=Mxassembly.NewMcGePoint3dArray(o));let s=Mxassembly.NewMcGePoint3d(e.x,e.y,e.z);return this.mxgeTool.pointInPolyline(s,t)}}const McGeTool=new McGeToolClass;export default McGeTool;
1
+ import Mxassembly from"../Mxassembly";import store from"../store";class McGeToolClass{constructor(){this.mxgeTool=null}initImp(){this.mxgeTool||store.state.Mxassembly&&(this.mxgeTool=new store.state.Mxassembly.McGeTool)}calcArea(e){if(this.initImp(),e instanceof Array){let o=Mxassembly.NewMcGePoint3dArray(e);return this.mxgeTool.calcArea(o)}return this.mxgeTool.calcArea(e)}pointInPolyline(e,o){this.initImp();let t=o;o instanceof Array&&(t=Mxassembly.NewMcGePoint3dArray(o));let s=Mxassembly.NewMcGePoint3d(e.x,e.y,e.z);return this.mxgeTool.pointInPolyline(s,t)}}const McGeTool=new McGeToolClass;export default McGeTool;
@@ -2,6 +2,7 @@
2
2
  import McGiWorldDrawType from '../McGiWorldDrawType';
3
3
  import MxDbEntity from '../MxDbEntity';
4
4
  import MxDrawObject from '../MxDrawObject';
5
+ import { UnstableColor } from '../MxType';
5
6
  /**
6
7
  * McGiWorldDraw 用于构建一个动态绘制回调对象的规范接口
7
8
  * @abstract 是 {@link MxDbEntity.worldDraw }必须实现的抽象回调方法中的回调对象 通过回调对象完成一些动态绘制任务
@@ -51,7 +52,7 @@ export default interface McGiWorldDraw {
51
52
  * ```
52
53
  *
53
54
  */
54
- setColor(iColor: number | string | THREE.Color): void;
55
+ setColor(iColor: UnstableColor): void;
55
56
  /**
56
57
  * 返回绘制颜色
57
58
  * @returns
@@ -104,7 +105,7 @@ export default interface McGiWorldDraw {
104
105
  * ```
105
106
  *
106
107
  */
107
- drawLines(points: THREE.Vector3[]): void;
108
+ drawLines(points: THREE.Vector3[] | THREE.Vector2[]): void;
108
109
  /**
109
110
  * 根据几何数据绘制直线
110
111
  * @param points 点数组
@@ -1 +1 @@
1
- import McEdGetPointWorldDrawObject from"../McEdGetPointWorldDrawObject";import store from"../store/store";let _MrxDbgUiPrPoint;export default class MrxDbgUiPrPoint{constructor(){var r;_MrxDbgUiPrPoint=new(null===(r=store.state.MxFun)||void 0===r?void 0:r.getMxJigCmdManager().getMrxDbgUiPrPointClass())}keyWords(){return _MrxDbgUiPrPoint.keyWords()}setKeyWords(r){return _MrxDbgUiPrPoint.setKeyWords(r)}message(){return _MrxDbgUiPrPoint.message()}setMessage(r){return _MrxDbgUiPrPoint.setMessage(r)}keyWordPicked(){return _MrxDbgUiPrPoint.keyWordPicked()}isKeyWordPicked(r){return _MrxDbgUiPrPoint.isKeyWordPicked(r)}setUserDraw(r){if("function"!=typeof r)return _MrxDbgUiPrPoint.setUserDraw(r._get?r._get():r);{const e=new McEdGetPointWorldDrawObject;e.setDraw(r),_MrxDbgUiPrPoint.setUserDraw(e._get())}}value(){return _MrxDbgUiPrPoint.value()}valueDocCoord(){return _MrxDbgUiPrPoint.valueDocCoord()}basePt(){return _MrxDbgUiPrPoint.basePt()}setBasePt(r){return _MrxDbgUiPrPoint.setBasePt(r)}setUseBasePt(r){return _MrxDbgUiPrPoint.setUseBasePt(r)}go(r){return r?(_MrxDbgUiPrPoint.go(r),new Promise((r,e)=>{r(null)})):new Promise((r,e)=>{_MrxDbgUiPrPoint.go(e=>{r(0!=e?null:_MrxDbgUiPrPoint.value())})})}goWhile(r,e){return _MrxDbgUiPrPoint.goWhile(r,e)}drawReserve(r){return _MrxDbgUiPrPoint.drawReserve(r)}setInputToucheType(r){return _MrxDbgUiPrPoint.setInputToucheType(r)}getInputToucheType(){return _MrxDbgUiPrPoint.getInputToucheType()}};
1
+ import McEdGetPointWorldDrawObject from"../McEdGetPointWorldDrawObject";import store from"../store";let _MrxDbgUiPrPoint;export default class MrxDbgUiPrPoint{constructor(){var r;_MrxDbgUiPrPoint=new(null===(r=store.state.MxFun)||void 0===r?void 0:r.getMxJigCmdManager().getMrxDbgUiPrPointClass())}keyWords(){return _MrxDbgUiPrPoint.keyWords()}setKeyWords(r){return _MrxDbgUiPrPoint.setKeyWords(r)}message(){return _MrxDbgUiPrPoint.message()}setMessage(r){return _MrxDbgUiPrPoint.setMessage(r)}keyWordPicked(){return _MrxDbgUiPrPoint.keyWordPicked()}isKeyWordPicked(r){return _MrxDbgUiPrPoint.isKeyWordPicked(r)}setUserDraw(r){if("function"!=typeof r)return _MrxDbgUiPrPoint.setUserDraw(r._get?r._get():r);{const e=new McEdGetPointWorldDrawObject;e.setDraw(r),_MrxDbgUiPrPoint.setUserDraw(e._get())}}value(){return _MrxDbgUiPrPoint.value()}valueDocCoord(){return _MrxDbgUiPrPoint.valueDocCoord()}basePt(){return _MrxDbgUiPrPoint.basePt()}setBasePt(r){return _MrxDbgUiPrPoint.setBasePt(r)}setUseBasePt(r){return _MrxDbgUiPrPoint.setUseBasePt(r)}go(r){return r?(_MrxDbgUiPrPoint.go(r),new Promise((r,e)=>{r(null)})):new Promise((r,e)=>{_MrxDbgUiPrPoint.go(e=>{r(0!=e?null:_MrxDbgUiPrPoint.value())})})}goWhile(r,e){return _MrxDbgUiPrPoint.goWhile(r,e)}drawReserve(r){return _MrxDbgUiPrPoint.drawReserve(r)}setInputToucheType(r){return _MrxDbgUiPrPoint.setInputToucheType(r)}getInputToucheType(){return _MrxDbgUiPrPoint.getInputToucheType()}};
@@ -1 +1 @@
1
- import MxFun from"../MxFun";import store from"../store/store";class MrxDbgUtilsClass{constructor(){this.imp=null}initImp(){if(!this.imp&&store.state.MxFun){let t=store.state.MxFun;this.imp=new t.getMrxDbgUtilsClass}}findEntAtPoint(t,s=null,i){return this.initImp(),i||(i=MxFun.getCurrentDraw()),this.imp.findEntAtPoint(i,t,s)}selectEnt(t,s){return this.initImp(),this.imp.selectEnt(t)}}const MrxDbgUtils=new MrxDbgUtilsClass;export default MrxDbgUtils;
1
+ import MxFun from"../MxFun";import store from"../store";class MrxDbgUtilsClass{constructor(){this.imp=null}initImp(){if(!this.imp&&store.state.MxFun){let t=store.state.MxFun;this.imp=new t.getMrxDbgUtilsClass}}findEntAtPoint(t,i=null,s){return this.initImp(),s||(s=MxFun.getCurrentDraw()),this.imp.findEntAtPoint(s,t,i)}selectEnt(t,i){return this.initImp(),this.imp.selectEnt(t)}}const MrxDbgUtils=new MrxDbgUtilsClass;export default MrxDbgUtils;
@@ -1,21 +1,59 @@
1
- /** @module MxDb2LineAngularDimension*/
2
1
  import McGiWorldDraw from '../McGiWorldDraw';
3
2
  import MxDbEntity from '../MxDbEntity';
4
- /**
5
- * MxDb2LineAngularDimension
6
- * 显示角度测量的图形
7
- */
3
+ import { MxColorType, UnstableColor } from '../MxType';
8
4
  export default class MxDb2LineAngularDimension extends MxDbEntity {
9
- point1: THREE.Vector3;
10
- point2: THREE.Vector3;
11
- point3: THREE.Vector3;
5
+ /**
6
+ * MxDb2LineAngularDimension
7
+ * 显示角度测量的图形
8
+ * @param options.points [point1(起始点)、point2(角顶点)、point3(结束点)]
9
+ * @param options.colors [起始线段颜色, 结束线段颜色, 标注角度圆弧颜色, 文字标注的角度颜色]
10
+ * @example
11
+ * ``` typescript
12
+ * const draw = Mx.MxFun.getCurrentDraw();
13
+ * const points = [ getPoint.value(),
14
+ * getPoint.value().add(new THREE.Vector3(8880, 0, 0)),
15
+ * getPoint.value().add(new THREE.Vector3(0, 6666, 0)),
16
+ * ]
17
+ * const colors = ['#F00880','#00ff1a', void 0, 0XFF0000]
18
+ * const obj = new Mx.MxDb2LineAngularDimension().setPoints(points).setColor(colors).setLineWidth(6)
19
+ * draw.addMxEntity(obj)
20
+ * ```
21
+ **/
22
+ constructor(options?: {
23
+ /** 传入三个位置THREE向量 分别对应 属性: point1(起始点)、point2(角顶点)、point3(结束点) 计算角度 */
24
+ points?: THREE.Vector3[];
25
+ /** colors 各标注的颜色设置:
26
+ * [起始线段颜色, 结束线段颜色, 标注角度圆弧颜色, 文字标注的角度颜色]
27
+ * 某一项为null或undefined采用绘制颜色 */
28
+ colors?: UnstableColor[];
29
+ });
30
+ point1: import("three").Vector3;
31
+ point2: import("three").Vector3;
32
+ point3: import("three").Vector3;
33
+ /**
34
+ * colors 各标注的颜色设置:
35
+ * [起始线段颜色, 结束线段颜色, 标注角度圆弧颜色, 文字标注的角度颜色]
36
+ * 某一项为null或undefined采用绘制颜色
37
+ * */
38
+ colors: UnstableColor[];
12
39
  private calculateLineAngle;
40
+ /**
41
+ * 设置point1 、 point2、point3 向量位置
42
+ * @param { THREE.Vector3[] } points
43
+ */
44
+ setPoints(points: THREE.Vector3[]): this;
45
+ /**
46
+ * 设置颜色组合
47
+ * @param colors [起始线段颜色, 结束线段颜色, 标注角度圆弧颜色, 文字标注的角度颜色]
48
+ * 某一项为null或undefined采用绘制颜色 || 单颜色
49
+ * */
50
+ setColor(colors: UnstableColor[] | MxColorType): this;
13
51
  worldDraw(pWorldDraw: McGiWorldDraw): void;
14
- getGripPoints(): THREE.Vector3[];
52
+ getGripPoints(): import("three").Vector3[];
15
53
  moveGripPointsAt(index: number, offset: THREE.Vector3): boolean;
16
54
  dwgIn(obj: any): boolean;
17
- dwgOut(obj: any): object;
18
- create(): MxDbEntity;
55
+ dwgOut(obj: any): any;
56
+ create(): MxDb2LineAngularDimension;
19
57
  transformBy(mat: THREE.Matrix4): void;
20
58
  getTypeName(): string;
21
59
  }
@@ -1 +1 @@
1
- import McGiWorldDrawType from"../McGiWorldDrawType";import MxDbEntity from"../MxDbEntity";import MxThreeJS from"../MxThreeJS";export default class MxDb2LineAngularDimension extends MxDbEntity{constructor(){super(...arguments),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.point3=new THREE.Vector3}calculateLineAngle(t,i,n){const e=2*Math.PI/360;return{startAngle:180*Math.atan2(i.y-t.y,i.x-t.x)/Math.PI*e,endAngle:180*Math.atan2(n.y-t.y,n.x-t.x)/Math.PI*e}}worldDraw(t){if(t.getType()==McGiWorldDrawType.kWorldDraw||t.getType()==McGiWorldDrawType.kDynDragDraw){let i=t.getColor(),n=t.getMxObject(),e=MxThreeJS.createLine(this.point1,this.point2,i);t.drawEntity(e);let o=MxThreeJS.createLine(this.point2,this.point3,i);t.drawEntity(o);const{startAngle:r,endAngle:p}=this.calculateLineAngle(this.point2,this.point1,this.point3),s=this.point2.distanceTo(this.point1),a=this.point2.distanceTo(this.point3);let h,l=(h=s>a?a:s)/4,c=THREE.MathUtils.radToDeg(r-p);c<0&&(c+=360);let d=n.screenCoordLong2Doc(50);const y=new THREE.ArcCurve(this.point2.x,this.point2.y,l,r,p,!0),w=(new THREE.BufferGeometry).setFromPoints(y.getPoints(50)),g=new THREE.LineBasicMaterial({color:"#ff0000"}),E=new THREE.Line(w,g);t.drawEntity(E);let M=y.getPoint(.5),T=new THREE.Vector3(M.x,M.y,0),x=T.sub(this.point2),u=x.length()+.5*d;x.normalize().multiplyScalar(u),T=this.point2.clone().add(x);let D=MxThreeJS.creatTextSprite(c.toFixed(3)+"°",T,.5*d,0,i);null!=D&&t.drawEntity(D)}else t.drawLine(this.point1,this.point2),t.drawLine(this.point3,this.point2)}getGripPoints(){return[this.point1,this.point2,this.point3]}moveGripPointsAt(t,i){return 0===t?this.point1.add(i):1===t?this.point2.add(i):2===t&&this.point3.add(i),!0}dwgIn(t){return this.onDwgIn(t),this.point1.copy(t.point1),this.point2.copy(t.point2),this.point3.copy(t.point3),t}dwgOut(t){return this.onDwgOut(t),t.point1=this.point1,t.point2=this.point2,t.point3=this.point3,t}create(){return new MxDb2LineAngularDimension}transformBy(t){this.point1.applyMatrix4(t),this.point2.applyMatrix4(t)}getTypeName(){return"MxDb2LineAngularDimension"}};
1
+ import _ from"lodash";import McGiWorldDrawType from"../McGiWorldDrawType";import MxDbEntity from"../MxDbEntity";const propertyDbKeys=["colors","point1","point2","point3"];export default class MxDb2LineAngularDimension extends MxDbEntity{constructor(t){if(super(),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.point3=new THREE.Vector3,this.colors=[],t){const{points:i,colors:o}=t;i&&this.setPoints(i),o&&this.setColor(o)}}calculateLineAngle(t,i,o){const n=2*Math.PI/360;return{startAngle:180*Math.atan2(i.y-t.y,i.x-t.x)/Math.PI*n,endAngle:180*Math.atan2(o.y-t.y,o.x-t.x)/Math.PI*n}}setPoints(t){const[i,o,n]=t;return i&&(this.point1=i),o&&(this.point2=o),n&&(this.point3=n),this}setColor(t){return _.isArray(t)?this.colors=t:this.color=t,this}worldDraw(t){if(t.getType()==McGiWorldDrawType.kWorldDraw||t.getType()==McGiWorldDrawType.kDynDragDraw){const[i,o,n,e]=this.colors||[],s=this.getColor(),r=t.getMxObject();t.setColor(i||s),t.drawLine(this.point1,this.point2),t.setColor(o||s),t.drawLine(this.point2,this.point3);const{startAngle:p,endAngle:h}=this.calculateLineAngle(this.point2,this.point1,this.point3),a=this.point2.distanceTo(this.point1),l=this.point2.distanceTo(this.point3),c=Math.min(a,l)/4;let d=THREE.MathUtils.radToDeg(p-h);d<0&&(d+=360);let y=r.screenCoordLong2Doc(50);const g=new THREE.ArcCurve(this.point2.x,this.point2.y,c,p,h,!0),w=(new THREE.Geometry).setFromPoints(g.getPoints(50));t.setColor(n||s),t.drawGeometryLines(w);const D=g.getPoint(.5);let u=new THREE.Vector3(D.x,D.y,0);const M=u.sub(this.point2),x=M.length()+.5*y;M.normalize().multiplyScalar(x),u=this.point2.clone().add(M),t.setColor(e||s),t.drawText(d.toFixed(3)+"°",.5*y,0,u)}else t.drawLine(this.point1,this.point2),t.drawLine(this.point3,this.point2)}getGripPoints(){return[this.point1,this.point2,this.point3]}moveGripPointsAt(t,i){return 0===t?this.point1.add(i):1===t?this.point2.add(i):2===t&&this.point3.add(i),!0}dwgIn(t){return this.onDwgIn(t),this.dwgInHelp(t,propertyDbKeys),!0}dwgOut(t){return this.onDwgOut(t),this.dwgOutHelp(t,propertyDbKeys),t}create(){return new MxDb2LineAngularDimension}transformBy(t){this.point1.applyMatrix4(t),this.point2.applyMatrix4(t)}getTypeName(){return"MxDb2LineAngularDimension"}};
@@ -1,14 +1,47 @@
1
1
  /** @module MxDbAlignedDimension*/
2
2
  import McGiWorldDraw from '../McGiWorldDraw';
3
3
  import MxDbEntity from '../MxDbEntity';
4
+ import { MxColorType, UnstableColor } from '../MxType';
4
5
  /**
5
6
  * MxDbAlignedDimension 尺寸标注
6
7
  */
7
8
  export default class MxDbAlignedDimension extends MxDbEntity {
9
+ /**
10
+ * MxDbAlignedDimension
11
+ * 尺寸标注
12
+ * @param options.points 提供两个向量测量尺寸
13
+ * @param options.fontColor 字体颜色
14
+ * @example ```typescript
15
+ * const draw = Mx.MxFun.getCurrentDraw();
16
+ * const v3 = new THREE.Vector3()
17
+ * const points = [v3 , v3.clone().add(new THREE.Vector3(8880, 0, 0))]
18
+ * const colors = ['#F00880','#00ff1a']
19
+ * draw.addMxEntity(
20
+ * new Mx.MxDbAlignedDimension({ points })
21
+ * .setColor(colors)
22
+ * .setLineWidth(6)
23
+ * )
24
+ * ```
25
+ **/
26
+ constructor(options?: {
27
+ /** [point1, point2] 两个向量位置 */
28
+ points?: THREE.Vector3[];
29
+ /** 字体颜色 */
30
+ fontColor?: MxColorType;
31
+ });
8
32
  point1: THREE.Vector3;
9
33
  point2: THREE.Vector3;
34
+ fontColor: UnstableColor;
35
+ /**
36
+ * 设置两个点位置向量
37
+ * @param { THREE.Vector3[] } points [THREE.Vector3, THREE.Vector3]
38
+ */
39
+ setPoints(points: THREE.Vector3[]): void;
10
40
  getTypeName(): string;
11
41
  private getDirection;
42
+ /**
43
+ * 获取尺寸距离
44
+ * */
12
45
  getDimText(): string;
13
46
  worldDraw(pWorldDraw: McGiWorldDraw): void;
14
47
  /**
@@ -21,9 +54,10 @@ export default class MxDbAlignedDimension extends MxDbEntity {
21
54
  * @parma pt1 three.js坐标点位
22
55
  * */
23
56
  setPoint2(pt2: THREE.Vector3): void;
57
+ setColor(color: UnstableColor | UnstableColor[]): this;
24
58
  getGripPoints(): Array<THREE.Vector3>;
25
59
  moveGripPointsAt(index: number, offset: THREE.Vector3): boolean;
26
60
  dwgIn(obj: any): boolean;
27
61
  dwgOut(obj: any): object;
28
- create(): MxDbEntity;
62
+ create(): MxDbAlignedDimension;
29
63
  }
@@ -1 +1 @@
1
- import McGiWorldDrawType from"../McGiWorldDrawType";import MxDbEntity from"../MxDbEntity";import MxThreeJS from"../MxThreeJS";export default class MxDbAlignedDimension extends MxDbEntity{constructor(){super(...arguments),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3}getTypeName(){return"MxDbAlignedDimension"}getDirection(t,e,i){var r=new THREE.Vector3(t.x,t.y,0),n=new THREE.Vector3(1,0,0),a=t.angleTo(n),o=-1;(a<7*Math.PI/18||a>10*Math.PI/18)&&e.x>i.x&&(o=1);var y=new THREE.Matrix4;return y.makeRotationZ(Math.PI/2*o),r.applyMatrix4(y),r}getDimText(){return new THREE.Vector3(this.point1.x-this.point2.x,this.point1.y-this.point2.y,0).length().toFixed(3)}worldDraw(t){if(t.getType()==McGiWorldDrawType.kWorldDraw||t.getType()==McGiWorldDrawType.kDynDragDraw){let V=this.point1,g=this.point2;var e,i,r,n,a,o,y,x=new THREE.Vector3(V.x-g.x,V.y-g.y,0),E=this.getDirection(x,V,g),p=new THREE.Matrix4;p.makeScale(.01,.01,.01),(h=new THREE.Vector3(E.x,E.y,0)).applyMatrix4(p);var w=new THREE.Vector3(V.x+h.x,V.y+h.y,0),T=new THREE.Vector3(g.x+h.x,g.y+h.y,0);const D=16777215;o=MxThreeJS.createPoint(V,D),y=MxThreeJS.createPoint(g,D),p.identity(),p.makeScale(.2,.2,0),new THREE.Vector3(E.x,E.y,0).applyMatrix4(p),p.identity(),p.makeScale(.02,.02,0);var c=new THREE.Vector3(E.x,E.y,0);c.applyMatrix4(p),t.drawLine(w,T),e=MxThreeJS.createLine(new THREE.Vector3(w.x+2*c.x,w.y+2*c.y,0),new THREE.Vector3(V.x+c.x,V.y+c.y,0),D),i=MxThreeJS.createLine(new THREE.Vector3(T.x+2*c.x,T.y+2*c.y,0),new THREE.Vector3(g.x+c.x,g.y+c.y,0),D);{var h,M=new THREE.Vector3(1,0,0),l=x.angleTo(M);(h=new THREE.Vector3(E.x,E.y,0)).normalize();var s=V.distanceTo(g);x.y<0?l=l<Math.PI/2?2*Math.PI-l:Math.PI-l:l>Math.PI/2&&(l=Math.PI+l);let e=t.getMxObject();e&&(l-=e.getViewAngle());let i=this.getDimText();null!=(r=MxThreeJS.creatTextSprite(i,new THREE.Vector3(T.x+x.x/2+h.x*s/30,T.y+x.y/2+h.y*s/30,0),.07*s,l,D))&&t.drawEntity(r)}{p.identity(),p.makeScale(.08,.08,.08);var R=new THREE.Matrix4;R.makeRotationZ(17*Math.PI/18);var d=new THREE.Vector3(x.x,x.y,0);d.applyMatrix4(p),d.applyMatrix4(R),R.identity(),R.makeRotationZ(17*-Math.PI/18);var H=new THREE.Vector3(x.x,x.y,0);H.applyMatrix4(p),H.applyMatrix4(R);let t=new Array;t.push(new THREE.Vector3(w.x,w.y,0),new THREE.Vector3(w.x+d.x,w.y+d.y,0),new THREE.Vector3(w.x+H.x,w.y+H.y,0)),n=MxThreeJS.createTriangle(t,D),R.identity(),R.makeRotationZ(Math.PI/18),(d=new THREE.Vector3(x.x,x.y,0)).applyMatrix4(p),d.applyMatrix4(R),R.identity(),R.makeRotationZ(-Math.PI/18),(H=new THREE.Vector3(x.x,x.y,0)).applyMatrix4(p),H.applyMatrix4(R);let e=new Array;e.push(new THREE.Vector3(T.x,T.y,0),new THREE.Vector3(T.x+d.x,T.y+d.y,0),new THREE.Vector3(T.x+H.x,T.y+H.y,0)),a=MxThreeJS.createTriangle(e,D)}t.drawEntity(e),t.drawEntity(i),n&&t.drawEntity(n),a&&t.drawEntity(a),t.drawEntity(o),t.drawEntity(y)}else t.drawLine(this.point1,this.point2)}setPoint1(t){this.point1=t}setPoint2(t){this.point2=t}getGripPoints(){let t=[];return t.push(this.point1),t.push(this.point2),t}moveGripPointsAt(t,e){return 0==t?this.point1.add(e):(t=1)&&this.point2.add(e),!0}dwgIn(t){return this.onDwgIn(t),this.point1.copy(t.point1),this.point2.copy(t.point2),!0}dwgOut(t){return this.onDwgOut(t),t.point1=this.point1,t.point2=this.point2,t}create(){return new MxDbAlignedDimension}};
1
+ import _ from"lodash";import McGiWorldDrawType from"../McGiWorldDrawType";import MxDbEntity from"../MxDbEntity";import MxThreeJS from"../MxThreeJS";const propertyDbKeys=["point1","point2","fontColor"];export default class MxDbAlignedDimension extends MxDbEntity{constructor(t){if(super(),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,t){const{points:e,fontColor:o}=t;e&&this.setPoints(e),o&&(this.fontColor=o)}}setPoints(t){const[e,o]=t;e&&(this.point1=e),o&&(this.point2=o)}getTypeName(){return"MxDbAlignedDimension"}getDirection(t,e,o){const n=new THREE.Vector3(t.x,t.y,0),i=new THREE.Vector3(1,0,0),r=t.angleTo(i);let a=-1;(r<7*Math.PI/18||r>10*Math.PI/18)&&e.x>o.x&&(a=1);const s=new THREE.Matrix4;return s.makeRotationZ(Math.PI/2*a),n.applyMatrix4(s),n}getDimText(){return new THREE.Vector3(this.point1.x-this.point2.x,this.point1.y-this.point2.y,0).length().toFixed(3)}worldDraw(t){if(t.getType()==McGiWorldDrawType.kWorldDraw||t.getType()==McGiWorldDrawType.kDynDragDraw){const e=this.point1,o=this.point2;let n,i,r,a,s,y,x;const c=new THREE.Vector3(e.x-o.x,e.y-o.y,0),p=this.getDirection(c,e,o),E=new THREE.Matrix4;E.makeScale(.01,.01,.01);const h=new THREE.Vector3(p.x,p.y,0);h.applyMatrix4(E);const l=new THREE.Vector3(e.x+h.x,e.y+h.y,0),w=new THREE.Vector3(o.x+h.x,o.y+h.y,0),T=this.getColor();y=MxThreeJS.createPoint(e,T),x=MxThreeJS.createPoint(o,T);{E.identity(),E.makeScale(.2,.2,0),new THREE.Vector3(p.x,p.y,0).applyMatrix4(E),E.identity(),E.makeScale(.02,.02,0);const r=new THREE.Vector3(p.x,p.y,0);r.applyMatrix4(E),t.drawLine(l,w),n=MxThreeJS.createLine(new THREE.Vector3(l.x+2*r.x,l.y+2*r.y,0),new THREE.Vector3(e.x+r.x,e.y+r.y,0),T),i=MxThreeJS.createLine(new THREE.Vector3(w.x+2*r.x,w.y+2*r.y,0),new THREE.Vector3(o.x+r.x,o.y+r.y,0),T)}{const n=new THREE.Vector3(1,0,0);let i=c.angleTo(n);const a=new THREE.Vector3(p.x,p.y,0);a.normalize();const s=e.distanceTo(o);c.y<0?i=i<Math.PI/2?2*Math.PI-i:Math.PI-i:i>Math.PI/2&&(i=Math.PI+i);const y=t.getMxObject();y&&(i-=y.getViewAngle());const x=this.getDimText();null!=(r=MxThreeJS.creatTextSprite(x,new THREE.Vector3(w.x+c.x/2+a.x*s/30,w.y+c.y/2+a.y*s/30,0),.07*s,i,this.fontColor||T))&&t.drawEntity(r)}{E.identity(),E.makeScale(.08,.08,.08);const t=new THREE.Matrix4;t.makeRotationZ(17*Math.PI/18);let e=new THREE.Vector3(c.x,c.y,0);e.applyMatrix4(E),e.applyMatrix4(t),t.identity(),t.makeRotationZ(17*-Math.PI/18);let o=new THREE.Vector3(c.x,c.y,0);o.applyMatrix4(E),o.applyMatrix4(t);const n=new Array;n.push(new THREE.Vector3(l.x,l.y,0),new THREE.Vector3(l.x+e.x,l.y+e.y,0),new THREE.Vector3(l.x+o.x,l.y+o.y,0)),a=MxThreeJS.createTriangle(n,T),t.identity(),t.makeRotationZ(Math.PI/18),(e=new THREE.Vector3(c.x,c.y,0)).applyMatrix4(E),e.applyMatrix4(t),t.identity(),t.makeRotationZ(-Math.PI/18),(o=new THREE.Vector3(c.x,c.y,0)).applyMatrix4(E),o.applyMatrix4(t);const i=new Array;i.push(new THREE.Vector3(w.x,w.y,0),new THREE.Vector3(w.x+e.x,w.y+e.y,0),new THREE.Vector3(w.x+o.x,w.y+o.y,0)),s=MxThreeJS.createTriangle(i,T)}t.drawEntity(n),t.drawEntity(i),a&&t.drawEntity(a),s&&t.drawEntity(s),t.drawEntity(y),t.drawEntity(x)}else t.drawLine(this.point1,this.point2)}setPoint1(t){this.point1=t}setPoint2(t){this.point2=t}setColor(t){return _.isArray(t)?([this.color=this.color,this.fontColor=this.fontColor||this.color]=t,console.log("this.fontColor : ",this.fontColor)):this.color=t,this}getGripPoints(){let t=[];return t.push(this.point1),t.push(this.point2),t}moveGripPointsAt(t,e){return 0==t?this.point1.add(e):(t=1)&&this.point2.add(e),!0}dwgIn(t){return this.onDwgIn(t),this.dwgInHelp(t,propertyDbKeys),!0}dwgOut(t){return this.onDwgOut(t),this.dwgOutHelp(t,propertyDbKeys),t}create(){return new MxDbAlignedDimension}};
@@ -9,8 +9,12 @@ export default class MxDbAnyLine extends MxDbEntity {
9
9
  /** 构成线段的顶点坐标集合 */
10
10
  points: THREE.Vector3[];
11
11
  getTypeName(): string;
12
- create(): MxDbEntity;
12
+ create(): MxDbAnyLine;
13
13
  worldDraw(pWorldDraw: McGiWorldDraw): void;
14
+ /** 设置线段points
15
+ * @param points 构成线段的多个点
16
+ */
17
+ setPoints(points: THREE.Vector3[]): this;
14
18
  /** 获取线段的包围盒的中心点坐标 */
15
19
  getCenter(): THREE.Vector3;
16
20
  getGripPoints(): THREE.Vector3[];
@@ -1 +1 @@
1
- import{createAnyLine}from"../../tools/three/index";import MxDbEntity from"../MxDbEntity";import McGiWorldDrawType from"../McGiWorldDrawType";export default class MxDbAnyLine extends MxDbEntity{constructor(){super(...arguments),this.points=[]}getTypeName(){return"MxDbAnyLine"}create(){return new MxDbAnyLine}worldDraw(e){let t=e.getMxObject();const n=createAnyLine(this.points);n.geometry.computeBoundingBox();let r=new THREE.Vector3;if(n.geometry.boundingBox.getCenter(r),e.drawEntity(n),e.getType()===McGiWorldDrawType.kSelectDraw){const o=new THREE.Vector3;n.geometry.boundingBox.getSize(o),o.addScalar(t.screenCoordLong2Doc(20));const i=o.x/2,y=o.y/2,s={x:r.x-i,y:r.y-y},x={x:r.x+i,y:r.y-y},c={x:r.x+i,y:r.y+y},d={x:r.x-i,y:r.y+y};e.drawLine(s.x,s.y,x.x,x.y),e.drawLine(x.x,x.y,c.x,c.y),e.drawLine(c.x,c.y,d.x,d.y),e.drawLine(d.x,d.y,s.x,s.y)}}getCenter(){const e=new THREE.Geometry;e.vertices=this.points;let t=new THREE.Vector3;return e.computeBoundingBox(),e.boundingBox.getCenter(t),t}getGripPoints(){return[this.getCenter()]}moveGripPointsAt(e,t){return this.points.forEach(e=>{e.add(t)}),!0}dwgIn(e){this.onDwgIn(e);let t=e.points;return this.points=[],t.forEach(e=>{this.points.push(new THREE.Vector3(e.x,e.y,e.z))}),!0}dwgOut(e){return this.onDwgOut(e),e.points=this.points,e}};
1
+ import MxDbEntity from"../MxDbEntity";import McGiWorldDrawType from"../McGiWorldDrawType";const propertyDbKeys=["points"];export default class MxDbAnyLine extends MxDbEntity{constructor(){super(...arguments),this.points=[]}getTypeName(){return"MxDbAnyLine"}create(){return new MxDbAnyLine}worldDraw(t){let e=t.getMxObject();const n=(new THREE.Box3).setFromPoints(this.points);let r=new THREE.Vector3;if(n.getCenter(r),t.drawLines(this.points),t.getType()===McGiWorldDrawType.kSelectDraw){const o=new THREE.Vector3;n.getSize(o),o.addScalar(e.screenCoordLong2Doc(20));const i=o.x/2,s=o.y/2,y={x:r.x-i,y:r.y-s},x={x:r.x+i,y:r.y-s},p={x:r.x+i,y:r.y+s},c={x:r.x-i,y:r.y+s};t.drawLine(y.x,y.y,x.x,x.y),t.drawLine(x.x,x.y,p.x,p.y),t.drawLine(p.x,p.y,c.x,c.y),t.drawLine(c.x,c.y,y.x,y.y)}}setPoints(t){return this.points=t,this}getCenter(){const t=new THREE.Geometry;t.vertices=this.points;const e=new THREE.Vector3;return t.computeBoundingBox(),t.boundingBox.getCenter(e),e}getGripPoints(){return[this.getCenter()]}moveGripPointsAt(t,e){return 0===t&&this.points.forEach(t=>{t.add(e)}),!0}dwgIn(t){return this.onDwgIn(t),this.dwgInHelp(t,propertyDbKeys),!0}dwgOut(t){return this.onDwgOut(t),this.dwgOutHelp(t,propertyDbKeys),t}};
@@ -7,7 +7,7 @@ import MxDbEntity from '../MxDbEntity';
7
7
  export default class MxDbCloudLine extends MxDbEntity {
8
8
  private points;
9
9
  private radius;
10
- private drawGeometry;
10
+ private cachePoint;
11
11
  getTypeName(): string;
12
12
  create(): MxDbEntity;
13
13
  /** 设置构成云线的每个圆弧半径长度
@@ -33,7 +33,7 @@ export default class MxDbCloudLine extends MxDbEntity {
33
33
  * */
34
34
  addLine(pt1: THREE.Vector3, pt2: THREE.Vector3): import("three").Vector3;
35
35
  /** 重新计算云线的的所有顶点坐标, 如绘制完云线后 重新设置了圆弧半径, 在worldDraw动态绘制时会调用该方法 */
36
- reCalculateDrawGeometry(): void;
36
+ reCalculateDrawGeometryPoint(): THREE.Vector3[] | null;
37
37
  worldDraw(pWorldDraw: McGiWorldDraw): void;
38
38
  /**
39
39
  * 获取云线包围盒的中心点
@@ -1 +1 @@
1
- import MxDbEntity from"../MxDbEntity";import McGiWorldDrawType from"../McGiWorldDrawType";export default class MxDbCloudLine extends MxDbEntity{constructor(){super(...arguments),this.points=[],this.radius=16,this.drawGeometry=null}getTypeName(){return"MxDbCloudLine"}create(){return new MxDbCloudLine}setRadius(t){this.radius=t,this.drawGeometry=null}getRadius(){return this.radius}clacNewArcDiameterPoint(t){if(0==this.points.length)return t;let e=this.points[this.points.length-1];const r=2*this.radius,i=e.distanceTo(t);if(i<r)return null;const n=r*(t.x-e.x)/i+e.x,s=r*(t.y-e.y)/i+e.y;return new THREE.Vector3(n,s,e.z)}createCloudArcCurvePoints(t,e,r){const i=new THREE.Vector3((t.x+e.x)/2,(t.y+e.y)/2,0);r||(r=i.distanceTo(t));const{startAngle:n,endAngle:s}=function(t,e,r){const i=2*Math.PI/360;return{startAngle:180*Math.atan2(e.y-t.y,e.x-t.x)/Math.PI*i,endAngle:180*Math.atan2(r.y-t.y,r.x-t.x)/Math.PI*i}}(i,t,e);return new THREE.ArcCurve(i.x,i.y,r,n,s,!0).getPoints(10)}addPoint(t,e){let r=this.clacNewArcDiameterPoint(t);if(r)if(this.points.push(r),e){if(this.points.length<2)return;let t=this.points[this.points.length-2];const e=this.createCloudArcCurvePoints(t,r);let i=this.drawGeometry;i||(i=new THREE.Geometry),e.forEach(t=>{null===i||void 0===i||i.vertices.push(new THREE.Vector3(t.x,t.y,0))}),this.drawGeometry=new THREE.Geometry,this.drawGeometry.vertices=i.vertices}else this.drawGeometry=null}addLine(t,e){this.addPoint(t);const r=2*this.radius;let i=this.points[this.points.length-1],n=i.distanceTo(e);const s=Math.round(n/r);for(let t=0;t<s;t++){n=i.distanceTo(e);const t=r*(e.x-i.x)/n+i.x,s=r*(e.y-i.y)/n+i.y;let o=new THREE.Vector3(t,s,e.z);this.addPoint(o),i=o}return this.points[this.points.length-1]}reCalculateDrawGeometry(){if(this.drawGeometry=new THREE.Geometry,this.points.length<2)return;let t=this.points[0],e=this.points.length;for(let r=1;r<e;r++){let e=this.points[r];this.createCloudArcCurvePoints(t,e).forEach(t=>{var e;null===(e=this.drawGeometry)||void 0===e||e.vertices.push(new THREE.Vector3(t.x,t.y,0))}),t=e}}worldDraw(t){var e;if(t.getType()===McGiWorldDrawType.kSelectDraw){if(!this.drawGeometry)return;this.drawGeometry.computeBoundingBox();const e=new THREE.Vector3;this.drawGeometry.boundingBox.getSize(e);let r=new THREE.Vector3;this.drawGeometry.boundingBox.getCenter(r);const i=e.x/2,n=e.y/2,s={x:r.x-i,y:r.y-n},o={x:r.x+i,y:r.y-n},a={x:r.x+i,y:r.y+n},h={x:r.x-i,y:r.y+n};t.drawLine(s.x,s.y,o.x,o.y),t.drawLine(o.x,o.y,a.x,a.y),t.drawLine(a.x,a.y,h.x,h.y),t.drawLine(h.x,h.y,s.x,s.y)}else{if(this.drawGeometry||this.reCalculateDrawGeometry(),0==(null===(e=this.drawGeometry)||void 0===e?void 0:e.vertices.length))return;t.drawGeometryLines(this.drawGeometry)}}getCenter(){const t=new THREE.Geometry;t.vertices=this.points;let e=new THREE.Vector3;return t.computeBoundingBox(),t.boundingBox.getCenter(e),e}getGripPoints(){return[this.getCenter()]}moveGripPointsAt(t,e){return this.points.forEach(t=>{t.add(e)}),this.drawGeometry=null,!0}dwgIn(t){this.onDwgIn(t);let e=t.points;return this.points=[],e.forEach(t=>{this.points.push(new THREE.Vector3(t.x,t.y,t.z))}),this.drawGeometry=null,this.radius=t.radius,!0}dwgOut(t){return this.onDwgOut(t),t.points=this.points,t.radius=this.radius,t}};
1
+ import MxDbEntity from"../MxDbEntity";import McGiWorldDrawType from"../McGiWorldDrawType";const propertyDbKeys=["points","radius","cachePoint"];export default class MxDbCloudLine extends MxDbEntity{constructor(){super(...arguments),this.points=[],this.radius=16,this.cachePoint=null}getTypeName(){return"MxDbCloudLine"}create(){return new MxDbCloudLine}setRadius(t){this.radius=t}getRadius(){return this.radius}clacNewArcDiameterPoint(t){if(0==this.points.length)return t;let e=this.points[this.points.length-1];const n=2*this.radius,i=e.distanceTo(t);if(i<n)return null;const r=n*(t.x-e.x)/i+e.x,o=n*(t.y-e.y)/i+e.y;return new THREE.Vector3(r,o,e.z)}createCloudArcCurvePoints(t,e,n){const i=new THREE.Vector3((t.x+e.x)/2,(t.y+e.y)/2,0);n||(n=i.distanceTo(t));const{startAngle:r,endAngle:o}=function(t,e,n){const i=2*Math.PI/360;return{startAngle:180*Math.atan2(e.y-t.y,e.x-t.x)/Math.PI*i,endAngle:180*Math.atan2(n.y-t.y,n.x-t.x)/Math.PI*i}}(i,t,e);return new THREE.ArcCurve(i.x,i.y,n,r,o,!0).getPoints(10)}addPoint(t,e){let n=this.clacNewArcDiameterPoint(t);n&&(this.points.push(n),this.cachePoint=null,e&&(this.cachePoint=this.reCalculateDrawGeometryPoint()))}addLine(t,e){this.addPoint(t);const n=2*this.radius;let i=this.points[this.points.length-1],r=i.distanceTo(e);const o=Math.round(r/n);for(let t=0;t<o;t++){r=i.distanceTo(e);const t=n*(e.x-i.x)/r+i.x,o=n*(e.y-i.y)/r+i.y;let s=new THREE.Vector3(t,o,e.z);this.addPoint(s),i=s}return this.points[this.points.length-1]}reCalculateDrawGeometryPoint(){if(this.points.length<2)return null;let t=this.points[0],e=this.points.length,n=[];for(let i=1;i<e;i++){let e=this.points[i];this.createCloudArcCurvePoints(t,e).forEach(t=>{n.push(new THREE.Vector3(t.x,t.y,0))}),t=e}return n}worldDraw(t){if(this.cachePoint||(this.cachePoint=this.reCalculateDrawGeometryPoint()),this.cachePoint)if(t.getType()===McGiWorldDrawType.kSelectDraw){let e=new THREE.Geometry;this.cachePoint.forEach(t=>{e.vertices.push(new THREE.Vector3(t.x,t.y,0))}),e.computeBoundingBox();const n=new THREE.Vector3;e.boundingBox.getSize(n);let i=new THREE.Vector3;e.boundingBox.getCenter(i);const r=n.x/2,o=n.y/2,s={x:i.x-r,y:i.y-o},c={x:i.x+r,y:i.y-o},a={x:i.x+r,y:i.y+o},h={x:i.x-r,y:i.y+o};t.drawLine(s.x,s.y,c.x,c.y),t.drawLine(c.x,c.y,a.x,a.y),t.drawLine(a.x,a.y,h.x,h.y),t.drawLine(h.x,h.y,s.x,s.y)}else t.drawLines(this.cachePoint)}getCenter(){const t=new THREE.Geometry;t.vertices=this.points;let e=new THREE.Vector3;return t.computeBoundingBox(),t.boundingBox.getCenter(e),e}getGripPoints(){return[this.getCenter()]}moveGripPointsAt(t,e){return this.points.forEach(t=>{t.add(e)}),this.cachePoint=null,!0}dwgIn(t){return this.onDwgIn(t),this.dwgInHelp(t,propertyDbKeys),!0}dwgOut(t){return this.onDwgOut(t),this.dwgOutHelp(t,propertyDbKeys),t}};
@@ -1,6 +1,16 @@
1
- /** @module MxDbEntity*/
2
1
  import McGiWorldDraw from '../McGiWorldDraw';
3
2
  import MxDrawObject from '../MxDrawObject';
3
+ import { MxColorType, UnstableColor } from '../MxType';
4
+ export declare enum DataType {
5
+ Default = 0,
6
+ Color = 1,
7
+ Vector2 = 2,
8
+ Vector3 = 3,
9
+ Vector4 = 4,
10
+ Matrix3 = 5,
11
+ Matrix4 = 6
12
+ }
13
+ export declare const MXDBDATATYPE = "datatype";
4
14
  /**
5
15
  * MxDbEntity 用于构建一个自定义对象的抽象类(该类无法实例化 请通过继承的方式对其抽象方法进行实现)
6
16
  * @description MxDbEntity 属于 abstract class(抽象类) 主要用途是通过继承这个类实现一个用于动态绘制的图形对象
@@ -25,7 +35,7 @@ export default abstract class MxDbEntity {
25
35
  /**
26
36
  * 颜色值
27
37
  * */
28
- color: number | string | THREE.Color;
38
+ color: UnstableColor;
29
39
  /**
30
40
  * 显示顺序
31
41
  * */
@@ -44,12 +54,12 @@ export default abstract class MxDbEntity {
44
54
  userData: {
45
55
  [key: string]: any;
46
56
  };
47
- private sGuid;
48
- private dLineWidth;
49
- private lineWidthByPixels;
50
- private dDashArray;
51
- private dDashRatio;
52
- private layer;
57
+ sGuid: string;
58
+ dLineWidth: number;
59
+ lineWidthByPixels: boolean;
60
+ dDashArray: number;
61
+ dDashRatio: number;
62
+ layer: string;
53
63
  private _event;
54
64
  abstract getTypeName(): string;
55
65
  initGuid(guid: string): void;
@@ -73,7 +83,10 @@ export default abstract class MxDbEntity {
73
83
  abstract moveGripPointsAt(index: number, offset: THREE.Vector3): boolean;
74
84
  /**
75
85
  * 自定义对象数据输入,辅助函数.
76
- * @param
86
+ * @param obj 数据对象
87
+ * @param aryProp 属性名称列表
88
+ * @param hooks.getVal 交互数据输入钩子函数 return null | undefined 默认深拷贝 ; return Value 返回数据
89
+ * @param hooks.getCacheVal 归档数据构子函数 return null | undefined 默认深拷贝 ; return Value 返回数据
77
90
  * @returns boolean
78
91
  * @example
79
92
  * ``` typescript
@@ -85,7 +98,13 @@ export default abstract class MxDbEntity {
85
98
  * }
86
99
  * ```
87
100
  */
88
- protected dwgInHelp(obj: any, aryProp: string[]): boolean;
101
+ protected dwgInHelp<T extends (string | {
102
+ key: string;
103
+ default: any;
104
+ })[]>(obj: any, aryProp: T, hooks?: {
105
+ getVal?: (v: any) => any;
106
+ getCacheVal?: (v: any) => any;
107
+ }): boolean;
89
108
  /**
90
109
  * 自定义对象数据输出 辅助函数.
91
110
  * @param
@@ -100,14 +119,17 @@ export default abstract class MxDbEntity {
100
119
  * }
101
120
  * ```
102
121
  */
103
- protected dwgOutHelp(obj: any, aryProp: string[]): any;
122
+ protected dwgOutHelp(obj: any, aryProp: (string | {
123
+ key: string;
124
+ default: any;
125
+ })[]): any;
104
126
  protected callEvent(sEventName: string, param?: any): any;
105
127
  /**
106
128
  * 新创建一个自定义对象 (默认调用该对象的构造函数来创建新的对象)
107
- * @param
129
+ * @param { T } options
108
130
  * @returns MxDbEntity
109
131
  */
110
- create(): MxDbEntity;
132
+ create(options?: {}): any;
111
133
  /**
112
134
  * 自定义对象数据输入,必须要实现该函数
113
135
  * @param
@@ -140,10 +162,10 @@ export default abstract class MxDbEntity {
140
162
  abstract dwgOut(obj: any): object;
141
163
  /**
142
164
  * 自定义实体的矩阵 坐标变换 (需要重写该方法实现如果通过矩阵对自定义实体进行操作 默认不会进行任何操作)
143
- * @param mat THREE.Matrix4 变化矩阵
165
+ * @param _mat THREE.Matrix4 变化矩阵
144
166
  * @returns void
145
167
  */
146
- transformBy(mat: THREE.Matrix4): void;
168
+ transformBy(_mat: THREE.Matrix4): void;
147
169
  /**
148
170
  * 返回对象最小外包.
149
171
  * @param
@@ -193,18 +215,18 @@ export default abstract class MxDbEntity {
193
215
  * @param color 颜色值
194
216
  * @returns boolean
195
217
  */
196
- setColor(color: number | string | THREE.Color): void;
218
+ setColor(color: MxColorType): this;
197
219
  /**
198
220
  * 得到颜色
199
221
  * @returns boolean
200
222
  */
201
- getColor(): number | string | THREE.Color;
223
+ getColor(): MxColorType;
202
224
  /**
203
225
  * 复制克隆对象。
204
226
  * @param type {@link MxType.MxCloneType} 传入参数区分是正常拷贝还是动态拷贝
205
227
  * @returns MxDbEntity
206
228
  */
207
- clone(type?: number): MxDbEntity;
229
+ clone(type?: number): any;
208
230
  /**
209
231
  * 自定义对象内部数据输入同步(重写实现dwgIn抽象方法时 必须在实现中调用 this.onDwgIn(obj))
210
232
  * @param obj dwgIn抽象方法的回调数据
@@ -234,7 +256,7 @@ export default abstract class MxDbEntity {
234
256
  * 设置线宽是否随像素
235
257
  * @returns number
236
258
  */
237
- setLineWidthByPixels(isPixels: boolean): void;
259
+ setLineWidthByPixels(isPixels: boolean): this;
238
260
  /**
239
261
  * 线宽是否随像素
240
262
  * @returns number
@@ -244,7 +266,7 @@ export default abstract class MxDbEntity {
244
266
  * 设置线宽
245
267
  * @returns number
246
268
  */
247
- setLineWidth(dLineWidth: number): void;
269
+ setLineWidth(dLineWidth: number): this;
248
270
  /**
249
271
  * 得到线宽
250
272
  * @returns number
@@ -260,22 +282,22 @@ export default abstract class MxDbEntity {
260
282
  * dDashRatio确定虚线,与实线的比率.
261
283
  * @returns number
262
284
  */
263
- setDashLen(dashLen: number): void;
285
+ setDashLen(dashLen: number): this;
264
286
  /**
265
287
  * 设置虚线,与实线的比率
266
288
  * @returns number
267
289
  */
268
- setDashRatio(dDashRatio: number): void;
290
+ setDashRatio(dDashRatio: number): this;
269
291
  /**
270
292
  * 设置实线虚线总段数 = 1 / dashArray
271
293
  * @returns number
272
294
  */
273
- setDashArray(dDashArray: number): void;
295
+ setDashArray(dDashArray: number): this;
274
296
  /**
275
297
  * 设置虚线数据
276
298
  * @returns number
277
299
  */
278
- setDash(dDashArray: number, dDashRatio: number): void;
300
+ setDash(dDashArray: number, dDashRatio: number): this;
279
301
  /**
280
302
  * 得到虚线数据
281
303
  * @returns number
@@ -285,7 +307,7 @@ export default abstract class MxDbEntity {
285
307
  * 设置虚线显示。并初始化一个默认值。
286
308
  * @returns number
287
309
  */
288
- setDashLineDisplay(isDashLine: boolean): void;
310
+ setDashLineDisplay(isDashLine: boolean): this;
289
311
  /**
290
312
  * 是否虚线显示
291
313
  * @returns number
@@ -1 +1 @@
1
- import MxType from"../MxType";import store from"../store/store";export default class MxDbEntity{constructor(){this.color=16777215,this.renderOrder=30,this.opacity=1,this.visible=!0,this.userData={},this.sGuid="",this.dLineWidth=0,this.lineWidthByPixels=!0,this.dDashArray=0,this.dDashRatio=0,this.layer="",this._event={}}initGuid(t){this.sGuid.length>0?console.log("mx: init guid error"):this.sGuid=t}dwgInHelp(t,e){const i=t=>t instanceof Array?s(t):"object"==typeof t?(t=>!!(t.isVector3||t.isVector2||t.isVector4))(t)?t.clone():2==t.datatype?new THREE.Vector2(t.x,t.y):3==t.datatype?new THREE.Vector3(t.x,t.y,t.z):4==t.datatype?new THREE.Vector4(t.x,t.y,t.z,t.w):r(t,Object.create(null)):t,s=t=>t.map(t=>i(t)),r=(t,e)=>{for(let s in t)t[s]&&(e[s]=i(t[s]));return e};let h=this;return e.forEach(e=>{t[e]&&(h[e]=i(t[e]))}),!0}dwgOutHelp(t,e){let i=this;return e.forEach(e=>{t[e]=i[e];let s=(t=>t.isVector3?3:t.isVector2?2:t.isVector4?4:0)(i[e]);s&&(t[e].datatype=s)}),t}callEvent(t,e){return void 0!=this._event[t]?this._event[t](e):void 0}create(){return new(0,this.constructor)}transformBy(t){}getGeomExtents(){return null}getImp(){return this.MxDbEntityImp}setNeedUpdateDisplay(t){let e=this.getImp();return!!e&&(t?e.upDisplay():e.setDirtyDisplay(!0),!0)}getMxObject(){let t=this.getImp();return t?t.getMxObject():null}onViewChange(){return!1}objectId(){let t=this.getImp();return t?t.objectId():0}erase(){let t=this.getImp();return!!t&&t.erase()}setLayer(t){let e=this.getImp();e&&e.nodifySetLayer(),this.layer=t}getLayer(){return this.layer}setColor(t){this.color=t}getColor(){return this.color}clone(t){let e=this.create(),i={type:t||MxType.MxCloneType.kClone};return this.dwgOut(i),e.dwgIn(i),e.sGuid="",e}onDwgIn(t){this.color=t.color,this.renderOrder=t.renderOrder,this.opacity=t.opacity,this.visible=t.visible,t.userData?this.userData=JSON.parse(JSON.stringify(t.userData)):this.userData={},this.dLineWidth=t.lineWidth,this.lineWidthByPixels=t.lineWidthByPixels,this.dDashArray=t.dashArray,this.dDashRatio=t.dashRatio,this.layer=t.layer,t.guid&&(this.sGuid=t.guid)}onDwgOut(t){t.color=this.color,t.renderOrder=this.renderOrder,t.opacity=this.opacity,t.visible=this.visible,Object.keys(this.userData).length>0&&(t.userData=this.userData),t.lineWidth=this.dLineWidth,t.lineWidthByPixels=this.lineWidthByPixels,t.dashArray=this.dDashArray,t.dashRatio=this.dDashRatio,t.layer=this.layer,t.guid=this.sGuid}rxInit(){store.state.MxFun.initMxDbEntityType(this)}setRenderOrder(t){this.renderOrder=t}getRenderOrder(){return this.renderOrder}setLineWidthByPixels(t){this.lineWidthByPixels=t}getLineWidthByPixels(){return this.lineWidthByPixels}setLineWidth(t){this.dLineWidth=t}getLineWidth(){return this.dLineWidth}getGetLength(){return 0}setDashLen(t){let e=this.getGetLength();if(e<1e-6||t<1e-6)return;let i=Math.floor(e/t);i<1e-6&&(this.dDashRatio=0),this.dDashArray=1/i}setDashRatio(t){this.dDashRatio=t}setDashArray(t){this.dDashArray=t}setDash(t,e){this.dDashArray=t,this.dDashRatio=e,0==this.dLineWidth&&(this.dLineWidth=6,this.lineWidthByPixels=!0)}getDash(){return{dDashArray:this.dDashArray,dDashRatio:this.dDashRatio}}setDashLineDisplay(t){t?(this.dDashArray<1e-5&&(this.dDashArray=.03),this.dDashRatio<1e-5&&(this.dDashRatio=.1),0==this.dLineWidth&&(this.dLineWidth=6,this.lineWidthByPixels=!0)):(this.dDashArray=0,this.dDashRatio=0)}isDashLineDisplay(){return this.dDashArray>0&&this.dDashRatio>0}guid(){return this.sGuid}onEndGripEidt(){this.callEvent("onEndGripEidt")}onStartGripEidt(){return this.callEvent("onStartGripEidt")}addEvent(t,e){this._event[t]=e}removeEvent(t){this._event[t]=void 0}};
1
+ import _ from"lodash";import MxType from"../MxType";import store from"../store";export var DataType;!function(t){t[t.Default=0]="Default",t[t.Color=1]="Color",t[t.Vector2=2]="Vector2",t[t.Vector3=3]="Vector3",t[t.Vector4=4]="Vector4",t[t.Matrix3=5]="Matrix3",t[t.Matrix4=6]="Matrix4"}(DataType||(DataType={}));export const MXDBDATATYPE="datatype";const propertyDbKeys=["color","renderOrder","opacity","visible","userData","sGuid","dLineWidth","lineWidthByPixels","dDashArray","dDashRatio","layer"];function getDwgKeyVal(t,e){let i,r="";return _.isObject(e)?(i=e.default,r=e.key):"string"==typeof e&&(r=e),[r,void 0===t[r]?i:t[r]]}export default class MxDbEntity{constructor(){this.color=16777215,this.renderOrder=30,this.opacity=1,this.visible=!0,this.userData={},this.sGuid="",this.dLineWidth=0,this.lineWidthByPixels=!0,this.dDashArray=0,this.dDashRatio=0,this.layer="",this._event={}}initGuid(t){this.sGuid.length>0?console.log("mx: init guid error"):this.sGuid=t}dwgInHelp(t,e,i){let r=this;const s=t.type===MxType.MxCloneType.kMxFileClone,a=t=>{if(!t)return;const{value:e,[MXDBDATATYPE]:r}=t;switch(r){case DataType.Color:return new THREE.Color(...e);case DataType.Vector2:return new THREE.Vector2(...e);case DataType.Vector3:return new THREE.Vector3(...e);case DataType.Vector4:return new THREE.Vector4(...e);case DataType.Matrix3:return(new THREE.Matrix3).fromArray(e);case DataType.Matrix4:return(new THREE.Matrix4).fromArray(e)}return i&&i.getCacheVal?i.getCacheVal(t):void 0};function n(t){return t instanceof THREE.Color||t instanceof THREE.Vector2||t instanceof THREE.Vector3||t instanceof THREE.Vector4||t instanceof THREE.Matrix3||t instanceof THREE.Matrix4?t.clone():i&&i.getVal?i.getVal(t):void 0}return e.forEach(e=>{const[i,h]=getDwgKeyVal(t,e);r[i]=_.cloneDeepWith(h,s?a:n)}),!0}dwgOutHelp(t,e){const i=t=>t instanceof THREE.Color?{[MXDBDATATYPE]:DataType.Color,value:t.toArray()}:t instanceof THREE.Vector2?{[MXDBDATATYPE]:DataType.Vector2,value:t.toArray()}:t instanceof THREE.Vector3?{[MXDBDATATYPE]:DataType.Vector3,value:t.toArray()}:t instanceof THREE.Vector4?{[MXDBDATATYPE]:DataType.Vector4,value:t.toArray()}:t instanceof THREE.Matrix3?{[MXDBDATATYPE]:DataType.Matrix3,value:t.toArray()}:t instanceof THREE.Matrix4?{[MXDBDATATYPE]:DataType.Matrix4,value:t.toArray()}:void 0;let r=this;const s=t.type===MxType.MxCloneType.kMxFileClone;return e.forEach(e=>{const[a,n]=getDwgKeyVal(r,e);t[a]=s?_.cloneDeepWith(n,i):n}),t}callEvent(t,e){return void 0!=this._event[t]?this._event[t](e):void 0}create(t){return new(0,this.constructor)(t)}transformBy(t){}getGeomExtents(){return null}getImp(){return this.MxDbEntityImp}setNeedUpdateDisplay(t){let e=this.getImp();return!!e&&(t?e.upDisplay():e.setDirtyDisplay(!0),!0)}getMxObject(){let t=this.getImp();return t?t.getMxObject():null}onViewChange(){return!1}objectId(){let t=this.getImp();return t?t.objectId():0}erase(){let t=this.getImp();return!!t&&t.erase()}setLayer(t){let e=this.getImp();e&&e.nodifySetLayer(),this.layer=t}getLayer(){return this.layer}setColor(t){return this.color=t,this}getColor(){return this.color||16777215}clone(t){let e=this.create(),i={type:t||MxType.MxCloneType.kClone};return this.dwgOut(i),e.dwgIn(i),e.sGuid="",e}onDwgIn(t){this.color=t.color,this.renderOrder=t.renderOrder,this.opacity=t.opacity,this.visible=t.visible,t.userData?this.userData=JSON.parse(JSON.stringify(t.userData)):this.userData={},this.dLineWidth=t.lineWidth,this.lineWidthByPixels=t.lineWidthByPixels,this.dDashArray=t.dashArray,this.dDashRatio=t.dashRatio,this.layer=t.layer,t.guid&&(this.sGuid=t.guid)}onDwgOut(t){t.color=this.color,t.renderOrder=this.renderOrder,t.opacity=this.opacity,t.visible=this.visible,t.lineWidth=this.dLineWidth,t.lineWidthByPixels=this.lineWidthByPixels,t.dashArray=this.dDashArray,t.dashRatio=this.dDashRatio,t.layer=this.layer,t.guid=this.sGuid,Object.keys(this.userData).length>0&&(t.userData=this.userData)}rxInit(){store.state.MxFun.initMxDbEntityType(this)}setRenderOrder(t){this.renderOrder=t}getRenderOrder(){return this.renderOrder}setLineWidthByPixels(t){return this.lineWidthByPixels=t,this}getLineWidthByPixels(){return this.lineWidthByPixels}setLineWidth(t){return this.dLineWidth=t,this}getLineWidth(){return this.dLineWidth}getGetLength(){return 0}setDashLen(t){let e=this.getGetLength();if(e<1e-6||t<1e-6)return this;let i=Math.floor(e/t);return i<1e-6&&(this.dDashRatio=0),this.dDashArray=1/i,this}setDashRatio(t){return this.dDashRatio=t,this}setDashArray(t){return this.dDashArray=t,this}setDash(t,e){return this.dDashArray=t,this.dDashRatio=e,0==this.dLineWidth&&(this.dLineWidth=6,this.lineWidthByPixels=!0),this}getDash(){return{dDashArray:this.dDashArray,dDashRatio:this.dDashRatio}}setDashLineDisplay(t){return t?(this.dDashArray<1e-5&&(this.dDashArray=.03),this.dDashRatio<1e-5&&(this.dDashRatio=.1),0==this.dLineWidth&&(this.dLineWidth=6,this.lineWidthByPixels=!0)):(this.dDashArray=0,this.dDashRatio=0),this}isDashLineDisplay(){return this.dDashArray>0&&this.dDashRatio>0}guid(){return this.sGuid}onEndGripEidt(){this.callEvent("onEndGripEidt")}onStartGripEidt(){return this.callEvent("onStartGripEidt")}addEvent(t,e){this._event[t]=e}removeEvent(t){this._event[t]=void 0}};
@@ -0,0 +1,62 @@
1
+ import type McGiWorldDraw from "../McGiWorldDraw";
2
+ import MxDbEntity from "../MxDbEntity";
3
+ /***
4
+ * 渐变线段
5
+ * @augments MxDbEntity
6
+ * */
7
+ export default class MxDbGradientLine extends MxDbEntity {
8
+ /** 点集合 */
9
+ points: THREE.Vector3[];
10
+ /** 渐变色 */
11
+ colors: (THREE.Color | string | number)[];
12
+ /**
13
+ * 定义线两端的样式
14
+ * @access public
15
+ * */
16
+ linecap: 'butt' | 'round' | 'square';
17
+ /**
18
+ * 定义线连接节点的样式
19
+ * @access public
20
+ * */
21
+ linejoin: 'round' | 'bevel' | 'miter';
22
+ /**
23
+ * 定义线形状是否闭合,从而创建多边形或斑点
24
+ * @access public
25
+ * */
26
+ closed: boolean;
27
+ /**
28
+ * 曲线的类型: chordal: 弦线、 centripetal: 向心线、 catmullrom: Catmull-Rom曲线 默认:centripetal
29
+ * @access public
30
+ * */
31
+ curveType: 'chordal' | 'centripetal' | 'catmullrom';
32
+ /**
33
+ * 当curveType为catmullrom时,定义catmullrom的张力。 张力: 数值越大,曲线越弯曲。值为0将导致没有插值。默认值是0
34
+ * @access public
35
+ *
36
+ */
37
+ tension: number;
38
+ /**
39
+ * 如果没有提供张力,但bezierType赋值为'quadratic'| 'cubic',则使用点集合中的点绘制一条bezier线 默认: undefined
40
+ * @summary quadratic: 三维二次贝塞尔曲线 => 起点 – 中间的控制点 – 终点
41
+ * @summary cubic: 三维三次贝塞尔曲线 => 起点v – 第一个控制点 – 第二个控制点 – 终点
42
+ */
43
+ bezierType: 'quadratic' | 'cubic' | undefined;
44
+ protected curve?: THREE.CatmullRomCurve3 | THREE.CurvePath<THREE.Vector3>;
45
+ create(): MxDbGradientLine;
46
+ getTypeName(): string;
47
+ setPoints(points: THREE.Vector3[]): this;
48
+ setColors(colors: (THREE.Color | string | number)[]): this;
49
+ addColor(color: THREE.Color): this;
50
+ setLinecap(linecap: "butt" | "round" | "square"): void;
51
+ setClosed(closed: boolean): void;
52
+ setCurveType(curveType: "chordal" | "centripetal" | "catmullrom"): void;
53
+ setTension(tension: number): void;
54
+ setBezierType(bezierType: 'quadratic' | 'cubic'): void;
55
+ worldDraw(pWorldDraw: McGiWorldDraw): void;
56
+ getGripPoints(): THREE.Vector3[];
57
+ getPoints(): import("three").Vector3[];
58
+ moveGripPointsAt(index: number, offset: THREE.Vector3): boolean;
59
+ move(index: number, offset: THREE.Vector3): this;
60
+ dwgIn(obj: any): boolean;
61
+ dwgOut(obj: any): object;
62
+ }
@@ -0,0 +1 @@
1
+ import McGiWorldDrawType from"../McGiWorldDrawType";import MxDbEntity from"../MxDbEntity";function createCurvePath(e=!1){const t=new THREE.CurvePath;return t.autoClose=e,t}function createQuadraticBezierCurve3(e){let t=0,r=[];for(let i=0;i<e.length;i++){const i=e[t],n=e[++t]||i,s=e[++t]||n;if(!i||!n||!s)break;r.push(new THREE.QuadraticBezierCurve3(i,n,s))}return r}function createCubicBezierCurve3(e){let t=0,r=[];for(let i=0;i<e.length;i++){const i=e[t],n=e[++t]||i,s=e[++t]||n,o=e[++t]||s;if(!(i&&n&&s&&o))break;r.push(new THREE.CubicBezierCurve3(i,n,s,o))}return r}function getCurveColorGradientData(e,t){let r=0,i=[],n=[];const s=Number((1/t.length).toFixed(2));let o=new THREE.Color(t[r]),c=new THREE.Color(t[r+1]);for(let u=0,l=e.length;u<l;u++){const l=e[u],a=u/e.length;a/r>=s&&(r++,c.set(new THREE.Color(t[r]||t[--r]))),i.push(l.x,l.y,l.z||0),o.lerpHSL(c,a),n.push(o.r,o.g,o.b)}return[i,n]}function getColorGradientData(e,t){let r=[],i=[];for(let n=0,s=e.length;n<s;n++){const s=e[n];r.push(s.x,s.y,s.z||0);const o=new THREE.Color(t[n]);i.push(o.r,o.g,o.b)}return[r,i]}const propertyDbKeys=["points","colors","linecap","linejoin","closed","curveType","tension","bezierType"];export default class MxDbGradientLine extends MxDbEntity{constructor(){super(...arguments),this.linecap="round",this.linejoin="round",this.closed=!1,this.curveType="centripetal",this.tension=0,this.bezierType="quadratic"}create(){return new MxDbGradientLine}getTypeName(){return"MxDbGradientLine"}setPoints(e){return this.points=e,this}setColors(e){return this.colors=e,this}addColor(e){return this.colors.push(e),this}setLinecap(e){this.linecap=e}setClosed(e){this.closed=e}setCurveType(e){this.curveType=e}setTension(e){this.tension=e}setBezierType(e){this.bezierType=e}worldDraw(e){const t=e.getType();let r=this.getPoints();const{closed:i,curveType:n,tension:s,bezierType:o}=this,c=new THREE.BufferGeometry;let u=[],l=[];const a="cubic"===o,h="quadratic"===o;0!==s?this.curve=new THREE.CatmullRomCurve3(r,i,n,s):o?(this.curve=createCurvePath(i),a?this.curve.curves=createCubicBezierCurve3(r):h?this.curve.curves=createQuadraticBezierCurve3(r):this.curve=void 0):this.curve=void 0,this.curve&&(r=this.curve.getPoints(50));const{linecap:p,linejoin:d}=this;let v;if(this.colors&&this.colors.length>1){const e=i?[...this.colors,this.colors[0]]:this.colors;[u,l]=this.curve?getCurveColorGradientData(r,e):getColorGradientData(r,e),c.setAttribute("position",new THREE.Float32BufferAttribute(u,3)),c.setAttribute("color",new THREE.Float32BufferAttribute(l,3)),v=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,linecap:p,linejoin:d})}else c.setFromPoints(r),v=new THREE.LineBasicMaterial({color:this.color,linecap:p,linejoin:d});const E=i?new THREE.LineLoop(c,v):new THREE.Line(c,v);if(e.drawEntity(E),(t===McGiWorldDrawType.kSelectDraw||t===McGiWorldDrawType.kDynDragDraw)&&this.curve){let t=this.getPoints();const r=e.getLineWidth();e.setLineWidth(1),e.drawLines(t),e.setLineWidth(r)}}getGripPoints(){return this.getPoints()}getPoints(){return this.closed?[...this.points,this.points[0]]:this.points}moveGripPointsAt(e,t){return this.move(e,t),!0}move(e,t){return this.points[e].add(t),this}dwgIn(e){return this.dwgInHelp(e,propertyDbKeys),this.curve=e.curve,!0}dwgOut(e){return this.dwgOutHelp(e,propertyDbKeys),e.curve=this.curve,e}};
@@ -1,5 +1,4 @@
1
1
  /** @module MxDbLeadComment*/
2
- import * as THREE from 'three';
3
2
  import McGiWorldDraw from '../McGiWorldDraw';
4
3
  import MxDbEntity from '../MxDbEntity';
5
4
  /**
@@ -1 +1 @@
1
- import*as THREE from"three";import MxDbEntity from"../MxDbEntity";import MxThreeJS from"../MxThreeJS";export default class MxDbLeadComment extends MxDbEntity{constructor(){super(...arguments),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.text="",this.textHeight=20,this.textWidth=0,this.fixedSize=!1}getTypeName(){return"MxDbLeadComment"}create(){return new MxDbLeadComment}worldDraw(t){if(t.drawLine(this.point1,this.point2),this.text.length>0){const e=new THREE.Vector3;let i=this.textHeight,h=this.textWidth,n=t.getMxObject();this.fixedSize&&(i=n.screenCoordLong2Doc(i),h=n.screenCoordLong2Doc(h));let s=MxThreeJS.clacTextSpriteSize(this.text,i,h);e.x=this.point2.x+.5*s.textwidth,e.y=this.point2.y+.5*s.allTextHeight,t.drawText(this.text,i,0,e,h);const o=new THREE.Vector3;o.x=this.point2.x+s.textwidth,o.y=this.point2.y,t.drawLine(o,this.point2)}}getGripPoints(){let t=[];return t.push(this.point1),t.push(this.point2),t}moveGripPointsAt(t,e){return 0==t?this.point1.add(e):1==t&&this.point2.add(e),!0}dwgIn(t){return this.onDwgIn(t),this.point1.copy(t.point1),this.point2.copy(t.point2),this.text=t.text.substr(0),this.textHeight=t.textHeight,t.textWidth&&(this.textWidth=t.textWidth),this.fixedSize=t.fixedSize,!0}dwgOut(t){return this.onDwgOut(t),t.point1=this.point1,t.point2=this.point2,t.textHeight=this.textHeight,t.text=this.text,t.textWidth=this.textWidth,t.fixedSize=this.fixedSize,t}onViewChange(){return!!this.fixedSize&&(this.setNeedUpdateDisplay(!1),!0)}};
1
+ import MxDbEntity from"../MxDbEntity";import MxThreeJS from"../MxThreeJS";export default class MxDbLeadComment extends MxDbEntity{constructor(){super(...arguments),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.text="",this.textHeight=20,this.textWidth=0,this.fixedSize=!1}getTypeName(){return"MxDbLeadComment"}create(){return new MxDbLeadComment}worldDraw(t){if(t.drawLine(this.point1,this.point2),this.text.length>0){const e=new THREE.Vector3;let i=this.textHeight,h=this.textWidth,n=t.getMxObject();this.fixedSize&&(i=n.screenCoordLong2Doc(i),h=n.screenCoordLong2Doc(h));let s=MxThreeJS.clacTextSpriteSize(this.text,i,h);e.x=this.point2.x+.5*s.textwidth,e.y=this.point2.y+.5*s.allTextHeight,t.drawText(this.text,i,0,e,h);const o=new THREE.Vector3;o.x=this.point2.x+s.textwidth,o.y=this.point2.y,t.drawLine(o,this.point2)}}getGripPoints(){let t=[];return t.push(this.point1),t.push(this.point2),t}moveGripPointsAt(t,e){return 0==t?this.point1.add(e):1==t&&this.point2.add(e),!0}dwgIn(t){return this.onDwgIn(t),this.point1.copy(t.point1),this.point2.copy(t.point2),this.text=t.text.substr(0),this.textHeight=t.textHeight,t.textWidth&&(this.textWidth=t.textWidth),this.fixedSize=t.fixedSize,!0}dwgOut(t){return this.onDwgOut(t),t.point1=this.point1,t.point2=this.point2,t.textHeight=this.textHeight,t.text=this.text,t.textWidth=this.textWidth,t.fixedSize=this.fixedSize,t}onViewChange(){return!!this.fixedSize&&(this.setNeedUpdateDisplay(!1),!0)}};
@@ -74,14 +74,14 @@ export default class MxDbSVG extends MxDbEntity {
74
74
  private calcSvgPosition;
75
75
  dwgIn(obj: any): boolean;
76
76
  dwgOut(obj: any): object;
77
- create(): MxDbEntity;
77
+ create(): MxDbSVG;
78
78
  transformBy(mat: THREE.Matrix4): void;
79
79
  getTypeName(): string;
80
80
  /**
81
81
  * 设置颜色
82
82
  * @param color 颜色值
83
83
  * */
84
- setColor(color: number | string | THREE.Color): void;
84
+ setColor(color: number | string | THREE.Color): this;
85
85
  /**
86
86
  * 设置svg对象
87
87
  * */