mxdraw 0.1.5 → 0.1.9

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 (33) hide show
  1. package/dist/lib/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.js +18 -1
  2. package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +25 -12
  3. package/dist/lib/MxModule/MxDbImage/MxDbImage.js +18 -6
  4. package/dist/lib/MxModule/MxDbRect/MxDbRect.js +140 -86
  5. package/dist/lib/MxModule/MxDbSVG/MxDbSVG.js +49 -32
  6. package/dist/lib/MxModule/MxDbSVGText/MxDbSVGText.js +18 -0
  7. package/dist/lib/MxModule/MxDbSVGText/index.js +5 -0
  8. package/dist/lib/MxModule/MxFun/MxFun.js +20 -2
  9. package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +2 -0
  10. package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +61 -45
  11. package/dist/lib/MxModule/store/store.js +1 -3
  12. package/dist/lib/MxModule/useCanvasResizeListener/useCanvasResizeListener.js +16 -9
  13. package/dist/lib/mxdraw.js +4 -1
  14. package/dist/lib/tools/dynamicImport/index.js +5 -5
  15. package/dist/lib/tools/three/index.js +21 -15
  16. package/dist/lib/types/MxCADObject.js +0 -1
  17. package/dist/mxdraw.es5.js +3 -3
  18. package/dist/mxdraw.es5.js.map +1 -1
  19. package/dist/mxdraw.umd.js +3 -3
  20. package/dist/mxdraw.umd.js.map +1 -1
  21. package/dist/types/MxModule/McGiWorldDraw/index.d.ts +1 -1
  22. package/dist/types/MxModule/McGiWorldDrawType/index.d.ts +1 -1
  23. package/dist/types/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.d.ts +1 -1
  24. package/dist/types/MxModule/MxDbEntity/MxDbEntity.d.ts +12 -4
  25. package/dist/types/MxModule/MxDbRect/MxDbRect.d.ts +21 -42
  26. package/dist/types/MxModule/MxDbSVG/MxDbSVG.d.ts +5 -9
  27. package/dist/types/MxModule/MxDbSVGText/MxDbSVGText.d.ts +7 -0
  28. package/dist/types/MxModule/MxDbSVGText/index.d.ts +3 -0
  29. package/dist/types/MxModule/MxFun/MxFun.d.ts +14 -1
  30. package/dist/types/MxModule/store/store.d.ts +0 -1
  31. package/dist/types/mxdraw.d.ts +3 -1
  32. package/dist/types/types/MxCADObject.d.ts +5 -5
  33. package/package.json +1 -1
