mxdraw 0.1.2 → 0.1.5
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/McGeVector3d/McGeVector3d.js +2 -0
- package/dist/lib/MxModule/McGeVector3d/index.js +3 -0
- package/dist/lib/MxModule/MxDbAlignedDimension/MxDbAlignedDimension.js +213 -0
- package/dist/lib/MxModule/MxDbAlignedDimension/index.js +5 -0
- package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +45 -19
- package/dist/lib/MxModule/MxDbImage/MxDbImage.js +147 -0
- package/dist/lib/MxModule/MxDbImage/index.js +5 -0
- package/dist/lib/MxModule/MxDbLine/MxDbLine.js +94 -0
- package/dist/lib/MxModule/MxDbLine/index.js +5 -0
- package/dist/lib/MxModule/MxDbRect/MxDbRect.js +219 -0
- package/dist/lib/MxModule/MxDbRect/index.js +4 -0
- package/dist/lib/MxModule/MxDbSVG/MxDbSVG.js +208 -0
- package/dist/lib/MxModule/MxDbSVG/index.js +5 -0
- package/dist/lib/MxModule/MxDrawObject/MxDrawObject.js +41 -44
- package/dist/lib/MxModule/MxFilters/MxFilters.js +201 -0
- package/dist/lib/MxModule/MxFilters/index.js +4 -0
- package/dist/lib/MxModule/MxFun/MxFun.js +70 -30
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js +6 -1
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +3 -3
- package/dist/lib/MxModule/MxThreeJS/SVGLoader.js +4 -4
- package/dist/lib/MxModule/Mxassembly/Mxassembly.js +18 -0
- package/dist/lib/MxModule/Mxassembly/index.js +9 -0
- package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +16 -0
- package/dist/lib/MxModule/loadCoreCode/mxcadassembly_es5.js +1519 -0
- package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +101 -92
- package/dist/lib/MxModule/store/store.js +1 -0
- package/dist/lib/doc.js +11 -1
- package/dist/lib/mxdraw.js +26 -6
- package/dist/lib/tools/three/index.js +100 -3
- package/dist/lib/types/Mxassembly.js +2 -0
- 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/McGeVector3d/McGeVector3d.d.ts +17 -0
- package/dist/types/MxModule/McGeVector3d/index.d.ts +3 -0
- package/dist/types/MxModule/McGiWorldDraw/McGiWorldDraw.d.ts +61 -65
- package/dist/types/MxModule/MxDbAlignedDimension/MxDbAlignedDimension.d.ts +21 -0
- package/dist/types/MxModule/MxDbAlignedDimension/index.d.ts +3 -0
- package/dist/types/MxModule/MxDbEntity/MxDbEntity.d.ts +47 -26
- package/dist/types/MxModule/MxDbImage/MxDbImage.d.ts +28 -0
- package/dist/types/MxModule/MxDbImage/index.d.ts +3 -0
- package/dist/types/MxModule/MxDbLine/MxDbLine.d.ts +22 -0
- package/dist/types/MxModule/MxDbLine/index.d.ts +3 -0
- package/dist/types/MxModule/MxDbRect/MxDbRect.d.ts +74 -0
- package/dist/types/MxModule/MxDbRect/index.d.ts +2 -0
- package/dist/types/MxModule/MxDbSVG/MxDbSVG.d.ts +42 -0
- package/dist/types/MxModule/MxDbSVG/index.d.ts +3 -0
- package/dist/types/MxModule/MxDrawObject/MxDrawObject.d.ts +38 -39
- package/dist/types/MxModule/MxFilters/MxFilters.d.ts +94 -0
- package/dist/types/MxModule/MxFilters/index.d.ts +2 -0
- package/dist/types/MxModule/MxFun/MxFun.d.ts +59 -27
- package/dist/types/MxModule/MxThreeJS/MxThreeJS.d.ts +2 -2
- package/dist/types/MxModule/MxType/index.d.ts +1 -1
- package/dist/types/MxModule/Mxassembly/Mxassembly.d.ts +11 -0
- package/dist/types/MxModule/Mxassembly/index.d.ts +3 -0
- package/dist/types/MxModule/loadCoreCode/mxcadassembly_es5.d.ts +1 -0
- package/dist/types/MxModule/store/store.d.ts +2 -0
- package/dist/types/doc.d.ts +6 -1
- package/dist/types/mxdraw.d.ts +18 -4
- package/dist/types/tools/three/index.d.ts +20 -1
- package/dist/types/types/MxDrawObject.d.ts +2 -2
- package/dist/types/types/MxFun.d.ts +8 -5
- package/dist/types/types/Mxassembly.d.ts +3 -0
- package/package.json +3 -3
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
/** 简单颜色滤镜矩阵 */
|
|
15
|
+
var three_1 = require("three");
|
|
16
|
+
var MxFilters = /** @class */ (function () {
|
|
17
|
+
function MxFilters() {
|
|
18
|
+
this.uniformObj = {};
|
|
19
|
+
this.filtersStr = '';
|
|
20
|
+
this.filtersTypes = '';
|
|
21
|
+
//顶点着色器代码片段
|
|
22
|
+
this.VSHADER_SOURCE = "\n varying vec2 v_Uv; \n void main () {\n v_Uv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n ";
|
|
23
|
+
//片元着色器代码片段
|
|
24
|
+
this.FSHADER_SOURCE = "\n varying vec2 v_Uv;\n uniform sampler2D e_Texture;\n uniform mat4 colorMatrix;\n ".concat(this.filtersStr, "\n void main () {\n vec4 color = texture2D( e_Texture, v_Uv );\n color = color * colorMatrix;\n ").concat(this.filtersTypes, "\n gl_FragColor = color;\n }");
|
|
25
|
+
this._matrix = new three_1.Matrix4();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 过滤或增强某个颜色通道
|
|
29
|
+
* @param {ChannelParamTypes}
|
|
30
|
+
* */
|
|
31
|
+
MxFilters.prototype.channel = function (_a) {
|
|
32
|
+
var _b = _a.r, r = _b === void 0 ? 1 : _b, _c = _a.g, g = _c === void 0 ? 1 : _c, _d = _a.b, b = _d === void 0 ? 1 : _d;
|
|
33
|
+
this._matrix = new three_1.Matrix4()
|
|
34
|
+
.set(r, 0, 0, 0, 0, g, 0, 0, 0, 0, b, 0, 0, 0, 0, 1)
|
|
35
|
+
.multiply(this._matrix);
|
|
36
|
+
return this;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* 改变亮度
|
|
40
|
+
* @param {number} p
|
|
41
|
+
* p = 0 全暗,p > 0 且 p < 1 调暗,p = 1 原色, p > 1 调亮
|
|
42
|
+
* */
|
|
43
|
+
MxFilters.prototype.brightness = function (p) {
|
|
44
|
+
this._matrix = new three_1.Matrix4()
|
|
45
|
+
.set(p, 0, 0, 0, 0, p, 0, 0, 0, 0, p, 0, 0, 0, 0, 1)
|
|
46
|
+
.multiply(this._matrix);
|
|
47
|
+
return this;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* 饱和度
|
|
51
|
+
* @param {number} p
|
|
52
|
+
* p = 0 完全灰度化,p = 1 原色,p > 1 增强饱和度
|
|
53
|
+
* */
|
|
54
|
+
MxFilters.prototype.saturate = function (p) {
|
|
55
|
+
var r = 0.2126 * (1 - p);
|
|
56
|
+
var g = 0.7152 * (1 - p);
|
|
57
|
+
var b = 0.0722 * (1 - p);
|
|
58
|
+
this._matrix = new three_1.Matrix4()
|
|
59
|
+
.set(r + p, g, b, 0, r, g + p, b, 0, r, g, b + p, 0, 0, 0, 0, 1)
|
|
60
|
+
.multiply(this._matrix);
|
|
61
|
+
return this;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* 对比度
|
|
65
|
+
* @param {number} p
|
|
66
|
+
* p = 1 原色, p < 1 减弱对比度,p > 1 增强对比度
|
|
67
|
+
* */
|
|
68
|
+
MxFilters.prototype.contrast = function (p) {
|
|
69
|
+
var d = 0.5 * (1 - p);
|
|
70
|
+
this._matrix = new three_1.Matrix4()
|
|
71
|
+
.set(p, 0, 0, 0, 0, p, 0, 0, 0, 0, p, 0, d, d, d, 1)
|
|
72
|
+
.multiply(this._matrix);
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* 透明度
|
|
77
|
+
* @param {number} p
|
|
78
|
+
* p = 0 全透明,p = 1 原色
|
|
79
|
+
* */
|
|
80
|
+
MxFilters.prototype.opacity = function (p) {
|
|
81
|
+
this._matrix = new three_1.Matrix4()
|
|
82
|
+
.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, p)
|
|
83
|
+
.multiply(this._matrix);
|
|
84
|
+
return this;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* 反色
|
|
88
|
+
* @param {number} p
|
|
89
|
+
* p = 0 原色, p = 1 完全反色
|
|
90
|
+
* */
|
|
91
|
+
MxFilters.prototype.invert = function (p) {
|
|
92
|
+
var d = 1 - 2 * p;
|
|
93
|
+
this._matrix = new three_1.Matrix4()
|
|
94
|
+
.set(d, 0, 0, 0, 0, d, 0, 0, 0, 0, d, 0, p, p, p, 1)
|
|
95
|
+
.multiply(this._matrix);
|
|
96
|
+
return this;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* 灰度
|
|
100
|
+
* @param {number} p 0~1
|
|
101
|
+
* */
|
|
102
|
+
MxFilters.prototype.grayscale = function (p) {
|
|
103
|
+
if (p === void 0) { p = 1; }
|
|
104
|
+
var r = 0.2126 * p;
|
|
105
|
+
var g = 0.7152 * p;
|
|
106
|
+
var b = 0.0722 * p;
|
|
107
|
+
this._matrix = new three_1.Matrix4()
|
|
108
|
+
.set(r + 1 - p, g, b, 0, r, g + 1 - p, b, 0, r, g, b + 1 - p, 0, 0, 0, 0, 1)
|
|
109
|
+
.multiply(this._matrix);
|
|
110
|
+
return this;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* 深褐色
|
|
114
|
+
* @param {number} p 0~1
|
|
115
|
+
* */
|
|
116
|
+
MxFilters.prototype.sepia = function (p) {
|
|
117
|
+
if (p === void 0) { p = 1; }
|
|
118
|
+
this._matrix = new three_1.Matrix4()
|
|
119
|
+
.set(1 - 0.607 * p, 0.769 * p, 0.189 * p, 0, 0.349 * p, 1 - 0.314 * p, 0.168 * p, 0, 0.272 * p, 0.534 * p, 1 - 0.869 * p, 0, 0, 0, 0, 1)
|
|
120
|
+
.multiply(this._matrix);
|
|
121
|
+
return this;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* 色相旋转,将色调沿极坐标转过deg角度
|
|
125
|
+
* @param {number} deg 0~360
|
|
126
|
+
* */
|
|
127
|
+
MxFilters.prototype.hueRotate = function (deg) {
|
|
128
|
+
var rotation = (deg / 180) * Math.PI;
|
|
129
|
+
var cos = Math.cos(rotation), sin = Math.sin(rotation), lumR = 0.2126, lumG = 0.7152, lumB = 0.0722;
|
|
130
|
+
this._matrix = new three_1.Matrix4()
|
|
131
|
+
.set(lumR + cos * (1 - lumR) + sin * -lumR, lumG + cos * -lumG + sin * -lumG, lumB + cos * -lumB + sin * (1 - lumB), 0, lumR + cos * -lumR + sin * 0.143, lumG + cos * (1 - lumG) + sin * 0.14, lumB + cos * -lumB + sin * -0.283, 0, lumR + cos * -lumR + sin * -(1 - lumR), lumG + cos * -lumG + sin * lumG, lumB + cos * (1 - lumB) + sin * lumB, 0, 0, 0, 0, 1)
|
|
132
|
+
.multiply(this._matrix);
|
|
133
|
+
return this;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* 色相旋转,将色调沿极坐标转过deg角度
|
|
137
|
+
* @param {number} deg 0~360
|
|
138
|
+
* */
|
|
139
|
+
/**
|
|
140
|
+
* 卷积
|
|
141
|
+
* @param {Matrix3} cKernel 3*3的矩阵
|
|
142
|
+
* @param {number} stStep 1 / 9
|
|
143
|
+
* @param {number} scaleFactor 521
|
|
144
|
+
* */
|
|
145
|
+
MxFilters.prototype.convolution = function (cKernel, stStep, scaleFactor) {
|
|
146
|
+
if (stStep === void 0) { stStep = 1 / 9; }
|
|
147
|
+
if (scaleFactor === void 0) { scaleFactor = 521; }
|
|
148
|
+
this.uniformObj = __assign(__assign({}, this.uniformObj), { cKernel: {
|
|
149
|
+
value: cKernel.toArray()
|
|
150
|
+
}, stStep: {
|
|
151
|
+
value: stStep
|
|
152
|
+
}, scaleFactor: {
|
|
153
|
+
value: scaleFactor
|
|
154
|
+
} });
|
|
155
|
+
if (this.filtersTypes.indexOf('convolutionTextureColor') < 0) {
|
|
156
|
+
this.filtersStr += "\n uniform float cKernel[9];\n uniform float stStep;\n uniform float scaleFactor;\n vec4 convolutionTextureColor(vec4 color) {\n vec2 offsets[9];\n offsets[0] = vec2(-1.0,-1.0);\n offsets[1] = vec2(0.0,-1.0);\n offsets[2] = vec2(1.0,-1.0);\n offsets[3] = vec2(-1.0,0.0);\n offsets[4] = vec2(0.0,0.0);\n offsets[5] = vec2(1.0,0.0);\n offsets[6] = vec2(-1.0,1.0);\n offsets[7] = vec2(0.0,1.0);\n offsets[8] = vec2(1.0,1.0);\n \n vec4 sum = color;\n for(int i = 0; i < 9; i++) {\n sum = sum + cKernel[i] * scaleFactor * texture2D(e_Texture, v_Uv + offsets[i] / stStep);\n };\n return sum;\n }";
|
|
157
|
+
this.filtersTypes += 'color = convolutionTextureColor(color);\n';
|
|
158
|
+
}
|
|
159
|
+
return this;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* 重置所有滤镜效果
|
|
163
|
+
* */
|
|
164
|
+
MxFilters.prototype.reset = function () {
|
|
165
|
+
this.uniformObj = {};
|
|
166
|
+
this.filtersStr = '';
|
|
167
|
+
this.filtersTypes = '';
|
|
168
|
+
this._matrix = new three_1.Matrix4();
|
|
169
|
+
return this;
|
|
170
|
+
};
|
|
171
|
+
// 获取滤镜自定义着色器数据
|
|
172
|
+
MxFilters.prototype._getFilterShaderData = function (texture) {
|
|
173
|
+
return {
|
|
174
|
+
uniforms: __assign({ e_Texture: {
|
|
175
|
+
value: texture
|
|
176
|
+
}, colorMatrix: {
|
|
177
|
+
value: this._matrix
|
|
178
|
+
} }, this.uniformObj),
|
|
179
|
+
// 顶点着色器
|
|
180
|
+
vertexShader: this.VSHADER_SOURCE,
|
|
181
|
+
// 片元着色器
|
|
182
|
+
fragmentShader: this.FSHADER_SOURCE
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
// 获取转换后的颜色
|
|
186
|
+
MxFilters.prototype._getFilterColor = function (color, opacity) {
|
|
187
|
+
if (color === void 0) { color = '#000000'; }
|
|
188
|
+
if (opacity === void 0) { opacity = 1; }
|
|
189
|
+
color = new three_1.Color(color);
|
|
190
|
+
var r = color.r, g = color.g, b = color.b;
|
|
191
|
+
var arr = this._matrix.toArray();
|
|
192
|
+
var A = arr[12] * opacity + arr[13] * opacity + arr[14] * opacity + arr[15] * opacity + 0;
|
|
193
|
+
var R = arr[0] * r + arr[1] * r + arr[2] * r + arr[3] * opacity;
|
|
194
|
+
var G = arr[4] * g + arr[5] * g + arr[6] * g + arr[7] * opacity;
|
|
195
|
+
var B = arr[8] * b + arr[9] * b + arr[10] * b + arr[11] * opacity;
|
|
196
|
+
color.setRGB(R, G, B);
|
|
197
|
+
return color;
|
|
198
|
+
};
|
|
199
|
+
return MxFilters;
|
|
200
|
+
}());
|
|
201
|
+
exports.default = MxFilters;
|
|
@@ -14,6 +14,7 @@ var create_1 = require("../../tools/dom/create");
|
|
|
14
14
|
var proxy_1 = require("../../tools/proxy");
|
|
15
15
|
var MxDrawObject_1 = require("../MxDrawObject");
|
|
16
16
|
var store_1 = require("../store/store");
|
|
17
|
+
var useCanvasResizeListener_1 = require("../useCanvasResizeListener");
|
|
17
18
|
/**
|
|
18
19
|
* MxFun 模块
|
|
19
20
|
* 导出库时已实例化,只需要调用实例方法 例如:
|
|
@@ -50,7 +51,7 @@ var MxFun = /** @class */ (function () {
|
|
|
50
51
|
* ```
|
|
51
52
|
*/
|
|
52
53
|
MxFun.prototype.createMxObject = function (_a) {
|
|
53
|
-
var _b = _a.canvasId, canvasId = _b === void 0 ? (0, random_1.createReandomId)() : _b, _c = _a.cadFile, cadFile = _c === void 0 ? '
|
|
54
|
+
var _b = _a.canvasId, canvasId = _b === void 0 ? (0, random_1.createReandomId)() : _b, _c = _a.cadFile, cadFile = _c === void 0 ? '' : _c, callback = _a.callback, _d = _a.isNewFile, isNewFile = _d === void 0 ? false : _d, _e = _a.useWebsocket, useWebsocket = _e === void 0 ? false : _e;
|
|
54
55
|
// 获取canvas和其父级
|
|
55
56
|
var canvas = (0, create_1.createCanvas)(canvasId);
|
|
56
57
|
var canvasParent = (0, create_1.createCanvasParent)(canvas);
|
|
@@ -75,12 +76,14 @@ var MxFun = /** @class */ (function () {
|
|
|
75
76
|
height: canvasParent.clientHeight
|
|
76
77
|
};
|
|
77
78
|
});
|
|
79
|
+
// 使用canvas侦听器 监听canvas元素的大小变化
|
|
80
|
+
(0, useCanvasResizeListener_1.default)(mxdrawObj, canvas);
|
|
78
81
|
callback &&
|
|
79
82
|
callback(mxdrawObj, {
|
|
80
83
|
canvas: canvas,
|
|
81
84
|
canvasParent: canvasParent
|
|
82
85
|
});
|
|
83
|
-
}, isNewFile);
|
|
86
|
+
}, undefined, isNewFile, useWebsocket);
|
|
84
87
|
};
|
|
85
88
|
/**
|
|
86
89
|
* 为程序设置服务器地址
|
|
@@ -200,6 +203,32 @@ var MxFun = /** @class */ (function () {
|
|
|
200
203
|
MxFun.prototype.screenCoordLong2World = function (len) {
|
|
201
204
|
return store_1.default.state.MxFun.screenCoordLong2World(len);
|
|
202
205
|
};
|
|
206
|
+
/**
|
|
207
|
+
* 屏幕坐标长度转文档坐标长度
|
|
208
|
+
* @param len 屏幕坐标长度
|
|
209
|
+
* @return number 文档坐标长度
|
|
210
|
+
* @example
|
|
211
|
+
* ``` typescript
|
|
212
|
+
* const len = Mx.MxFun.screenCoordLong2Doc(36)
|
|
213
|
+
* console.log(len)
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
MxFun.prototype.screenCoordLong2Doc = function (len) {
|
|
217
|
+
return store_1.default.state.MxFun.screenCoordLong2Doc(len);
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* 文档坐标长度转屏幕坐标长度
|
|
221
|
+
* @param len 文档坐标长度
|
|
222
|
+
* @return number 屏幕坐标长度
|
|
223
|
+
* @example
|
|
224
|
+
* ``` typescript
|
|
225
|
+
* const len = Mx.MxFun.docCoordLong2Screen(36)
|
|
226
|
+
* console.log(len)
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
MxFun.prototype.docCoordLong2Screen = function (len) {
|
|
230
|
+
return store_1.default.state.MxFun.docCoordLong2Screen(len);
|
|
231
|
+
};
|
|
203
232
|
/**
|
|
204
233
|
* THREE.JS坐标长度转屏幕坐标长度
|
|
205
234
|
* @param len THREE.JS坐标长度
|
|
@@ -214,14 +243,14 @@ var MxFun = /** @class */ (function () {
|
|
|
214
243
|
return store_1.default.state.MxFun.worldCoordLong2Doc(len);
|
|
215
244
|
};
|
|
216
245
|
/**
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
246
|
+
* DWG文档坐标长度到ThreeJS坐标长度
|
|
247
|
+
* @returns number
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
*
|
|
251
|
+
*
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
225
254
|
MxFun.prototype.docCoordLong2World = function (l) {
|
|
226
255
|
return store_1.default.state.MxFun.docCoordLong2World(l);
|
|
227
256
|
};
|
|
@@ -298,8 +327,8 @@ var MxFun = /** @class */ (function () {
|
|
|
298
327
|
* console.log(vector3)
|
|
299
328
|
* ```
|
|
300
329
|
*/
|
|
301
|
-
MxFun.prototype.screenCoord2Doc = function (x, y
|
|
302
|
-
return store_1.default.state.MxFun.screenCoord2Doc(x, y,
|
|
330
|
+
MxFun.prototype.screenCoord2Doc = function (x, y) {
|
|
331
|
+
return store_1.default.state.MxFun.screenCoord2Doc(x, y, 0);
|
|
303
332
|
};
|
|
304
333
|
/**
|
|
305
334
|
* 文档转屏幕坐标.
|
|
@@ -313,8 +342,8 @@ var MxFun = /** @class */ (function () {
|
|
|
313
342
|
* console.log(vector3)
|
|
314
343
|
* ```
|
|
315
344
|
*/
|
|
316
|
-
MxFun.prototype.docCoord2Screen = function (x, y
|
|
317
|
-
return store_1.default.state.MxFun.docCoord2Screen(x, y,
|
|
345
|
+
MxFun.prototype.docCoord2Screen = function (x, y) {
|
|
346
|
+
return store_1.default.state.MxFun.docCoord2Screen(x, y, 0);
|
|
318
347
|
};
|
|
319
348
|
/**
|
|
320
349
|
* 更新显示,使用Three.js绘制了对象,调用该函数更新显示。
|
|
@@ -488,22 +517,22 @@ var MxFun = /** @class */ (function () {
|
|
|
488
517
|
return store_1.default.state.MxFun.loadImageMaterial(imageUrlPath, callResult);
|
|
489
518
|
};
|
|
490
519
|
/**
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
520
|
+
* 判断点是否在一个闭合的多边形区域。
|
|
521
|
+
* @param p
|
|
522
|
+
* @return any
|
|
523
|
+
* @example
|
|
524
|
+
* ``` typescript
|
|
525
|
+
* let aryPoint:Array<THREE.Vector3> = [];
|
|
526
|
+
* aryPoint.push(new THREE.Vector3(0,0,0));
|
|
527
|
+
* aryPoint.push(new THREE.Vector3(0,100,0));
|
|
528
|
+
* aryPoint.push(new THREE.Vector3(100,100,0));
|
|
529
|
+
* aryPoint.push(new THREE.Vector3(100,0,0));
|
|
530
|
+
* let pt:THREE.Vector3 = new THREE.Vector3(150,150);
|
|
531
|
+
* if(MxFun.pointInPolyline(pt,aryPoint) ){
|
|
532
|
+
* console.log("in");
|
|
533
|
+
* }
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
507
536
|
MxFun.prototype.pointInPolyline = function (pt, vecPolyline) {
|
|
508
537
|
return store_1.default.state.MxFun.pointInPolyline(pt, vecPolyline);
|
|
509
538
|
};
|
|
@@ -518,6 +547,17 @@ var MxFun = /** @class */ (function () {
|
|
|
518
547
|
MxFun.prototype.calcArea = function (aryPoint) {
|
|
519
548
|
return store_1.default.state.MxFun.calcArea(aryPoint);
|
|
520
549
|
};
|
|
550
|
+
/**
|
|
551
|
+
* 重新打开cad文件,该函数在控件创建完后,需要再次重新打开文件,调用。
|
|
552
|
+
* @param sFile 打的cad文件路径
|
|
553
|
+
* @return any
|
|
554
|
+
* @example
|
|
555
|
+
* ``` typescript
|
|
556
|
+
* ```
|
|
557
|
+
*/
|
|
558
|
+
MxFun.prototype.openFile = function (sFile) {
|
|
559
|
+
return store_1.default.state.MxFun.openFile(sFile);
|
|
560
|
+
};
|
|
521
561
|
return MxFun;
|
|
522
562
|
}());
|
|
523
563
|
exports.default = MxFun;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
4
|
+
//版权所有(C)2002-2022,成都梦想凯德科技有限公司。
|
|
5
|
+
//本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
|
|
6
|
+
//此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
|
|
7
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
3
8
|
var three_1 = require("three");
|
|
4
9
|
var math_1 = require("../../tools/algorithm/math");
|
|
5
10
|
var formatting_1 = require("../../tools/formatting");
|
|
@@ -139,7 +144,7 @@ var MxThreeJS = /** @class */ (function () {
|
|
|
139
144
|
context.font = sFont;
|
|
140
145
|
context.textAlign = 'center';
|
|
141
146
|
context.textBaseline = 'middle';
|
|
142
|
-
context.fillStyle = (0, formatting_1.formatString)('rgba({0}, {1}, {2}, 1.0)', ((iColor >> 16) & 0xff) +
|
|
147
|
+
context.fillStyle = (0, formatting_1.formatString)('rgba({0}, {1}, {2}, 1.0)', ((iColor >> 16) & 0xff) + '', ((iColor >> 8) & 0xff) + '', (iColor & 0xff) + '');
|
|
143
148
|
//const sColor = formatString('#{0}', iColor.toString(16))
|
|
144
149
|
context.fillText(message, textWidth / 2, textHeight / 2);
|
|
145
150
|
var texture = new three_1.Texture(canvas);
|
|
@@ -88,7 +88,7 @@ var MxThreeJSBuffer = /** @class */ (function () {
|
|
|
88
88
|
else {
|
|
89
89
|
this.loadSVGImp(url, color, function (group, aryMeterial) {
|
|
90
90
|
if (group && aryMeterial) {
|
|
91
|
-
var data_1 = new MxThreeJSSVGData;
|
|
91
|
+
var data_1 = new MxThreeJSSVGData();
|
|
92
92
|
data_1.svg = group;
|
|
93
93
|
data_1.aryMeterial = aryMeterial;
|
|
94
94
|
_this.mapSvgUrlToData.set(url, data_1);
|
|
@@ -104,7 +104,7 @@ var MxThreeJSBuffer = /** @class */ (function () {
|
|
|
104
104
|
return MxThreeJSBuffer;
|
|
105
105
|
}());
|
|
106
106
|
function default_1(MxThreeJS) {
|
|
107
|
-
var mxThreeJsBuffer = new MxThreeJSBuffer;
|
|
107
|
+
var mxThreeJsBuffer = new MxThreeJSBuffer();
|
|
108
108
|
MxThreeJS.createImage = function (pos, w, h, imageUrlPath, callResult) {
|
|
109
109
|
new three_1.TextureLoader().load(imageUrlPath, function (texture) {
|
|
110
110
|
var geometry = new three_1.PlaneGeometry(w, h);
|
|
@@ -116,7 +116,7 @@ function default_1(MxThreeJS) {
|
|
|
116
116
|
});
|
|
117
117
|
if (materialTexture.map)
|
|
118
118
|
materialTexture.map.needsUpdate = true;
|
|
119
|
-
(0, three_2.
|
|
119
|
+
(0, three_2.setGeometrPostion)(geometry, pos);
|
|
120
120
|
//var mesh = new Mesh(geometry, material);
|
|
121
121
|
var mesh = new three_1.Mesh(geometry, materialTexture);
|
|
122
122
|
mesh.material['depthTest'] = false;
|
|
@@ -1185,13 +1185,13 @@ var SVGLoader = /** @class */ (function (_super) {
|
|
|
1185
1185
|
var center = new three_1.Vector2();
|
|
1186
1186
|
boundingBox.getCenter(center);
|
|
1187
1187
|
var allIntersections = [];
|
|
1188
|
-
paths
|
|
1188
|
+
paths.forEach(function (path) {
|
|
1189
1189
|
// check if the center of the bounding box is in the bounding box of the paths.
|
|
1190
1190
|
// this is a pruning method to limit the search of intersections in paths that can't envelop of the current path.
|
|
1191
1191
|
// if a path envelops another path. The center of that oter path, has to be inside the bounding box of the enveloping path.
|
|
1192
1192
|
if (path.boundingBox.containsPoint(center)) {
|
|
1193
1193
|
var intersections = getIntersections(scanline, path.points);
|
|
1194
|
-
intersections
|
|
1194
|
+
intersections.forEach(function (p) {
|
|
1195
1195
|
allIntersections.push({ identifier: path.identifier, isCW: path.isCW, point: p });
|
|
1196
1196
|
});
|
|
1197
1197
|
}
|
|
@@ -1307,13 +1307,13 @@ var SVGLoader = /** @class */ (function (_super) {
|
|
|
1307
1307
|
// check if path is solid or a hole
|
|
1308
1308
|
var isAHole = simplePaths.map(function (p) { return isHoleTo(p, simplePaths, scanlineMinX, scanlineMaxX, shapePath.userData.style.fillRule); });
|
|
1309
1309
|
var shapesToReturn = [];
|
|
1310
|
-
simplePaths
|
|
1310
|
+
simplePaths.forEach(function (p) {
|
|
1311
1311
|
var amIAHole = isAHole[p.identifier];
|
|
1312
1312
|
if (!amIAHole.isHole) {
|
|
1313
1313
|
var shape_1 = new three_1.Shape();
|
|
1314
1314
|
shape_1.curves = p.curves;
|
|
1315
1315
|
var holes = isAHole.filter(function (h) { return h.isHole && h.for === p.identifier; });
|
|
1316
|
-
holes
|
|
1316
|
+
holes.forEach(function (h) {
|
|
1317
1317
|
var hole = simplePaths[h.identifier];
|
|
1318
1318
|
var path = new three_1.Path();
|
|
1319
1319
|
path.curves = hole.curves;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var store_1 = require("../store/store");
|
|
4
|
+
/**
|
|
5
|
+
* Mxassembly 模块
|
|
6
|
+
* 导出库时已实例化,只需要调用实例方法 例如:
|
|
7
|
+
* ```typescript
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
var Mxassembly = /** @class */ (function () {
|
|
11
|
+
function Mxassembly() {
|
|
12
|
+
}
|
|
13
|
+
Mxassembly.prototype.NewMcGeVector3d = function () {
|
|
14
|
+
return new store_1.default.state.Mxassembly.McGeVector3d();
|
|
15
|
+
};
|
|
16
|
+
return Mxassembly;
|
|
17
|
+
}());
|
|
18
|
+
exports.default = Mxassembly;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var Mxassembly_1 = require("./Mxassembly");
|
|
4
|
+
// import store from '../store/_index'
|
|
5
|
+
// import loadCoreCode from '../loadCoreCode'
|
|
6
|
+
// if (!store.state.MxFUn) {
|
|
7
|
+
// loadCoreCode()
|
|
8
|
+
// }
|
|
9
|
+
exports.default = new Mxassembly_1.default();
|
|
@@ -40,6 +40,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
var dynamicImport_1 = require("../../tools/dynamicImport");
|
|
41
41
|
var store_1 = require("../store/store");
|
|
42
42
|
var mxfun_es5_js_1 = require("./mxfun.es5.js");
|
|
43
|
+
var mxcadassembly_es5_js_1 = require("./mxcadassembly_es5.js");
|
|
44
|
+
var MxDbImage_1 = require("../MxDbImage");
|
|
45
|
+
var MxDbSVG_1 = require("../MxDbSVG");
|
|
46
|
+
var MxDbAlignedDimension_1 = require("../MxDbAlignedDimension");
|
|
47
|
+
var MxDbLine_1 = require("../MxDbLine");
|
|
48
|
+
function rxInitMxEntity() {
|
|
49
|
+
new MxDbImage_1.default().rxInit();
|
|
50
|
+
new MxDbSVG_1.default().rxInit();
|
|
51
|
+
new MxDbAlignedDimension_1.default().rxInit();
|
|
52
|
+
new MxDbLine_1.default().rxInit();
|
|
53
|
+
}
|
|
43
54
|
/**
|
|
44
55
|
* 加载MxDraw库的核心代码 才能使用Mx的其他模块
|
|
45
56
|
* @returns Promise<{@link MxFun}>
|
|
@@ -85,9 +96,14 @@ function loadCoreCode() {
|
|
|
85
96
|
window.MxMain = function (requireFun) {
|
|
86
97
|
store_1.default.events.emit('MxMain', requireFun);
|
|
87
98
|
window.MxMain = undefined;
|
|
99
|
+
rxInitMxEntity();
|
|
88
100
|
res();
|
|
89
101
|
return 0;
|
|
90
102
|
};
|
|
103
|
+
(0, mxcadassembly_es5_js_1.default)().then(function (mxassembly) {
|
|
104
|
+
//console.log(mxassembly);
|
|
105
|
+
store_1.default.commit('setMxassembly', mxassembly);
|
|
106
|
+
});
|
|
91
107
|
// 加载mxfun.min.js,mxfun()相当直接模拟了mxfun.min.js的加载。
|
|
92
108
|
(0, mxfun_es5_js_1.default)();
|
|
93
109
|
return [3 /*break*/, 3];
|