mxdraw 0.1.8 → 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.
- package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +25 -12
- package/dist/lib/MxModule/MxDbRect/MxDbRect.js +140 -86
- package/dist/lib/MxModule/MxDbSVG/MxDbSVG.js +49 -32
- package/dist/lib/MxModule/MxDbSVGText/MxDbSVGText.js +18 -0
- package/dist/lib/MxModule/MxDbSVGText/index.js +5 -0
- package/dist/lib/MxModule/MxFun/MxFun.js +13 -0
- package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +2 -0
- package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +36 -23
- package/dist/lib/mxdraw.js +4 -1
- package/dist/lib/tools/three/index.js +21 -15
- package/dist/mxdraw.es5.js +3 -3
- package/dist/mxdraw.es5.js.map +1 -1
- package/dist/mxdraw.umd.js +3 -3
- package/dist/mxdraw.umd.js.map +1 -1
- package/dist/types/MxModule/MxDbEntity/MxDbEntity.d.ts +12 -4
- package/dist/types/MxModule/MxDbRect/MxDbRect.d.ts +21 -42
- package/dist/types/MxModule/MxDbSVG/MxDbSVG.d.ts +5 -9
- package/dist/types/MxModule/MxDbSVGText/MxDbSVGText.d.ts +7 -0
- package/dist/types/MxModule/MxDbSVGText/index.d.ts +3 -0
- package/dist/types/MxModule/MxFun/MxFun.d.ts +12 -0
- package/dist/types/mxdraw.d.ts +3 -1
- package/package.json +1 -1
|
@@ -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.
|
|
29
|
-
this.
|
|
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 (
|
|
115
|
-
this.
|
|
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.
|
|
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.
|
|
151
|
-
this.
|
|
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['
|
|
159
|
-
obj['
|
|
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 (
|
|
184
|
-
this.
|
|
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.
|
|
209
|
+
return this.renderOrder;
|
|
197
210
|
};
|
|
198
211
|
return MxDbEntity;
|
|
199
212
|
}());
|
|
@@ -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
|
-
*
|
|
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.
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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:
|
|
81
|
+
transparent: true,
|
|
82
|
+
depthTest: false,
|
|
96
83
|
opacity: this.opacity,
|
|
97
84
|
visible: this.visible
|
|
98
85
|
};
|
|
99
86
|
// 如果是填充模式
|
|
100
|
-
if (this.
|
|
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
|
-
|
|
109
|
-
var
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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 (
|
|
126
|
-
if (
|
|
127
|
-
map.center =
|
|
128
|
-
if (
|
|
129
|
-
map.offset =
|
|
130
|
-
if (
|
|
131
|
-
map.repeat =
|
|
132
|
-
if (
|
|
133
|
-
map.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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
142
|
-
|
|
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 '
|
|
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.
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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.
|
|
141
|
-
|
|
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.
|
|
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
|
-
|
|
177
|
-
this.
|
|
178
|
-
|
|
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['
|
|
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;
|
|
@@ -563,6 +563,19 @@ var MxFun = /** @class */ (function () {
|
|
|
563
563
|
MxFun.prototype.openFile = function (sFile) {
|
|
564
564
|
return store_1.default.state.MxFun.openFile(sFile);
|
|
565
565
|
};
|
|
566
|
+
/**
|
|
567
|
+
* 添加一个MxDbEntity实体到当前绘图对象上。
|
|
568
|
+
* @param ent 实体对象
|
|
569
|
+
* @returns number 返回对象的id.
|
|
570
|
+
* @example
|
|
571
|
+
* ```typescript
|
|
572
|
+
*
|
|
573
|
+
*
|
|
574
|
+
* ```
|
|
575
|
+
*/
|
|
576
|
+
MxFun.prototype.addToCurrentSpace = function (ent) {
|
|
577
|
+
return this.getCurrentDraw().addMxEntity(ent);
|
|
578
|
+
};
|
|
566
579
|
return MxFun;
|
|
567
580
|
}());
|
|
568
581
|
exports.default = MxFun;
|
|
@@ -45,11 +45,13 @@ var MxDbImage_1 = require("../MxDbImage");
|
|
|
45
45
|
var MxDbSVG_1 = require("../MxDbSVG");
|
|
46
46
|
var MxDbAlignedDimension_1 = require("../MxDbAlignedDimension");
|
|
47
47
|
var MxDbLine_1 = require("../MxDbLine");
|
|
48
|
+
var MxDbRect_1 = require("../MxDbRect");
|
|
48
49
|
function rxInitMxEntity() {
|
|
49
50
|
new MxDbImage_1.default().rxInit();
|
|
50
51
|
new MxDbSVG_1.default().rxInit();
|
|
51
52
|
new MxDbAlignedDimension_1.default().rxInit();
|
|
52
53
|
new MxDbLine_1.default().rxInit();
|
|
54
|
+
new MxDbRect_1.default().rxInit();
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* 加载MxDraw库的核心代码 才能使用Mx的其他模块
|