@@ -109,7 +109,24 @@ var MrxDbgUiPrPoint = /** @class */ (function () {
109
109
  * @returns void
110
110
  */
111
111
  MrxDbgUiPrPoint.prototype.go = function (retcall) {
112
- return _MrxDbgUiPrPoint.go(retcall);
112
+ if (retcall) {
113
+ _MrxDbgUiPrPoint.go(retcall);
114
+ return new Promise(function (resolve, reject) {
115
+ resolve(null);
116
+ });
117
+ }
118
+ else {
119
+ return new Promise(function (resolve, reject) {
120
+ _MrxDbgUiPrPoint.go(function (status) {
121
+ if (status != 0) {
122
+ resolve(null);
123
+ }
124
+ else {
125
+ resolve(_MrxDbgUiPrPoint.value());
126
+ }
127
+ });
128
+ });
129
+ }
113
130
  };
114
131
  /**
115
132
  * 动态拖动,连续取点,直到ESC退出。
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ ///////////////////////////////////////////////////////////////////////////////
3
+ //版权所有(C)2002-2022,成都梦想凯德科技有限公司。
4
+ //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
5
+ //此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
6
+ ///////////////////////////////////////////////////////////////////////////////
2
7
  /** @module MxDbEntity*/
3
8
  Object.defineProperty(exports, "__esModule", { value: true });
4
9
  var MxType_1 = require("../MxType");
@@ -25,8 +30,16 @@ var store_1 = require("../store/store");
25
30
  */
26
31
  var MxDbEntity = /** @class */ (function () {
27
32
  function MxDbEntity() {
28
- this.iColor = 0xffffff;
29
- this.iRenderOrder = 30;
33
+ this.color = 0xffffff;
34
+ this.renderOrder = 30;
35
+ /**
36
+ * opacity 设置透明度 0 ~ 1,1表示完全不透明,0表示全透明.
37
+ * */
38
+ this.opacity = 1;
39
+ /**
40
+ * visible 该矩形对象是否可见
41
+ * */
42
+ this.visible = true;
30
43
  }
31
44
  /**
32
45
  * 自定义实体的坐标变换.
@@ -111,8 +124,8 @@ var MxDbEntity = /** @class */ (function () {
111
124
  *
112
125
  * ```
113
126
  */
114
- MxDbEntity.prototype.setColor = function (iColor) {
115
- this.iColor = iColor;
127
+ MxDbEntity.prototype.setColor = function (color) {
128
+ this.color = color;
116
129
  };
117
130
  /**
118
131
  * 得到颜色
@@ -124,7 +137,7 @@ var MxDbEntity = /** @class */ (function () {
124
137
  * ```
125
138
  */
126
139
  MxDbEntity.prototype.getColor = function () {
127
- return this.iColor;
140
+ return this.color;
128
141
  };
129
142
  /**
130
143
  * 复制对象。
@@ -147,16 +160,16 @@ var MxDbEntity = /** @class */ (function () {
147
160
  * @param obj dwgIn抽象方法的回调数据
148
161
  */
149
162
  MxDbEntity.prototype.onDwgIn = function (obj) {
150
- this.iColor = obj['iColor'];
151
- this.iRenderOrder = obj['iRenderOrder'];
163
+ this.color = obj['color'];
164
+ this.renderOrder = obj['renderOrder'];
152
165
  };
153
166
  /**
154
167
  * 自定义对象内部数据输出同步(实现dwgIn抽象方法 必须在实现中调用 this.onDwgIn()
155
168
  * @param obj dwgOut抽象方法的回调数据
156
169
  */
157
170
  MxDbEntity.prototype.onDwgOut = function (obj) {
158
- obj['iColor'] = this.iColor;
159
- obj['iRenderOrder'] = this.iRenderOrder;
171
+ obj['color'] = this.color;
172
+ obj['renderOrder'] = this.renderOrder;
160
173
  };
161
174
  /**
162
175
  * 初始自定义对象的类型信息.
@@ -180,8 +193,8 @@ var MxDbEntity = /** @class */ (function () {
180
193
  *
181
194
  * ```
182
195
  */
183
- MxDbEntity.prototype.setRenderOrder = function (iRenderOrder) {
184
- this.iRenderOrder = iRenderOrder;
196
+ MxDbEntity.prototype.setRenderOrder = function (renderOrder) {
197
+ this.renderOrder = renderOrder;
185
198
  };
186
199
  /**
187
200
  * 得到显示顺序
@@ -193,7 +206,7 @@ var MxDbEntity = /** @class */ (function () {
193
206
  * ```
194
207
  */
195
208
  MxDbEntity.prototype.getRenderOrder = function () {
196
- return this.iRenderOrder;
209
+ return this.renderOrder;
197
210
  };
198
211
  return MxDbEntity;
199
212
  }());
@@ -47,11 +47,11 @@ var MxDbImage = /** @class */ (function (_super) {
47
47
  var _this = this;
48
48
  var pt3 = new THREE.Vector3(this.pt1.x, this.pt2.y);
49
49
  var pt4 = new THREE.Vector3(this.pt2.x, this.pt1.y);
50
- pWorldDraw.drawLine(this.pt1, pt3);
51
- pWorldDraw.drawLine(pt3, this.pt2);
52
- pWorldDraw.drawLine(this.pt2, pt4);
53
- pWorldDraw.drawLine(pt4, this.pt1);
54
50
  if (pWorldDraw.getType() == 1) {
51
+ pWorldDraw.drawSelectLine(this.pt1, pt3);
52
+ pWorldDraw.drawSelectLine(pt3, this.pt2);
53
+ pWorldDraw.drawSelectLine(this.pt2, pt4);
54
+ pWorldDraw.drawSelectLine(pt4, this.pt1);
55
55
  // 图片正常的显示绘制.
56
56
  if (this.material) {
57
57
  var w = Math.abs(this.pt1.x - this.pt2.x);
@@ -70,7 +70,7 @@ var MxDbImage = /** @class */ (function (_super) {
70
70
  }
71
71
  else if (this.imagePath.length > 0 && this.isLoadMaterialFromPath) {
72
72
  var myThis_1 = this;
73
- MxFun_1.default.loadImageMaterial('./models/img/mxcad.jpg', function (material) {
73
+ MxFun_1.default.loadImageMaterial(this.imagePath, function (material) {
74
74
  _this.isLoadMaterialFromPath = false;
75
75
  if (!material) {
76
76
  return;
@@ -81,6 +81,12 @@ var MxDbImage = /** @class */ (function (_super) {
81
81
  });
82
82
  }
83
83
  }
84
+ else {
85
+ pWorldDraw.drawLine(this.pt1, pt3);
86
+ pWorldDraw.drawLine(pt3, this.pt2);
87
+ pWorldDraw.drawLine(this.pt2, pt4);
88
+ pWorldDraw.drawLine(pt4, this.pt1);
89
+ }
84
90
  };
85
91
  MxDbImage.prototype.setImagePath = function (sPath) {
86
92
  this.imagePath = sPath;
@@ -110,6 +116,8 @@ var MxDbImage = /** @class */ (function (_super) {
110
116
  var ret = [];
111
117
  ret.push(this.pt1);
112
118
  ret.push(this.pt2);
119
+ var midPt = new THREE.Vector3(this.pt1.x + (this.pt2.x - this.pt1.x) * 0.5, this.pt1.y + (this.pt2.y - this.pt1.y) * 0.5);
120
+ ret.push(midPt);
113
121
  return ret;
114
122
  };
115
123
  // 图片的夹点拖动编辑.
@@ -117,7 +125,11 @@ var MxDbImage = /** @class */ (function (_super) {
117
125
  if (index == 0) {
118
126
  this.pt1.add(offset);
119
127
  }
120
- else if ((index = 1)) {
128
+ else if (index == 1) {
129
+ this.pt2.add(offset);
130
+ }
131
+ else if (index == 2) {
132
+ this.pt1.add(offset);
121
133
  this.pt2.add(offset);
122
134
  }
123
135
  return true;
@@ -26,10 +26,17 @@ var __assign = (this && this.__assign) || function () {
26
26
  return __assign.apply(this, arguments);
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ ///////////////////////////////////////////////////////////////////////////////
30
+ //版权所有(C)2002-2022,成都梦想凯德科技有限公司。
31
+ //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
32
+ //此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
33
+ ///////////////////////////////////////////////////////////////////////////////
29
34
  var MxDbEntity_1 = require("../MxDbEntity");
30
35
  var three_1 = require("three");
31
36
  var index_1 = require("../../tools/three/index");
37
+ // import * as _ from 'lodash'
32
38
  var MxFun_1 = require("../MxFun");
39
+ var McGiWorldDrawType_1 = require("../McGiWorldDrawType");
33
40
  /**
34
41
  * MxRectEntity 矩形对象.
35
42
  */
@@ -37,6 +44,8 @@ var MxDbRect = /** @class */ (function (_super) {
37
44
  __extends(MxDbRect, _super);
38
45
  function MxDbRect() {
39
46
  var _this = _super !== null && _super.apply(this, arguments) || this;
47
+ // 圆角半径
48
+ _this.cornerRadius = [];
40
49
  /**
41
50
  * pt1: 构成矩形的第一个点
42
51
  * */
@@ -46,122 +55,109 @@ var MxDbRect = /** @class */ (function (_super) {
46
55
  * */
47
56
  _this.pt2 = new three_1.Vector3();
48
57
  /**
49
- * width: 在绘制时自动计算矩形像素宽度 单位px
50
- * */
51
- _this.width = 0;
52
- /**
53
- * height: 在绘制时自动计算矩形像素高度 单位px
54
- * */
55
- _this.height = 0;
56
- /**
57
- * cornerRadius(优先级大于radius属性): 圆角的半径 如[3, 2, 1, 4]分别对应左上角圆角半径3 右上角2 右下角1 左下角4
58
+ * 是否需要颜色填充.
58
59
  * */
59
- _this.cornerRadius = [];
60
- /**
61
- * transparent 开启透明度
62
- * */
63
- _this.transparent = true;
64
- /**
65
- * opacity 设置透明度 0 ~ 1
66
- * */
67
- _this.opacity = 1;
68
- /**
69
- * visible 该矩形对象是否可见
70
- * */
71
- _this.visible = true;
60
+ _this.isSolidColorFill = false;
61
+ _this.isLoadMaterialFromPath = true;
62
+ _this.material = null;
72
63
  return _this;
73
64
  }
74
65
  MxDbRect.prototype.worldDraw = function (pWorldDraw) {
75
66
  var _this = this;
76
67
  // 根据第一个点和对角点 计算矩形的四个点位
77
68
  var points = (0, index_1.computeRectPoints)(this.pt1, this.pt2);
78
- // 计算圆角顶点坐标
79
- if (this.cornerRadius.length <= 0 && this.radius) {
80
- this.cornerRadius = [
81
- MxFun_1.default.screenCoordLong2Doc(this.radius),
82
- MxFun_1.default.screenCoordLong2Doc(this.radius),
83
- MxFun_1.default.screenCoordLong2Doc(this.radius),
84
- MxFun_1.default.screenCoordLong2Doc(this.radius)
85
- ];
86
- }
87
69
  if (this.cornerRadius.length > 0) {
88
70
  points = (0, index_1.getToGenerateRoundedCorners)(points, this.cornerRadius);
89
71
  }
90
- var geometry;
91
- var material;
92
- var line = new three_1.Object3D();
72
+ if (pWorldDraw.getType() != McGiWorldDrawType_1.default.kWorldDraw) {
73
+ // 动态拖动绘制,或选择绘制 。
74
+ // 组成闭合区域。
75
+ points.push(points[0]);
76
+ pWorldDraw.drawLines(points);
77
+ return;
78
+ }
93
79
  // 公共的material参数
94
80
  var materialParam = {
95
- transparent: this.transparent,
81
+ transparent: true,
82
+ depthTest: false,
96
83
  opacity: this.opacity,
97
84
  visible: this.visible
98
85
  };
99
86
  // 如果是填充模式
100
- if (this.fillColor || this.fillImageSrc) {
87
+ if (this.isSolidColorFill) {
101
88
  // 三维坐标转二位坐标
102
89
  points = points.map(function (_a) {
103
90
  var x = _a.x, y = _a.y;
104
91
  return new three_1.Vector2(x, y);
105
92
  });
106
93
  // 计算矩形宽高
94
+ var geometry = void 0;
107
95
  geometry = new three_1.ShapeGeometry(new three_1.Shape(points));
108
- geometry.computeBoundingBox();
109
- var size = new three_1.Vector3();
110
- geometry.boundingBox.getSize(size);
111
- this.width = MxFun_1.default.docCoord2Screen(size.x).x;
112
- this.height = MxFun_1.default.docCoord2Screen(size.y).x;
113
- // 如果是图片填充
114
- if (this.fillImageSrc) {
115
- var imgSrc = this.fillImageSrc;
116
- MxFun_1.default.loadImageMaterial(imgSrc, function (mate) {
117
- if (!mate)
118
- return;
119
- material = mate;
120
- geometry = new three_1.ShapeGeometry(new three_1.Shape(points));
121
- // 修复集合体的uv坐标
122
- geometry = (0, index_1.repairGeometryFaceVertexUvs)(geometry);
96
+ // 颜色填充
97
+ var material = new three_1.MeshBasicMaterial(__assign({ color: this.filter
98
+ ? this.filter._getFilterColor(this.color, this.opacity)
99
+ : new three_1.Color(this.color) }, materialParam));
100
+ var mash = new three_1.Mesh(geometry, material);
101
+ pWorldDraw.drawEntity(mash);
102
+ }
103
+ else if (this.fillImageSrc) {
104
+ // 图片填充.
105
+ if (this.material) {
106
+ // 三维坐标转二位坐标
107
+ points = points.map(function (_a) {
108
+ var x = _a.x, y = _a.y;
109
+ return new three_1.Vector2(x, y);
110
+ });
111
+ var material = this.material;
112
+ var geometry = new three_1.ShapeGeometry(new three_1.Shape(points));
113
+ // 修复集合体的uv坐标
114
+ geometry = (0, index_1.repairGeometryFaceVertexUvs)(geometry);
115
+ // 有滤镜对象使用自定义着色器
116
+ if (this.filter) {
123
117
  // 纹理属性设置
118
+ var mate = material;
124
119
  var map = mate.map;
125
- if (_this.fillImageParam) {
126
- if (_this.fillImageParam.center)
127
- map.center = _this.fillImageParam.center;
128
- if (_this.fillImageParam.offset)
129
- map.offset = _this.fillImageParam.offset;
130
- if (_this.fillImageParam.repeat)
131
- map.repeat = _this.fillImageParam.repeat;
132
- if (_this.fillImageParam.rotation)
133
- map.rotation = _this.fillImageParam.rotation;
120
+ if (this.fillImageParam) {
121
+ if (this.fillImageParam.center)
122
+ map.center = this.fillImageParam.center;
123
+ if (this.fillImageParam.offset)
124
+ map.offset = this.fillImageParam.offset;
125
+ if (this.fillImageParam.repeat)
126
+ map.repeat = this.fillImageParam.repeat;
127
+ if (this.fillImageParam.rotation)
128
+ map.rotation = this.fillImageParam.rotation;
134
129
  }
135
- // 有滤镜对象使用自定义着色器
136
- if (_this.filter) {
137
- var data = _this.filter._getFilterShaderData(map);
138
- material = new three_1.ShaderMaterial(__assign(__assign({}, data), materialParam));
130
+ var data = this.filter._getFilterShaderData(map);
131
+ material = new three_1.ShaderMaterial(__assign(__assign({}, data), materialParam));
132
+ }
133
+ // 设置材质属性
134
+ material.depthTest = false;
135
+ material.transparent = true;
136
+ material.opacity = this.opacity;
137
+ material.visible = this.visible;
138
+ var mash = new three_1.Mesh(geometry, material);
139
+ pWorldDraw.drawEntity(mash);
140
+ }
141
+ else if (this.fillImageSrc.length > 0 && this.isLoadMaterialFromPath) {
142
+ var myThis_1 = this;
143
+ MxFun_1.default.loadImageMaterial(this.fillImageSrc, function (material) {
144
+ _this.isLoadMaterialFromPath = false;
145
+ if (!material) {
146
+ return;
139
147
  }
140
- // 设置材质属性
141
- material.depthTest = false;
142
- material.transparent = _this.transparent;
143
- material.opacity = _this.opacity;
144
- material.visible = _this.visible;
145
- line = new three_1.Mesh(geometry, material);
146
- pWorldDraw.drawEntity(line);
148
+ myThis_1.material = material;
149
+ myThis_1.setNeedUpdateDisplay();
150
+ MxFun_1.default.updateDisplay();
147
151
  });
148
- return;
149
- }
150
- else {
151
- // 颜色填充
152
- material = new three_1.MeshBasicMaterial(__assign({ color: this.filter
153
- ? this.filter._getFilterColor(this.fillColor, this.opacity)
154
- : new three_1.Color(this.fillColor) }, materialParam));
155
- line = new three_1.Mesh(geometry, material);
156
152
  }
157
153
  }
158
154
  else {
159
155
  // 线框模式
160
- geometry = new three_1.BufferGeometry().setFromPoints(points);
161
- material = new three_1.LineBasicMaterial(__assign({ color: this.getColor() }, materialParam));
162
- line = new three_1.LineLoop(geometry, material);
156
+ var geometry = new three_1.BufferGeometry().setFromPoints(points);
157
+ var material = new three_1.LineBasicMaterial(__assign({ color: this.getColor() }, materialParam));
158
+ var line = new three_1.LineLoop(geometry, material);
159
+ pWorldDraw.drawEntity(line);
163
160
  }
164
- pWorldDraw.drawEntity(line);
165
161
  };
166
162
  MxDbRect.prototype.getGripPoints = function () {
167
163
  var ret = [];
@@ -190,17 +186,23 @@ var MxDbRect = /** @class */ (function (_super) {
190
186
  this.onDwgIn(obj);
191
187
  this.pt1.copy(obj['pt1']);
192
188
  this.pt2.copy(obj['pt2']);
189
+ this.isSolidColorFill = obj['isSolidColorFill'];
190
+ this.fillImageSrc = obj['fillImageSrc'];
191
+ this.fillImageParam = obj['fillImageParam'];
193
192
  this.cornerRadius = obj['cornerRadius'];
194
- this.radius = obj['radius'];
195
193
  this.filter = obj['filter'];
194
+ this.isLoadMaterialFromPath = true;
195
+ this.material = null;
196
196
  return true;
197
197
  };
198
198
  MxDbRect.prototype.dwgOut = function (obj) {
199
199
  this.onDwgOut(obj);
200
200
  obj['pt1'] = this.pt1;
201
201
  obj['pt2'] = this.pt2;
202
+ obj['isSolidColorFill'] = this.isSolidColorFill;
203
+ obj['fillImageSrc'] = this.fillImageSrc;
204
+ obj['fillImageParam'] = this.fillImageParam;
202
205
  obj['cornerRadius'] = this.cornerRadius;
203
- obj['radius'] = this.radius;
204
206
  obj['filter'] = this.filter;
205
207
  return obj;
206
208
  };
@@ -211,8 +213,60 @@ var MxDbRect = /** @class */ (function (_super) {
211
213
  this.pt1.applyMatrix4(mat);
212
214
  this.pt2.applyMatrix4(mat);
213
215
  };
216
+ /**
217
+ * setRadius 设置圆角 圆角的半径 如[3, 2, 1, 4]分别对应左上角圆角半径3 右上角2 右下角1 左下角4
218
+ * @param { number | number[] } radius 圆角半径 为数组时[3, 2, 1, 4]分别对应左上角圆角半径3 右上角2 右下角1 左下角4; 或者直接设置半径值 则四个角统一半径
219
+ * */
220
+ MxDbRect.prototype.setRadius = function (radius, isScreenCoord) {
221
+ if (isScreenCoord === void 0) { isScreenCoord = true; }
222
+ if (radius instanceof Array) {
223
+ this.cornerRadius = radius.map(function (r) {
224
+ if (isScreenCoord)
225
+ return MxFun_1.default.screenCoordLong2Doc(r);
226
+ else
227
+ return r;
228
+ });
229
+ }
230
+ else {
231
+ if (radius > 0) {
232
+ if (isScreenCoord) {
233
+ this.cornerRadius = [
234
+ MxFun_1.default.screenCoordLong2Doc(radius),
235
+ MxFun_1.default.screenCoordLong2Doc(radius),
236
+ MxFun_1.default.screenCoordLong2Doc(radius),
237
+ MxFun_1.default.screenCoordLong2Doc(radius)
238
+ ];
239
+ }
240
+ else {
241
+ this.cornerRadius = [radius, radius, radius, radius];
242
+ }
243
+ }
244
+ else {
245
+ this.cornerRadius = [];
246
+ }
247
+ }
248
+ };
214
249
  MxDbRect.prototype.getTypeName = function () {
215
- return 'MxRectEntity';
250
+ return 'MxDbRect';
251
+ };
252
+ MxDbRect.prototype.getFilter = function () {
253
+ return this.filter;
254
+ };
255
+ MxDbRect.prototype.setFilter = function (filter) {
256
+ this.filter = filter;
257
+ this.isLoadMaterialFromPath = true;
258
+ this.material = null;
259
+ };
260
+ MxDbRect.prototype.setFillImagePath = function (sPath) {
261
+ this.fillImageSrc = sPath;
262
+ this.isLoadMaterialFromPath = true;
263
+ this.material = null;
264
+ if (this.fillImageSrc) {
265
+ this.isSolidColorFill = false;
266
+ }
267
+ };
268
+ MxDbRect.prototype.getFillImagePath = function () {
269
+ return this.fillImageSrc;
216
270
  };
217
271
  return MxDbRect;
218
272
  }(MxDbEntity_1.default));
@@ -23,6 +23,7 @@ var __extends = (this && this.__extends) || (function () {
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  var THREE = require("three");
25
25
  var MxDbEntity_1 = require("../MxDbEntity");
26
+ var MxDbSVGText_1 = require("../MxDbSVGText");
26
27
  var MxFun_1 = require("../MxFun");
27
28
  var MxThreeJS_1 = require("../MxThreeJS");
28
29
  var MxType_1 = require("../MxType");
@@ -39,17 +40,18 @@ var MxDbSVG = /** @class */ (function (_super) {
39
40
  _this.svgAlignmentRatio = new THREE.Vector2(0, 0);
40
41
  _this.isSvgDirtyLocation = false;
41
42
  _this.isLoadFromPath = true;
42
- _this.txtPos = new THREE.Vector3();
43
- _this.txt = '';
44
- _this.txtHeight = 1;
43
+ _this.aryText = [];
45
44
  return _this;
46
45
  }
47
46
  MxDbSVG.prototype.worldDraw = function (pWorldDraw) {
47
+ var _this = this;
48
48
  this.calcSvgPosition();
49
- if (this.txt.length > 0) {
50
- var posTxt = new THREE.Vector3(this.txtPos.x, this.txtPos.y, 0);
51
- pWorldDraw.drawText(this.txt, this.txtHeight, 0, posTxt);
52
- }
49
+ this.aryText.forEach(function (txt) {
50
+ if (txt.txt.length > 0) {
51
+ var posTxt = new THREE.Vector3(txt.txtPos.x, txt.txtPos.y, 0);
52
+ pWorldDraw.drawText(txt.txt, txt.txtHeight, 0, posTxt);
53
+ }
54
+ });
53
55
  var svgPosX = this.svgPos.x - this.svgSize.x * this.svgAlignmentRatio.x;
54
56
  var svgPosY = this.svgPos.y - this.svgSize.y * this.svgAlignmentRatio.y;
55
57
  var pt1 = new THREE.Vector3(svgPosX, svgPosY, 0);
@@ -68,9 +70,12 @@ var MxDbSVG = /** @class */ (function (_super) {
68
70
  obj.scale.y = myThis_1.svgSize.y / (box.max.y - box.min.y);
69
71
  obj.scale.z = obj.scale.x;
70
72
  myThis_1.isSvgDirtyLocation = true;
73
+ var color_1 = new THREE.Color(_this.color);
71
74
  obj.traverse(function (child) {
72
75
  if (child.material) {
76
+ child.material = child.material.clone();
73
77
  child.material.transparent = true;
78
+ child.material.color = color_1;
74
79
  }
75
80
  });
76
81
  //this.svgPos.multiply
@@ -121,24 +126,16 @@ var MxDbSVG = /** @class */ (function (_super) {
121
126
  MxDbSVG.prototype.getSvgAlignmentRatio = function () {
122
127
  return this.svgAlignmentRatio;
123
128
  };
124
- //
125
- MxDbSVG.prototype.setTextHeight = function (height) {
126
- this.txtHeight = height;
127
- };
128
- MxDbSVG.prototype.getTextHeight = function () {
129
- return this.txtHeight;
130
- };
131
- MxDbSVG.prototype.setText = function (txt) {
132
- this.txt = txt;
133
- };
134
- MxDbSVG.prototype.getText = function () {
135
- return this.txt;
136
- };
137
- MxDbSVG.prototype.setTextPostion = function (pos) {
138
- this.txtPos = pos;
129
+ MxDbSVG.prototype.getText = function (index) {
130
+ if (index < this.aryText.length) {
131
+ return this.aryText[index];
132
+ }
133
+ else {
134
+ return null;
135
+ }
139
136
  };
140
- MxDbSVG.prototype.getTextPostion = function () {
141
- return this.txtPos;
137
+ MxDbSVG.prototype.addText = function (txt) {
138
+ this.aryText.push(txt);
142
139
  };
143
140
  MxDbSVG.prototype.getGripPoints = function () {
144
141
  var ret = [];
@@ -148,7 +145,9 @@ var MxDbSVG = /** @class */ (function (_super) {
148
145
  MxDbSVG.prototype.moveGripPointsAt = function (index, offset) {
149
146
  if (index == 0) {
150
147
  this.svgPos.add(offset);
151
- this.txtPos.add(offset);
148
+ this.aryText.forEach(function (txt) {
149
+ txt.txtPos.add(offset);
150
+ });
152
151
  }
153
152
  this.isSvgDirtyLocation = true;
154
153
  return true;
@@ -162,6 +161,7 @@ var MxDbSVG = /** @class */ (function (_super) {
162
161
  this.svg.position.y = this.svgPos.y - this.svgSize.y * this.svgAlignmentRatio.y;
163
162
  };
164
163
  MxDbSVG.prototype.dwgIn = function (obj) {
164
+ var _this = this;
165
165
  this.onDwgIn(obj);
166
166
  if (obj.type == MxType_1.default.MxCloneType.kClone && obj['svg']) {
167
167
  this.svg = obj['svg'].clone();
@@ -173,9 +173,15 @@ var MxDbSVG = /** @class */ (function (_super) {
173
173
  this.isSvgDirtyLocation = true;
174
174
  if (!this.svg)
175
175
  this.isLoadFromPath = true;
176
- this.txt = obj['txt'];
177
- this.txtHeight = obj['txtHeight'];
178
- this.txtPos.copy(obj['txtPos']);
176
+ var aryText = obj['txts'];
177
+ this.aryText = [];
178
+ aryText.forEach(function (txt) {
179
+ var copyTxt = new MxDbSVGText_1.default();
180
+ copyTxt.txt = txt.txt;
181
+ copyTxt.txtHeight = txt.txtHeight;
182
+ copyTxt.txtPos.copy(txt.txtPos);
183
+ _this.aryText.push(copyTxt);
184
+ });
179
185
  return true;
180
186
  };
181
187
  MxDbSVG.prototype.dwgOut = function (obj) {
@@ -187,9 +193,7 @@ var MxDbSVG = /** @class */ (function (_super) {
187
193
  obj['svgPos'] = this.svgPos;
188
194
  obj['svgSize'] = this.svgSize;
189
195
  obj['svgAlignmentRatio'] = this.svgAlignmentRatio;
190
- obj['txt'] = this.txt;
191
- obj['txtHeight'] = this.txtHeight;
192
- obj['txtPos'] = this.txtPos;
196
+ obj['txts'] = this.aryText;
193
197
  return obj;
194
198
  };
195
199
  MxDbSVG.prototype.create = function () {
@@ -197,12 +201,25 @@ var MxDbSVG = /** @class */ (function (_super) {
197
201
  };
198
202
  MxDbSVG.prototype.transformBy = function (mat) {
199
203
  this.svgPos.applyMatrix4(mat);
200
- this.txtPos.applyMatrix4(mat);
201
204
  this.isSvgDirtyLocation = true;
205
+ this.aryText.forEach(function (txt) {
206
+ txt.txtPos.applyMatrix4(mat);
207
+ });
202
208
  };
203
209
  MxDbSVG.prototype.getTypeName = function () {
204
210
  return 'MxDbSVG';
205
211
  };
212
+ MxDbSVG.prototype.setColor = function (color) {
213
+ _super.prototype.setColor.call(this, color);
214
+ if (this.svg) {
215
+ var color_2 = new THREE.Color(this.color);
216
+ this.svg.traverse(function (child) {
217
+ if (child.material) {
218
+ child.material.color = color_2;
219
+ }
220
+ });
221
+ }
222
+ };
206
223
  return MxDbSVG;
207
224
  }(MxDbEntity_1.default));
208
225
  exports.default = MxDbSVG;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ///////////////////////////////////////////////////////////////////////////////
4
+ //版权所有(C)2002-2022,成都梦想凯德科技有限公司。
5
+ //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
6
+ //此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
7
+ ///////////////////////////////////////////////////////////////////////////////
8
+ /** @module MxDbSVG*/
9
+ var THREE = require("three");
10
+ var MxDbSVGText = /** @class */ (function () {
11
+ function MxDbSVGText() {
12
+ this.txtPos = new THREE.Vector3();
13
+ this.txt = '';
14
+ this.txtHeight = 1;
15
+ }
16
+ return MxDbSVGText;
17
+ }());
18
+ exports.default = MxDbSVGText;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /** @module McEdGetPointWorldDrawObject*/
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ var MxDbSVGText_1 = require("./MxDbSVGText");
5
+ exports.default = MxDbSVGText_1.default;