mxdraw 0.1.12 → 0.1.13
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/McEdGetPointWorldDrawObject/McEdGetPointWorldDrawObjectClass.js +1 -128
- package/dist/lib/MxModule/McEdGetPointWorldDrawObject/index.js +1 -5
- package/dist/lib/MxModule/McGeVector3d/McGeVector3d.js +1 -2
- package/dist/lib/MxModule/McGeVector3d/index.js +1 -3
- package/dist/lib/MxModule/McGiWorldDraw/McGiWorldDraw.js +1 -2
- package/dist/lib/MxModule/McGiWorldDraw/index.js +1 -2
- package/dist/lib/MxModule/McGiWorldDrawType/McGiWorldDrawType.js +1 -19
- package/dist/lib/MxModule/McGiWorldDrawType/index.js +1 -4
- package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/MrxDbgUiPrBaseReturn.js +1 -31
- package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/index.js +1 -5
- package/dist/lib/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.js +1 -150
- package/dist/lib/MxModule/MrxDbgUiPrPoint/index.js +1 -5
- package/dist/lib/MxModule/MxDbAlignedDimension/MxDbAlignedDimension.js +1 -213
- package/dist/lib/MxModule/MxDbAlignedDimension/index.js +1 -5
- package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +1 -241
- package/dist/lib/MxModule/MxDbEntity/index.js +1 -5
- package/dist/lib/MxModule/MxDbImage/MxDbImage.js +1 -160
- package/dist/lib/MxModule/MxDbImage/index.js +1 -5
- package/dist/lib/MxModule/MxDbLine/MxDbLine.js +1 -94
- package/dist/lib/MxModule/MxDbLine/index.js +1 -5
- package/dist/lib/MxModule/MxDbRect/MxDbRect.js +1 -273
- package/dist/lib/MxModule/MxDbRect/index.js +1 -4
- package/dist/lib/MxModule/MxDbSVG/MxDbSVG.js +1 -369
- package/dist/lib/MxModule/MxDbSVG/index.js +1 -5
- package/dist/lib/MxModule/MxDbSVGText/MxDbSVGText.js +1 -21
- package/dist/lib/MxModule/MxDbSVGText/index.js +1 -5
- package/dist/lib/MxModule/MxDrawObject/MxDrawObject.js +1 -754
- package/dist/lib/MxModule/MxDrawObject/index.js +1 -5
- package/dist/lib/MxModule/MxFilters/MxFilters.js +1 -201
- package/dist/lib/MxModule/MxFilters/index.js +1 -4
- package/dist/lib/MxModule/MxFun/MxFun.js +1 -630
- package/dist/lib/MxModule/MxFun/index.js +1 -9
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js +1 -283
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +1 -146
- package/dist/lib/MxModule/MxThreeJS/SVGLoader.js +1 -1862
- package/dist/lib/MxModule/MxThreeJS/index.js +1 -7
- package/dist/lib/MxModule/MxType/MxType.js +1 -27
- package/dist/lib/MxModule/MxType/index.js +1 -4
- package/dist/lib/MxModule/Mxassembly/Mxassembly.js +1 -18
- package/dist/lib/MxModule/Mxassembly/index.js +1 -9
- package/dist/lib/MxModule/loadCoreCode/index.js +1 -5
- package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +1 -125
- package/dist/lib/MxModule/loadCoreCode/mxUiData.js +1 -317
- package/dist/lib/MxModule/loadCoreCode/mxcadassembly_es5.js +1 -1519
- package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +1 -7361
- package/dist/lib/MxModule/store/PubsubClass.js +1 -40
- package/dist/lib/MxModule/store/StoreClass.js +1 -73
- package/dist/lib/MxModule/store/index.js +1 -16
- package/dist/lib/MxModule/store/store.js +1 -25
- package/dist/lib/MxModule/useCanvasResizeListener/index.js +1 -5
- package/dist/lib/MxModule/useCanvasResizeListener/useCanvasResizeListener.js +1 -95
- package/dist/lib/doc.js +1 -38
- package/dist/lib/mxdraw.js +1 -64
- package/dist/lib/tools/algorithm/math.js +1 -16
- package/dist/lib/tools/algorithm/random.js +1 -13
- package/dist/lib/tools/dom/create.js +1 -47
- package/dist/lib/tools/dynamicImport/index.js +1 -186
- package/dist/lib/tools/formatting/index.js +1 -20
- package/dist/lib/tools/proxy/index.js +1 -17
- package/dist/lib/tools/three/index.js +1 -124
- package/dist/lib/types/McEdGetPointWorldDrawObject.js +1 -2
- package/dist/lib/types/MrxDbgUiPrPoint.js +1 -2
- package/dist/lib/types/MxCADObject.js +1 -2
- package/dist/lib/types/MxDrawObject.js +1 -2
- package/dist/lib/types/MxFun.js +1 -2
- package/dist/lib/types/Mxassembly.js +1 -2
- package/dist/mxdraw.es5.js +1 -45
- package/dist/mxdraw.umd.js +1 -45
- package/dist/types/MxModule/MxFun/MxFun.d.ts +18 -1
- package/dist/types/MxModule/store/index.d.ts +2 -7
- package/dist/types/mxdraw.d.ts +1 -4
- package/package.json +6 -5
- package/dist/mxdraw.es5.js.map +0 -1
- package/dist/mxdraw.umd.js.map +0 -1
|
@@ -1,273 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
30
|
-
//版权所有(C)2002-2022,成都梦想凯德科技有限公司。
|
|
31
|
-
//本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
|
|
32
|
-
//此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
|
|
33
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
34
|
-
var MxDbEntity_1 = require("../MxDbEntity");
|
|
35
|
-
var three_1 = require("three");
|
|
36
|
-
var index_1 = require("../../tools/three/index");
|
|
37
|
-
// import * as _ from 'lodash'
|
|
38
|
-
var MxFun_1 = require("../MxFun");
|
|
39
|
-
var McGiWorldDrawType_1 = require("../McGiWorldDrawType");
|
|
40
|
-
/**
|
|
41
|
-
* MxRectEntity 矩形对象.
|
|
42
|
-
*/
|
|
43
|
-
var MxDbRect = /** @class */ (function (_super) {
|
|
44
|
-
__extends(MxDbRect, _super);
|
|
45
|
-
function MxDbRect() {
|
|
46
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
47
|
-
// 圆角半径
|
|
48
|
-
_this.cornerRadius = [];
|
|
49
|
-
/**
|
|
50
|
-
* pt1: 构成矩形的第一个点
|
|
51
|
-
* */
|
|
52
|
-
_this.pt1 = new three_1.Vector3();
|
|
53
|
-
/**
|
|
54
|
-
* pt1: 构成矩形的第二个点(对角点)
|
|
55
|
-
* */
|
|
56
|
-
_this.pt2 = new three_1.Vector3();
|
|
57
|
-
/**
|
|
58
|
-
* 是否需要颜色填充.
|
|
59
|
-
* */
|
|
60
|
-
_this.isSolidColorFill = false;
|
|
61
|
-
_this.isLoadMaterialFromPath = true;
|
|
62
|
-
_this.material = null;
|
|
63
|
-
return _this;
|
|
64
|
-
}
|
|
65
|
-
MxDbRect.prototype.worldDraw = function (pWorldDraw) {
|
|
66
|
-
var _this = this;
|
|
67
|
-
// 根据第一个点和对角点 计算矩形的四个点位
|
|
68
|
-
var points = (0, index_1.computeRectPoints)(this.pt1, this.pt2);
|
|
69
|
-
if (this.cornerRadius.length > 0) {
|
|
70
|
-
points = (0, index_1.getToGenerateRoundedCorners)(points, this.cornerRadius);
|
|
71
|
-
}
|
|
72
|
-
if (pWorldDraw.getType() != McGiWorldDrawType_1.default.kWorldDraw) {
|
|
73
|
-
// 动态拖动绘制,或选择绘制 。
|
|
74
|
-
// 组成闭合区域。
|
|
75
|
-
points.push(points[0]);
|
|
76
|
-
pWorldDraw.drawLines(points);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
// 公共的material参数
|
|
80
|
-
var materialParam = {
|
|
81
|
-
transparent: true,
|
|
82
|
-
depthTest: false,
|
|
83
|
-
opacity: this.opacity,
|
|
84
|
-
visible: this.visible
|
|
85
|
-
};
|
|
86
|
-
// 如果是填充模式
|
|
87
|
-
if (this.isSolidColorFill) {
|
|
88
|
-
// 三维坐标转二位坐标
|
|
89
|
-
points = points.map(function (_a) {
|
|
90
|
-
var x = _a.x, y = _a.y;
|
|
91
|
-
return new three_1.Vector2(x, y);
|
|
92
|
-
});
|
|
93
|
-
// 计算矩形宽高
|
|
94
|
-
var geometry = void 0;
|
|
95
|
-
geometry = new three_1.ShapeGeometry(new three_1.Shape(points));
|
|
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) {
|
|
117
|
-
// 纹理属性设置
|
|
118
|
-
var mate = material;
|
|
119
|
-
var map = mate.map;
|
|
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;
|
|
129
|
-
}
|
|
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;
|
|
147
|
-
}
|
|
148
|
-
myThis_1.material = material;
|
|
149
|
-
myThis_1.setNeedUpdateDisplay();
|
|
150
|
-
MxFun_1.default.updateDisplay();
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
// 线框模式
|
|
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);
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
MxDbRect.prototype.getGripPoints = function () {
|
|
163
|
-
var ret = [];
|
|
164
|
-
ret.push(this.pt1);
|
|
165
|
-
var lineMath = new three_1.Line3(this.pt1, this.pt2);
|
|
166
|
-
var corePt = new three_1.Vector3();
|
|
167
|
-
lineMath.getCenter(corePt);
|
|
168
|
-
ret.push(corePt);
|
|
169
|
-
ret.push(this.pt2);
|
|
170
|
-
return ret;
|
|
171
|
-
};
|
|
172
|
-
MxDbRect.prototype.moveGripPointsAt = function (index, offset) {
|
|
173
|
-
if (index == 0) {
|
|
174
|
-
this.pt1.add(offset);
|
|
175
|
-
}
|
|
176
|
-
else if (index == 1) {
|
|
177
|
-
this.pt1.add(offset);
|
|
178
|
-
this.pt2.add(offset);
|
|
179
|
-
}
|
|
180
|
-
else if (index == 2) {
|
|
181
|
-
this.pt2.add(offset);
|
|
182
|
-
}
|
|
183
|
-
return true;
|
|
184
|
-
};
|
|
185
|
-
MxDbRect.prototype.dwgIn = function (obj) {
|
|
186
|
-
this.onDwgIn(obj);
|
|
187
|
-
this.pt1.copy(obj['pt1']);
|
|
188
|
-
this.pt2.copy(obj['pt2']);
|
|
189
|
-
this.isSolidColorFill = obj['isSolidColorFill'];
|
|
190
|
-
this.fillImageSrc = obj['fillImageSrc'];
|
|
191
|
-
this.fillImageParam = obj['fillImageParam'];
|
|
192
|
-
this.cornerRadius = obj['cornerRadius'];
|
|
193
|
-
this.filter = obj['filter'];
|
|
194
|
-
this.isLoadMaterialFromPath = true;
|
|
195
|
-
this.material = null;
|
|
196
|
-
return true;
|
|
197
|
-
};
|
|
198
|
-
MxDbRect.prototype.dwgOut = function (obj) {
|
|
199
|
-
this.onDwgOut(obj);
|
|
200
|
-
obj['pt1'] = this.pt1;
|
|
201
|
-
obj['pt2'] = this.pt2;
|
|
202
|
-
obj['isSolidColorFill'] = this.isSolidColorFill;
|
|
203
|
-
obj['fillImageSrc'] = this.fillImageSrc;
|
|
204
|
-
obj['fillImageParam'] = this.fillImageParam;
|
|
205
|
-
obj['cornerRadius'] = this.cornerRadius;
|
|
206
|
-
obj['filter'] = this.filter;
|
|
207
|
-
return obj;
|
|
208
|
-
};
|
|
209
|
-
MxDbRect.prototype.create = function () {
|
|
210
|
-
return new MxDbRect();
|
|
211
|
-
};
|
|
212
|
-
MxDbRect.prototype.transformBy = function (mat) {
|
|
213
|
-
this.pt1.applyMatrix4(mat);
|
|
214
|
-
this.pt2.applyMatrix4(mat);
|
|
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
|
-
};
|
|
249
|
-
MxDbRect.prototype.getTypeName = function () {
|
|
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;
|
|
270
|
-
};
|
|
271
|
-
return MxDbRect;
|
|
272
|
-
}(MxDbEntity_1.default));
|
|
273
|
-
exports.default = MxDbRect;
|
|
1
|
+
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var a in e=arguments[r])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t}).apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0});var MxDbEntity_1=require("../MxDbEntity"),three_1=require("three"),index_1=require("../../tools/three/index"),MxFun_1=require("../MxFun"),McGiWorldDrawType_1=require("../McGiWorldDrawType"),MxDbRect=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.cornerRadius=[],e.pt1=new three_1.Vector3,e.pt2=new three_1.Vector3,e.isSolidColorFill=!1,e.isLoadMaterialFromPath=!0,e.material=null,e}return __extends(e,t),e.prototype.worldDraw=function(t){var e=this,r=(0,index_1.computeRectPoints)(this.pt1,this.pt2);if(this.cornerRadius.length>0&&(r=(0,index_1.getToGenerateRoundedCorners)(r,this.cornerRadius)),t.getType()!=McGiWorldDrawType_1.default.kWorldDraw)return r.push(r[0]),void t.drawLines(r);var i={transparent:!0,depthTest:!1,opacity:this.opacity,visible:this.visible};if(this.isSolidColorFill){r=r.map(function(t){var e=t.x,r=t.y;return new three_1.Vector2(e,r)});var a=void 0;a=new three_1.ShapeGeometry(new three_1.Shape(r));var o=new three_1.MeshBasicMaterial(__assign({color:this.filter?this.filter._getFilterColor(this.color,this.opacity):new three_1.Color(this.color)},i)),n=new three_1.Mesh(a,o);t.drawEntity(n)}else if(this.fillImageSrc){if(this.material){r=r.map(function(t){var e=t.x,r=t.y;return new three_1.Vector2(e,r)});o=this.material,a=new three_1.ShapeGeometry(new three_1.Shape(r));if(a=(0,index_1.repairGeometryFaceVertexUvs)(a),this.filter){var s=o.map;this.fillImageParam&&(this.fillImageParam.center&&(s.center=this.fillImageParam.center),this.fillImageParam.offset&&(s.offset=this.fillImageParam.offset),this.fillImageParam.repeat&&(s.repeat=this.fillImageParam.repeat),this.fillImageParam.rotation&&(s.rotation=this.fillImageParam.rotation));var l=this.filter._getFilterShaderData(s);o=new three_1.ShaderMaterial(__assign(__assign({},l),i))}o.depthTest=!1,o.transparent=!0,o.opacity=this.opacity,o.visible=this.visible;n=new three_1.Mesh(a,o);t.drawEntity(n)}else if(this.fillImageSrc.length>0&&this.isLoadMaterialFromPath){var h=this;MxFun_1.default.loadImageMaterial(this.fillImageSrc,function(t){e.isLoadMaterialFromPath=!1,t&&(h.material=t,h.setNeedUpdateDisplay(),MxFun_1.default.updateDisplay())})}}else{a=(new three_1.BufferGeometry).setFromPoints(r),o=new three_1.LineBasicMaterial(__assign({color:this.getColor()},i));var p=new three_1.LineLoop(a,o);t.drawEntity(p)}},e.prototype.getGripPoints=function(){var t=[];t.push(this.pt1);var e=new three_1.Line3(this.pt1,this.pt2),r=new three_1.Vector3;return e.getCenter(r),t.push(r),t.push(this.pt2),t},e.prototype.moveGripPointsAt=function(t,e){return 0==t?this.pt1.add(e):1==t?(this.pt1.add(e),this.pt2.add(e)):2==t&&this.pt2.add(e),!0},e.prototype.dwgIn=function(t){return this.onDwgIn(t),this.pt1.copy(t.pt1),this.pt2.copy(t.pt2),this.isSolidColorFill=t.isSolidColorFill,this.fillImageSrc=t.fillImageSrc,this.fillImageParam=t.fillImageParam,this.cornerRadius=t.cornerRadius,this.filter=t.filter,this.isLoadMaterialFromPath=!0,this.material=null,!0},e.prototype.dwgOut=function(t){return this.onDwgOut(t),t.pt1=this.pt1,t.pt2=this.pt2,t.isSolidColorFill=this.isSolidColorFill,t.fillImageSrc=this.fillImageSrc,t.fillImageParam=this.fillImageParam,t.cornerRadius=this.cornerRadius,t.filter=this.filter,t},e.prototype.create=function(){return new e},e.prototype.transformBy=function(t){this.pt1.applyMatrix4(t),this.pt2.applyMatrix4(t)},e.prototype.setRadius=function(t,e){void 0===e&&(e=!0),t instanceof Array?this.cornerRadius=t.map(function(t){return e?MxFun_1.default.screenCoordLong2Doc(t):t}):this.cornerRadius=t>0?e?[MxFun_1.default.screenCoordLong2Doc(t),MxFun_1.default.screenCoordLong2Doc(t),MxFun_1.default.screenCoordLong2Doc(t),MxFun_1.default.screenCoordLong2Doc(t)]:[t,t,t,t]:[]},e.prototype.getTypeName=function(){return"MxDbRect"},e.prototype.getFilter=function(){return this.filter},e.prototype.setFilter=function(t){this.filter=t,this.isLoadMaterialFromPath=!0,this.material=null},e.prototype.setFillImagePath=function(t){this.fillImageSrc=t,this.isLoadMaterialFromPath=!0,this.material=null,this.fillImageSrc&&(this.isSolidColorFill=!1)},e.prototype.getFillImagePath=function(){return this.fillImageSrc},e}(MxDbEntity_1.default);exports.default=MxDbRect;
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var MxDbRect_1 = require("./MxDbRect");
|
|
4
|
-
exports.default = MxDbRect_1.default;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var MxDbRect_1=require("./MxDbRect");exports.default=MxDbRect_1.default;
|
|
@@ -1,369 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
19
|
-
//版权所有(C)2002-2022,成都梦想凯德科技有限公司。
|
|
20
|
-
//本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
|
|
21
|
-
//此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
|
|
22
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
-
/** @module MxDbSVG*/
|
|
24
|
-
var THREE = require("three");
|
|
25
|
-
var MxDbEntity_1 = require("../MxDbEntity");
|
|
26
|
-
var MxDbSVGText_1 = require("../MxDbSVGText");
|
|
27
|
-
var MxThreeJS_1 = require("../MxThreeJS");
|
|
28
|
-
var MxType_1 = require("../MxType");
|
|
29
|
-
/**
|
|
30
|
-
* MxDbSVG SVG对象.
|
|
31
|
-
*/
|
|
32
|
-
var MxDbSVG = /** @class */ (function (_super) {
|
|
33
|
-
__extends(MxDbSVG, _super);
|
|
34
|
-
function MxDbSVG() {
|
|
35
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
36
|
-
_this.svgPos = new THREE.Vector3();
|
|
37
|
-
_this.svg = null;
|
|
38
|
-
_this.svgPath = '';
|
|
39
|
-
_this.svgSize = new THREE.Vector2(50, 50);
|
|
40
|
-
_this.svgAlignmentRatio = new THREE.Vector2(0, 0);
|
|
41
|
-
_this.svgRotate = 0;
|
|
42
|
-
_this.svgReverse = false;
|
|
43
|
-
_this.svgMargin = new THREE.Vector2(0, 0);
|
|
44
|
-
_this.isSvgDirtyLocation = false;
|
|
45
|
-
_this.isLoadFromPath = true;
|
|
46
|
-
_this.aryText = [];
|
|
47
|
-
_this.svgBoxSize = null;
|
|
48
|
-
// 固定尺寸,图片和文字大小,取屏幕像素绘图单位。
|
|
49
|
-
_this.fixedSize = false;
|
|
50
|
-
_this.useSvgColor = false;
|
|
51
|
-
return _this;
|
|
52
|
-
}
|
|
53
|
-
MxDbSVG.prototype.calcVewSize = function (mxObj) {
|
|
54
|
-
var sizew = this.svgSize.x;
|
|
55
|
-
var sizeh = this.svgSize.y;
|
|
56
|
-
if (sizeh <= 0) {
|
|
57
|
-
if (this.svgBoxSize) {
|
|
58
|
-
sizeh = (this.svgBoxSize.y / this.svgBoxSize.x) * sizew;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
sizeh = sizew;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (this.fixedSize) {
|
|
65
|
-
sizew = mxObj.screenCoordLong2Doc(sizew);
|
|
66
|
-
sizeh = mxObj.screenCoordLong2Doc(sizeh);
|
|
67
|
-
}
|
|
68
|
-
return [sizew, sizeh];
|
|
69
|
-
};
|
|
70
|
-
MxDbSVG.prototype.worldDraw = function (pWorldDraw) {
|
|
71
|
-
var _this = this;
|
|
72
|
-
var mxObj = pWorldDraw.getMxObject();
|
|
73
|
-
this.calcSvgPosition(mxObj);
|
|
74
|
-
var _a = this.calcVewSize(mxObj), sizew = _a[0], sizeh = _a[1];
|
|
75
|
-
var matSclae = new THREE.Matrix4();
|
|
76
|
-
if (this.svgReverse)
|
|
77
|
-
matSclae.makeScale(1, -1, 1);
|
|
78
|
-
var mat = new THREE.Matrix4();
|
|
79
|
-
mat.makeRotationZ(this.svgRotate);
|
|
80
|
-
var matMove = new THREE.Matrix4();
|
|
81
|
-
var svgNewPos = new THREE.Vector3(this.svgPos.x - sizew * this.svgAlignmentRatio.x, this.svgPos.y - sizeh * this.svgAlignmentRatio.y, 0);
|
|
82
|
-
matMove.makeTranslation(svgNewPos.x, svgNewPos.y, svgNewPos.z);
|
|
83
|
-
mat.multiply(matSclae);
|
|
84
|
-
mat.premultiply(matMove);
|
|
85
|
-
var pt1 = new THREE.Vector3(0, 0, 0);
|
|
86
|
-
var pt3 = new THREE.Vector3(sizew, 0, 0);
|
|
87
|
-
var pt2 = new THREE.Vector3(sizew, sizeh, 0);
|
|
88
|
-
var pt4 = new THREE.Vector3(0, sizeh, 0);
|
|
89
|
-
pt1.applyMatrix4(mat);
|
|
90
|
-
pt3.applyMatrix4(mat);
|
|
91
|
-
pt2.applyMatrix4(mat);
|
|
92
|
-
pt4.applyMatrix4(mat);
|
|
93
|
-
if (pWorldDraw.getType() == 1) {
|
|
94
|
-
this.aryText.forEach(function (txt) {
|
|
95
|
-
if (txt.txt.length > 0) {
|
|
96
|
-
var posTxt = new THREE.Vector3(txt.txtPos.x, txt.txtPos.y, 0);
|
|
97
|
-
if (_this.fixedSize) {
|
|
98
|
-
if (txt.txtPos.x > 0)
|
|
99
|
-
posTxt.x = _this.svgPos.x + mxObj.screenCoordLong2Doc(txt.txtPos.x);
|
|
100
|
-
else
|
|
101
|
-
posTxt.x = _this.svgPos.x - mxObj.screenCoordLong2Doc(txt.txtPos.x);
|
|
102
|
-
if (txt.txtPos.y > 0)
|
|
103
|
-
posTxt.y = _this.svgPos.y + mxObj.screenCoordLong2Doc(txt.txtPos.y);
|
|
104
|
-
else
|
|
105
|
-
posTxt.y = _this.svgPos.y - mxObj.screenCoordLong2Doc(txt.txtPos.y);
|
|
106
|
-
}
|
|
107
|
-
var bakColor = undefined;
|
|
108
|
-
if (txt.color) {
|
|
109
|
-
bakColor = pWorldDraw.getColor();
|
|
110
|
-
pWorldDraw.setColor(txt.color);
|
|
111
|
-
}
|
|
112
|
-
var iSize = txt.txtHeight;
|
|
113
|
-
if (_this.fixedSize)
|
|
114
|
-
iSize = mxObj.screenCoordLong2Doc(txt.txtHeight);
|
|
115
|
-
txt._txtObject = pWorldDraw.drawText(txt.txt, iSize, 0, posTxt);
|
|
116
|
-
txt._txtAspectRatio = -1;
|
|
117
|
-
if (bakColor) {
|
|
118
|
-
pWorldDraw.setColor(bakColor);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
if (this.svg) {
|
|
123
|
-
pWorldDraw.drawEntity(this.svg);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
if (this.svgPath.length > 0 && this.isLoadFromPath) {
|
|
127
|
-
var myThis_1 = this;
|
|
128
|
-
var mxobj_1 = pWorldDraw.getMxObject();
|
|
129
|
-
MxThreeJS_1.default.loadSVG(this.svgPath, undefined, function (obj) {
|
|
130
|
-
if (obj) {
|
|
131
|
-
var box = new THREE.Box3().setFromObject(obj);
|
|
132
|
-
if (!myThis_1.svgBoxSize) {
|
|
133
|
-
myThis_1.svgBoxSize = new THREE.Vector3();
|
|
134
|
-
}
|
|
135
|
-
myThis_1.svgBoxSize.x = box.max.x - box.min.x;
|
|
136
|
-
myThis_1.svgBoxSize.y = box.max.y - box.min.y;
|
|
137
|
-
var _a = myThis_1.calcVewSize(mxObj), sizew_1 = _a[0], sizeh_1 = _a[1];
|
|
138
|
-
obj.scale.x = sizew_1 / myThis_1.svgBoxSize.x;
|
|
139
|
-
obj.scale.y = sizeh_1 / myThis_1.svgBoxSize.y;
|
|
140
|
-
obj.scale.z = obj.scale.x;
|
|
141
|
-
if (myThis_1.svgReverse) {
|
|
142
|
-
obj.scale.y *= -1;
|
|
143
|
-
}
|
|
144
|
-
obj.rotateZ(myThis_1.svgRotate);
|
|
145
|
-
myThis_1.isSvgDirtyLocation = true;
|
|
146
|
-
var color_1 = new THREE.Color(pWorldDraw.getColor());
|
|
147
|
-
obj.traverse(function (child) {
|
|
148
|
-
if (child.material) {
|
|
149
|
-
child.material = child.material.clone();
|
|
150
|
-
child.material.transparent = true;
|
|
151
|
-
if (!myThis_1.useSvgColor)
|
|
152
|
-
child.material.color = color_1;
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
//this.svgPos.multiply
|
|
156
|
-
myThis_1.svg = obj;
|
|
157
|
-
myThis_1.setNeedUpdateDisplay();
|
|
158
|
-
mxobj_1.updateDisplay();
|
|
159
|
-
}
|
|
160
|
-
myThis_1.isLoadFromPath = false;
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
pWorldDraw.drawSelectLine(pt1, pt2);
|
|
165
|
-
pWorldDraw.drawSelectLine(pt3, pt4);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
pWorldDraw.drawLine(pt1, pt3);
|
|
169
|
-
pWorldDraw.drawLine(pt3, pt2);
|
|
170
|
-
pWorldDraw.drawLine(pt2, pt4);
|
|
171
|
-
pWorldDraw.drawLine(pt4, pt1);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
MxDbSVG.prototype.setSvgPath = function (path) {
|
|
175
|
-
this.svgPath = path;
|
|
176
|
-
this.svg = null;
|
|
177
|
-
this.isLoadFromPath = true;
|
|
178
|
-
this.svgBoxSize = null;
|
|
179
|
-
};
|
|
180
|
-
MxDbSVG.prototype.getSvgPath = function () {
|
|
181
|
-
return this.svgPath;
|
|
182
|
-
};
|
|
183
|
-
MxDbSVG.prototype.setSvgPostion = function (pos) {
|
|
184
|
-
this.svgPos = pos.clone();
|
|
185
|
-
this.isSvgDirtyLocation = true;
|
|
186
|
-
};
|
|
187
|
-
MxDbSVG.prototype.getSvgPostion = function () {
|
|
188
|
-
return this.svgPos;
|
|
189
|
-
};
|
|
190
|
-
MxDbSVG.prototype.setSvgSize = function (size) {
|
|
191
|
-
this.svgSize = size;
|
|
192
|
-
this.isSvgDirtyLocation = true;
|
|
193
|
-
};
|
|
194
|
-
MxDbSVG.prototype.getSvgSize = function () {
|
|
195
|
-
return this.svgSize;
|
|
196
|
-
};
|
|
197
|
-
MxDbSVG.prototype.setSvgAlignmentRatio = function (alignmentRatio) {
|
|
198
|
-
this.svgAlignmentRatio = alignmentRatio;
|
|
199
|
-
this.isSvgDirtyLocation = true;
|
|
200
|
-
};
|
|
201
|
-
MxDbSVG.prototype.getSvgAlignmentRatio = function () {
|
|
202
|
-
return this.svgAlignmentRatio;
|
|
203
|
-
};
|
|
204
|
-
MxDbSVG.prototype.getText = function (index) {
|
|
205
|
-
if (index < this.aryText.length) {
|
|
206
|
-
return this.aryText[index];
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
MxDbSVG.prototype.addText = function (txt) {
|
|
213
|
-
this.aryText.push(txt);
|
|
214
|
-
};
|
|
215
|
-
MxDbSVG.prototype.getGripPoints = function () {
|
|
216
|
-
var ret = [];
|
|
217
|
-
ret.push(this.svgPos);
|
|
218
|
-
return ret;
|
|
219
|
-
};
|
|
220
|
-
MxDbSVG.prototype.moveGripPointsAt = function (index, offset) {
|
|
221
|
-
if (index == 0) {
|
|
222
|
-
this.svgPos.add(offset);
|
|
223
|
-
if (!this.fixedSize) {
|
|
224
|
-
this.aryText.forEach(function (txt) {
|
|
225
|
-
txt.txtPos.add(offset);
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
this.isSvgDirtyLocation = true;
|
|
230
|
-
return true;
|
|
231
|
-
};
|
|
232
|
-
MxDbSVG.prototype.calcSvgPosition = function (mxObj) {
|
|
233
|
-
if (!this.svg || !this.isSvgDirtyLocation) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
this.isSvgDirtyLocation = false;
|
|
237
|
-
var _a = this.calcVewSize(mxObj), sizew = _a[0], sizeh = _a[1];
|
|
238
|
-
this.svg.position.x =
|
|
239
|
-
this.svgPos.x - sizew * this.svgAlignmentRatio.x - this.svgMargin.x * sizew;
|
|
240
|
-
this.svg.position.y =
|
|
241
|
-
this.svgPos.y - sizeh * this.svgAlignmentRatio.y - this.svgMargin.y * sizeh;
|
|
242
|
-
};
|
|
243
|
-
MxDbSVG.prototype.dwgIn = function (obj) {
|
|
244
|
-
var _this = this;
|
|
245
|
-
this.onDwgIn(obj);
|
|
246
|
-
this.fixedSize = obj['fixedSize'];
|
|
247
|
-
if (this.fixedSize) {
|
|
248
|
-
// svg = null,重新加载svg.
|
|
249
|
-
this.svg = null;
|
|
250
|
-
}
|
|
251
|
-
else if (obj.type == MxType_1.default.MxCloneType.kClone && obj['svg']) {
|
|
252
|
-
this.svg = obj['svg'].clone();
|
|
253
|
-
}
|
|
254
|
-
this.svgPos.copy(obj['svgPos']);
|
|
255
|
-
this.svgPath = obj['svgPath'].substr(0);
|
|
256
|
-
this.svgSize.copy(obj['svgSize']);
|
|
257
|
-
this.svgAlignmentRatio.copy(obj['svgAlignmentRatio']);
|
|
258
|
-
this.isSvgDirtyLocation = true;
|
|
259
|
-
if (!this.svg)
|
|
260
|
-
this.isLoadFromPath = true;
|
|
261
|
-
this.svgBoxSize = null;
|
|
262
|
-
var aryText = obj['txts'];
|
|
263
|
-
this.aryText = [];
|
|
264
|
-
aryText.forEach(function (txt) {
|
|
265
|
-
var copyTxt = new MxDbSVGText_1.default();
|
|
266
|
-
copyTxt.txt = txt.txt;
|
|
267
|
-
copyTxt.txtHeight = txt.txtHeight;
|
|
268
|
-
copyTxt.txtPos.copy(txt.txtPos);
|
|
269
|
-
_this.aryText.push(copyTxt);
|
|
270
|
-
});
|
|
271
|
-
this.svgRotate = obj['svgRotate'];
|
|
272
|
-
this.useSvgColor = obj['useSvgColor'];
|
|
273
|
-
this.svgReverse = obj['svgReverse'];
|
|
274
|
-
this.svgMargin = obj['svgMargin'];
|
|
275
|
-
return true;
|
|
276
|
-
};
|
|
277
|
-
MxDbSVG.prototype.dwgOut = function (obj) {
|
|
278
|
-
this.onDwgOut(obj);
|
|
279
|
-
if (obj.type == MxType_1.default.MxCloneType.kClone) {
|
|
280
|
-
obj['svg'] = this.svg;
|
|
281
|
-
}
|
|
282
|
-
obj['svgPath'] = this.svgPath;
|
|
283
|
-
obj['svgPos'] = this.svgPos;
|
|
284
|
-
obj['svgSize'] = this.svgSize;
|
|
285
|
-
obj['svgAlignmentRatio'] = this.svgAlignmentRatio;
|
|
286
|
-
obj['txts'] = this.aryText;
|
|
287
|
-
obj['fixedSize'] = this.fixedSize;
|
|
288
|
-
obj['svgRotate'] = this.svgRotate;
|
|
289
|
-
obj['useSvgColor'] = this.useSvgColor;
|
|
290
|
-
obj['svgReverse'] = this.svgReverse;
|
|
291
|
-
obj['svgMargin'] = this.svgMargin;
|
|
292
|
-
return obj;
|
|
293
|
-
};
|
|
294
|
-
MxDbSVG.prototype.create = function () {
|
|
295
|
-
return new MxDbSVG();
|
|
296
|
-
};
|
|
297
|
-
MxDbSVG.prototype.transformBy = function (mat) {
|
|
298
|
-
this.svgPos.applyMatrix4(mat);
|
|
299
|
-
this.isSvgDirtyLocation = true;
|
|
300
|
-
if (!this.fixedSize) {
|
|
301
|
-
this.aryText.forEach(function (txt) {
|
|
302
|
-
txt.txtPos.applyMatrix4(mat);
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
MxDbSVG.prototype.getTypeName = function () {
|
|
307
|
-
return 'MxDbSVG';
|
|
308
|
-
};
|
|
309
|
-
MxDbSVG.prototype.setColor = function (color) {
|
|
310
|
-
_super.prototype.setColor.call(this, color);
|
|
311
|
-
if (this.svg) {
|
|
312
|
-
var color_2 = new THREE.Color(this.color);
|
|
313
|
-
this.svg.traverse(function (child) {
|
|
314
|
-
if (child.material) {
|
|
315
|
-
child.material.color = color_2;
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
MxDbSVG.prototype.onViewChange = function () {
|
|
321
|
-
if (!this.fixedSize) {
|
|
322
|
-
return false;
|
|
323
|
-
}
|
|
324
|
-
var mxObj = this.getMxObject();
|
|
325
|
-
if (mxObj == null)
|
|
326
|
-
return false;
|
|
327
|
-
if (this.svg) {
|
|
328
|
-
if (!this.svgBoxSize) {
|
|
329
|
-
this.svgBoxSize = new THREE.Vector3();
|
|
330
|
-
var box = new THREE.Box3().setFromObject(this.svg);
|
|
331
|
-
this.svgBoxSize.x = box.max.x - box.min.x;
|
|
332
|
-
this.svgBoxSize.y = box.max.y - box.min.y;
|
|
333
|
-
}
|
|
334
|
-
var _a = this.calcVewSize(mxObj), sizew = _a[0], sizeh = _a[1];
|
|
335
|
-
this.svg.scale.x = sizew / this.svgBoxSize.x;
|
|
336
|
-
this.svg.scale.y = sizeh / this.svgBoxSize.y;
|
|
337
|
-
this.svg.scale.z = this.svg.scale.x;
|
|
338
|
-
if (this.svgReverse) {
|
|
339
|
-
this.svg.scale.y *= -1;
|
|
340
|
-
}
|
|
341
|
-
this.isSvgDirtyLocation = true;
|
|
342
|
-
this.calcSvgPosition(mxObj);
|
|
343
|
-
}
|
|
344
|
-
var myThis = this;
|
|
345
|
-
this.aryText.forEach(function (txt) {
|
|
346
|
-
if (txt._txtObject && mxObj) {
|
|
347
|
-
var iSize = mxObj.screenCoordLong2Doc(txt.txtHeight);
|
|
348
|
-
if (iSize > 0.00001) {
|
|
349
|
-
if (txt._txtAspectRatio <= 0) {
|
|
350
|
-
txt._txtAspectRatio = txt._txtObject.scale.x / txt._txtObject.scale.y;
|
|
351
|
-
}
|
|
352
|
-
txt._txtObject.scale.set(txt._txtAspectRatio * iSize, iSize, 1);
|
|
353
|
-
if (txt.txtPos.x > 0)
|
|
354
|
-
txt._txtObject.position.x = myThis.svgPos.x + mxObj.screenCoordLong2Doc(txt.txtPos.x);
|
|
355
|
-
else
|
|
356
|
-
txt._txtObject.position.x = myThis.svgPos.x - mxObj.screenCoordLong2Doc(txt.txtPos.x);
|
|
357
|
-
if (txt.txtPos.y > 0)
|
|
358
|
-
txt._txtObject.position.y = myThis.svgPos.y + mxObj.screenCoordLong2Doc(txt.txtPos.y);
|
|
359
|
-
else
|
|
360
|
-
txt._txtObject.position.y = myThis.svgPos.y - mxObj.screenCoordLong2Doc(txt.txtPos.y);
|
|
361
|
-
txt._txtObject.updateMatrix();
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
return true;
|
|
366
|
-
};
|
|
367
|
-
return MxDbSVG;
|
|
368
|
-
}(MxDbEntity_1.default));
|
|
369
|
-
exports.default = MxDbSVG;
|
|
1
|
+
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,s){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])})(e,s)};return function(e,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function i(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(i.prototype=s.prototype,new i)}}();Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),MxDbEntity_1=require("../MxDbEntity"),MxDbSVGText_1=require("../MxDbSVGText"),MxThreeJS_1=require("../MxThreeJS"),MxType_1=require("../MxType"),MxDbSVG=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.svgPos=new THREE.Vector3,e.svg=null,e.svgPath="",e.svgSize=new THREE.Vector2(50,50),e.svgAlignmentRatio=new THREE.Vector2(0,0),e.svgRotate=0,e.svgReverse=!1,e.svgMargin=new THREE.Vector2(0,0),e.isSvgDirtyLocation=!1,e.isLoadFromPath=!0,e.aryText=[],e.svgBoxSize=null,e.fixedSize=!1,e.useSvgColor=!1,e}return __extends(e,t),e.prototype.calcVewSize=function(t){var e=this.svgSize.x,s=this.svgSize.y;return s<=0&&(s=this.svgBoxSize?this.svgBoxSize.y/this.svgBoxSize.x*e:e),this.fixedSize&&(e=t.screenCoordLong2Doc(e),s=t.screenCoordLong2Doc(s)),[e,s]},e.prototype.worldDraw=function(t){var e=this,s=t.getMxObject();this.calcSvgPosition(s);var i=this.calcVewSize(s),o=i[0],r=i[1],n=new THREE.Matrix4;this.svgReverse&&n.makeScale(1,-1,1);var a=new THREE.Matrix4;a.makeRotationZ(this.svgRotate);var g=new THREE.Matrix4,v=new THREE.Vector3(this.svgPos.x-o*this.svgAlignmentRatio.x,this.svgPos.y-r*this.svgAlignmentRatio.y,0);g.makeTranslation(v.x,v.y,v.z),a.multiply(n),a.premultiply(g);var x=new THREE.Vector3(0,0,0),c=new THREE.Vector3(o,0,0),h=new THREE.Vector3(o,r,0),l=new THREE.Vector3(0,r,0);if(x.applyMatrix4(a),c.applyMatrix4(a),h.applyMatrix4(a),l.applyMatrix4(a),1==t.getType()){if(this.aryText.forEach(function(i){if(i.txt.length>0){var o=new THREE.Vector3(i.txtPos.x,i.txtPos.y,0);e.fixedSize&&(i.txtPos.x>0?o.x=e.svgPos.x+s.screenCoordLong2Doc(i.txtPos.x):o.x=e.svgPos.x-s.screenCoordLong2Doc(i.txtPos.x),i.txtPos.y>0?o.y=e.svgPos.y+s.screenCoordLong2Doc(i.txtPos.y):o.y=e.svgPos.y-s.screenCoordLong2Doc(i.txtPos.y));var r=void 0;i.color&&(r=t.getColor(),t.setColor(i.color));var n=i.txtHeight;e.fixedSize&&(n=s.screenCoordLong2Doc(i.txtHeight)),i._txtObject=t.drawText(i.txt,n,0,o),i._txtAspectRatio=-1,r&&t.setColor(r)}}),this.svg)t.drawEntity(this.svg);else if(this.svgPath.length>0&&this.isLoadFromPath){var y=this,p=t.getMxObject();MxThreeJS_1.default.loadSVG(this.svgPath,void 0,function(e){if(e){var i=(new THREE.Box3).setFromObject(e);y.svgBoxSize||(y.svgBoxSize=new THREE.Vector3),y.svgBoxSize.x=i.max.x-i.min.x,y.svgBoxSize.y=i.max.y-i.min.y;var o=y.calcVewSize(s),r=o[0],n=o[1];e.scale.x=r/y.svgBoxSize.x,e.scale.y=n/y.svgBoxSize.y,e.scale.z=e.scale.x,y.svgReverse&&(e.scale.y*=-1),e.rotateZ(y.svgRotate),y.isSvgDirtyLocation=!0;var a=new THREE.Color(t.getColor());e.traverse(function(t){t.material&&(t.material=t.material.clone(),t.material.transparent=!0,y.useSvgColor||(t.material.color=a))}),y.svg=e,y.setNeedUpdateDisplay(),p.updateDisplay()}y.isLoadFromPath=!1})}t.drawSelectLine(x,h),t.drawSelectLine(c,l)}else t.drawLine(x,c),t.drawLine(c,h),t.drawLine(h,l),t.drawLine(l,x)},e.prototype.setSvgPath=function(t){this.svgPath=t,this.svg=null,this.isLoadFromPath=!0,this.svgBoxSize=null},e.prototype.getSvgPath=function(){return this.svgPath},e.prototype.setSvgPostion=function(t){this.svgPos=t.clone(),this.isSvgDirtyLocation=!0},e.prototype.getSvgPostion=function(){return this.svgPos},e.prototype.setSvgSize=function(t){this.svgSize=t,this.isSvgDirtyLocation=!0},e.prototype.getSvgSize=function(){return this.svgSize},e.prototype.setSvgAlignmentRatio=function(t){this.svgAlignmentRatio=t,this.isSvgDirtyLocation=!0},e.prototype.getSvgAlignmentRatio=function(){return this.svgAlignmentRatio},e.prototype.getText=function(t){return t<this.aryText.length?this.aryText[t]:null},e.prototype.addText=function(t){this.aryText.push(t)},e.prototype.getGripPoints=function(){var t=[];return t.push(this.svgPos),t},e.prototype.moveGripPointsAt=function(t,e){return 0==t&&(this.svgPos.add(e),this.fixedSize||this.aryText.forEach(function(t){t.txtPos.add(e)})),this.isSvgDirtyLocation=!0,!0},e.prototype.calcSvgPosition=function(t){if(this.svg&&this.isSvgDirtyLocation){this.isSvgDirtyLocation=!1;var e=this.calcVewSize(t),s=e[0],i=e[1];this.svg.position.x=this.svgPos.x-s*this.svgAlignmentRatio.x-this.svgMargin.x*s,this.svg.position.y=this.svgPos.y-i*this.svgAlignmentRatio.y-this.svgMargin.y*i}},e.prototype.dwgIn=function(t){var e=this;this.onDwgIn(t),this.fixedSize=t.fixedSize,this.fixedSize?this.svg=null:t.type==MxType_1.default.MxCloneType.kClone&&t.svg&&(this.svg=t.svg.clone()),this.svgPos.copy(t.svgPos),this.svgPath=t.svgPath.substr(0),this.svgSize.copy(t.svgSize),this.svgAlignmentRatio.copy(t.svgAlignmentRatio),this.isSvgDirtyLocation=!0,this.svg||(this.isLoadFromPath=!0),this.svgBoxSize=null;var s=t.txts;return this.aryText=[],s.forEach(function(t){var s=new MxDbSVGText_1.default;s.txt=t.txt,s.txtHeight=t.txtHeight,s.txtPos.copy(t.txtPos),e.aryText.push(s)}),this.svgRotate=t.svgRotate,this.useSvgColor=t.useSvgColor,this.svgReverse=t.svgReverse,this.svgMargin=t.svgMargin,!0},e.prototype.dwgOut=function(t){return this.onDwgOut(t),t.type==MxType_1.default.MxCloneType.kClone&&(t.svg=this.svg),t.svgPath=this.svgPath,t.svgPos=this.svgPos,t.svgSize=this.svgSize,t.svgAlignmentRatio=this.svgAlignmentRatio,t.txts=this.aryText,t.fixedSize=this.fixedSize,t.svgRotate=this.svgRotate,t.useSvgColor=this.useSvgColor,t.svgReverse=this.svgReverse,t.svgMargin=this.svgMargin,t},e.prototype.create=function(){return new e},e.prototype.transformBy=function(t){this.svgPos.applyMatrix4(t),this.isSvgDirtyLocation=!0,this.fixedSize||this.aryText.forEach(function(e){e.txtPos.applyMatrix4(t)})},e.prototype.getTypeName=function(){return"MxDbSVG"},e.prototype.setColor=function(e){if(t.prototype.setColor.call(this,e),this.svg){var s=new THREE.Color(this.color);this.svg.traverse(function(t){t.material&&(t.material.color=s)})}},e.prototype.onViewChange=function(){if(!this.fixedSize)return!1;var t=this.getMxObject();if(null==t)return!1;if(this.svg){if(!this.svgBoxSize){this.svgBoxSize=new THREE.Vector3;var e=(new THREE.Box3).setFromObject(this.svg);this.svgBoxSize.x=e.max.x-e.min.x,this.svgBoxSize.y=e.max.y-e.min.y}var s=this.calcVewSize(t),i=s[0],o=s[1];this.svg.scale.x=i/this.svgBoxSize.x,this.svg.scale.y=o/this.svgBoxSize.y,this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}var r=this;return this.aryText.forEach(function(e){if(e._txtObject&&t){var s=t.screenCoordLong2Doc(e.txtHeight);s>1e-5&&(e._txtAspectRatio<=0&&(e._txtAspectRatio=e._txtObject.scale.x/e._txtObject.scale.y),e._txtObject.scale.set(e._txtAspectRatio*s,s,1),e.txtPos.x>0?e._txtObject.position.x=r.svgPos.x+t.screenCoordLong2Doc(e.txtPos.x):e._txtObject.position.x=r.svgPos.x-t.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?e._txtObject.position.y=r.svgPos.y+t.screenCoordLong2Doc(e.txtPos.y):e._txtObject.position.y=r.svgPos.y-t.screenCoordLong2Doc(e.txtPos.y),e._txtObject.updateMatrix())}}),!0},e}(MxDbEntity_1.default);exports.default=MxDbSVG;
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @module McEdGetPointWorldDrawObject*/
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
var MxDbSVG_1 = require("./MxDbSVG");
|
|
5
|
-
exports.default = MxDbSVG_1.default;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var MxDbSVG_1=require("./MxDbSVG");exports.default=MxDbSVG_1.default;
|