mxdraw 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/lib/MxModule/MxDbImage/MxDbImage.js +2 -5
  2. package/dist/lib/MxModule/MxDbLine/MxDbLine.js +94 -0
  3. package/dist/lib/MxModule/MxDbLine/index.js +5 -0
  4. package/dist/lib/MxModule/MxDbRect/MxDbRect.js +219 -0
  5. package/dist/lib/MxModule/MxDbRect/index.js +4 -0
  6. package/dist/lib/MxModule/MxFilters/MxFilters.js +201 -0
  7. package/dist/lib/MxModule/MxFilters/index.js +4 -0
  8. package/dist/lib/MxModule/MxFun/MxFun.js +5 -2
  9. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +1 -1
  10. package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +2 -0
  11. package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +20 -14
  12. package/dist/lib/doc.js +9 -1
  13. package/dist/lib/mxdraw.js +13 -9
  14. package/dist/lib/tools/three/index.js +100 -3
  15. package/dist/mxdraw.es5.js +3 -3
  16. package/dist/mxdraw.es5.js.map +1 -1
  17. package/dist/mxdraw.umd.js +3 -3
  18. package/dist/mxdraw.umd.js.map +1 -1
  19. package/dist/types/MxModule/MxDbEntity/MxDbEntity.d.ts +1 -1
  20. package/dist/types/MxModule/MxDbLine/MxDbLine.d.ts +22 -0
  21. package/dist/types/MxModule/MxDbLine/index.d.ts +3 -0
  22. package/dist/types/MxModule/MxDbRect/MxDbRect.d.ts +74 -0
  23. package/dist/types/MxModule/MxDbRect/index.d.ts +2 -0
  24. package/dist/types/MxModule/MxFilters/MxFilters.d.ts +94 -0
  25. package/dist/types/MxModule/MxFilters/index.d.ts +2 -0
  26. package/dist/types/MxModule/MxFun/MxFun.d.ts +2 -1
  27. package/dist/types/doc.d.ts +5 -1
  28. package/dist/types/mxdraw.d.ts +9 -7
  29. package/dist/types/tools/three/index.d.ts +20 -1
  30. package/dist/types/types/MxFun.d.ts +1 -1
  31. package/package.json +1 -1
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
2
  ///////////////////////////////////////////////////////////////////////////////
3
3
  //版权所有(C)2002-2022,成都梦想凯德科技有限公司。
4
- //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司
5
- //应用包含本软件的程序必须包括以下声明
6
- //在版权声明中:
7
- //此应用程序与成都梦想凯德科技有限公司成协议。
8
- //通过使用本软件、其文档或相关材料
4
+ //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
5
+ //此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
9
6
  ///////////////////////////////////////////////////////////////////////////////
10
7
  /** @module MxDbImage*/
11
8
  var __extends = (this && this.__extends) || (function () {
@@ -0,0 +1,94 @@
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 MxDbLine*/
24
+ var THREE = require("three");
25
+ var MxDbEntity_1 = require("../MxDbEntity");
26
+ /**
27
+ * MxDbLine 直线对象.
28
+ */
29
+ var MxDbLine = /** @class */ (function (_super) {
30
+ __extends(MxDbLine, _super);
31
+ function MxDbLine() {
32
+ var _this = _super !== null && _super.apply(this, arguments) || this;
33
+ // pt1,pt2
34
+ _this.pt1 = new THREE.Vector3();
35
+ _this.pt2 = new THREE.Vector3();
36
+ return _this;
37
+ }
38
+ MxDbLine.prototype.getTypeName = function () {
39
+ return 'MxDbLine';
40
+ };
41
+ MxDbLine.prototype.worldDraw = function (pWorldDraw) {
42
+ pWorldDraw.drawLine(this.pt1, this.pt2);
43
+ };
44
+ MxDbLine.prototype.setPoint1 = function (pt1) {
45
+ this.pt1 = pt1;
46
+ };
47
+ MxDbLine.prototype.getPoint1 = function () {
48
+ return this.pt1;
49
+ };
50
+ MxDbLine.prototype.setPoint2 = function (pt2) {
51
+ this.pt2 = pt2;
52
+ };
53
+ MxDbLine.prototype.getPoint2 = function () {
54
+ return this.pt2;
55
+ };
56
+ MxDbLine.prototype.getGripPoints = function () {
57
+ var ret = [];
58
+ ret.push(this.pt1);
59
+ ret.push(this.pt2);
60
+ var midPoint = new THREE.Vector3(this.pt1.x + (this.pt2.x - this.pt1.x) * 0.5, this.pt1.y + (this.pt2.y - this.pt1.y) * 0.5, 0);
61
+ ret.push(midPoint);
62
+ return ret;
63
+ };
64
+ MxDbLine.prototype.moveGripPointsAt = function (index, offset) {
65
+ if (index == 0) {
66
+ this.pt1.add(offset);
67
+ }
68
+ else if (index == 1) {
69
+ this.pt2.add(offset);
70
+ }
71
+ else if (index == 2) {
72
+ this.pt1.add(offset);
73
+ this.pt2.add(offset);
74
+ }
75
+ return true;
76
+ };
77
+ MxDbLine.prototype.dwgIn = function (obj) {
78
+ this.onDwgIn(obj);
79
+ this.pt1.copy(obj['pt1']);
80
+ this.pt2.copy(obj['pt2']);
81
+ return true;
82
+ };
83
+ MxDbLine.prototype.dwgOut = function (obj) {
84
+ this.onDwgOut(obj);
85
+ obj['pt1'] = this.pt1;
86
+ obj['pt2'] = this.pt2;
87
+ return obj;
88
+ };
89
+ MxDbLine.prototype.create = function () {
90
+ return new MxDbLine();
91
+ };
92
+ return MxDbLine;
93
+ }(MxDbEntity_1.default));
94
+ exports.default = MxDbLine;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /** @module McEdGetPointWorldDrawObject*/
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ var MxDbLine_1 = require("./MxDbLine");
5
+ exports.default = MxDbLine_1.default;
@@ -0,0 +1,219 @@
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
+ var MxDbEntity_1 = require("../MxDbEntity");
30
+ var three_1 = require("three");
31
+ var index_1 = require("../../tools/three/index");
32
+ var MxFun_1 = require("../MxFun");
33
+ /**
34
+ * MxRectEntity 矩形对象.
35
+ */
36
+ var MxDbRect = /** @class */ (function (_super) {
37
+ __extends(MxDbRect, _super);
38
+ function MxDbRect() {
39
+ var _this = _super !== null && _super.apply(this, arguments) || this;
40
+ /**
41
+ * pt1: 构成矩形的第一个点
42
+ * */
43
+ _this.pt1 = new three_1.Vector3();
44
+ /**
45
+ * pt1: 构成矩形的第二个点(对角点)
46
+ * */
47
+ _this.pt2 = new three_1.Vector3();
48
+ /**
49
+ * width: 在绘制时自动计算矩形像素宽度 单位px
50
+ * */
51
+ _this.width = 0;
52
+ /**
53
+ * height: 在绘制时自动计算矩形像素高度 单位px
54
+ * */
55
+ _this.height = 0;
56
+ /**
57
+ * cornerRadius(优先级大于radius属性): 圆角的半径 如[3, 2, 1, 4]分别对应左上角圆角半径3 右上角2 右下角1 左下角4
58
+ * */
59
+ _this.cornerRadius = [];
60
+ /**
61
+ * transparent 开启透明度
62
+ * */
63
+ _this.transparent = true;
64
+ /**
65
+ * opacity 设置透明度 0 ~ 1
66
+ * */
67
+ _this.opacity = 1;
68
+ /**
69
+ * visible 该矩形对象是否可见
70
+ * */
71
+ _this.visible = true;
72
+ return _this;
73
+ }
74
+ MxDbRect.prototype.worldDraw = function (pWorldDraw) {
75
+ var _this = this;
76
+ // 根据第一个点和对角点 计算矩形的四个点位
77
+ 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
+ if (this.cornerRadius.length > 0) {
88
+ points = (0, index_1.getToGenerateRoundedCorners)(points, this.cornerRadius);
89
+ }
90
+ var geometry;
91
+ var material;
92
+ var line = new three_1.Object3D();
93
+ // 公共的material参数
94
+ var materialParam = {
95
+ transparent: this.transparent,
96
+ opacity: this.opacity,
97
+ visible: this.visible
98
+ };
99
+ // 如果是填充模式
100
+ if (this.fillColor || this.fillImageSrc) {
101
+ // 三维坐标转二位坐标
102
+ points = points.map(function (_a) {
103
+ var x = _a.x, y = _a.y;
104
+ return new three_1.Vector2(x, y);
105
+ });
106
+ // 计算矩形宽高
107
+ geometry = new three_1.ShapeGeometry(new three_1.Shape(points));
108
+ geometry.computeBoundingBox();
109
+ var size = new three_1.Vector3();
110
+ geometry.boundingBox.getSize(size);
111
+ this.width = MxFun_1.default.docCoord2Screen(size.x).x;
112
+ this.height = MxFun_1.default.docCoord2Screen(size.y).x;
113
+ // 如果是图片填充
114
+ if (this.fillImageSrc) {
115
+ var imgSrc = this.fillImageSrc;
116
+ MxFun_1.default.loadImageMaterial(imgSrc, function (mate) {
117
+ if (!mate)
118
+ return;
119
+ material = mate;
120
+ geometry = new three_1.ShapeGeometry(new three_1.Shape(points));
121
+ // 修复集合体的uv坐标
122
+ geometry = (0, index_1.repairGeometryFaceVertexUvs)(geometry);
123
+ // 纹理属性设置
124
+ var map = mate.map;
125
+ if (_this.fillImageParam) {
126
+ if (_this.fillImageParam.center)
127
+ map.center = _this.fillImageParam.center;
128
+ if (_this.fillImageParam.offset)
129
+ map.offset = _this.fillImageParam.offset;
130
+ if (_this.fillImageParam.repeat)
131
+ map.repeat = _this.fillImageParam.repeat;
132
+ if (_this.fillImageParam.rotation)
133
+ map.rotation = _this.fillImageParam.rotation;
134
+ }
135
+ // 有滤镜对象使用自定义着色器
136
+ if (_this.filter) {
137
+ var data = _this.filter._getFilterShaderData(map);
138
+ material = new three_1.ShaderMaterial(__assign(__assign({}, data), materialParam));
139
+ }
140
+ // 设置材质属性
141
+ material.depthTest = false;
142
+ material.transparent = _this.transparent;
143
+ material.opacity = _this.opacity;
144
+ material.visible = _this.visible;
145
+ line = new three_1.Mesh(geometry, material);
146
+ pWorldDraw.drawEntity(line);
147
+ });
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
+ }
157
+ }
158
+ else {
159
+ // 线框模式
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);
163
+ }
164
+ pWorldDraw.drawEntity(line);
165
+ };
166
+ MxDbRect.prototype.getGripPoints = function () {
167
+ var ret = [];
168
+ ret.push(this.pt1);
169
+ var lineMath = new three_1.Line3(this.pt1, this.pt2);
170
+ var corePt = new three_1.Vector3();
171
+ lineMath.getCenter(corePt);
172
+ ret.push(corePt);
173
+ ret.push(this.pt2);
174
+ return ret;
175
+ };
176
+ MxDbRect.prototype.moveGripPointsAt = function (index, offset) {
177
+ if (index == 0) {
178
+ this.pt1.add(offset);
179
+ }
180
+ else if (index == 1) {
181
+ this.pt1.add(offset);
182
+ this.pt2.add(offset);
183
+ }
184
+ else if (index == 2) {
185
+ this.pt2.add(offset);
186
+ }
187
+ return true;
188
+ };
189
+ MxDbRect.prototype.dwgIn = function (obj) {
190
+ this.onDwgIn(obj);
191
+ this.pt1.copy(obj['pt1']);
192
+ this.pt2.copy(obj['pt2']);
193
+ this.cornerRadius = obj['cornerRadius'];
194
+ this.radius = obj['radius'];
195
+ this.filter = obj['filter'];
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['cornerRadius'] = this.cornerRadius;
203
+ obj['radius'] = this.radius;
204
+ obj['filter'] = this.filter;
205
+ return obj;
206
+ };
207
+ MxDbRect.prototype.create = function () {
208
+ return new MxDbRect();
209
+ };
210
+ MxDbRect.prototype.transformBy = function (mat) {
211
+ this.pt1.applyMatrix4(mat);
212
+ this.pt2.applyMatrix4(mat);
213
+ };
214
+ MxDbRect.prototype.getTypeName = function () {
215
+ return 'MxRectEntity';
216
+ };
217
+ return MxDbRect;
218
+ }(MxDbEntity_1.default));
219
+ exports.default = MxDbRect;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var MxDbRect_1 = require("./MxDbRect");
4
+ exports.default = MxDbRect_1.default;
@@ -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;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var MxFilters_1 = require("./MxFilters");
4
+ exports.default = MxFilters_1.default;
@@ -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 ? '' : _c, callback = _a.callback, _d = _a.isNewFile, isNewFile = _d === void 0 ? true : _d;
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
  * 为程序设置服务器地址
@@ -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.setGeometryPostion)(geometry, pos);
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;
@@ -44,10 +44,12 @@ var mxcadassembly_es5_js_1 = require("./mxcadassembly_es5.js");
44
44
  var MxDbImage_1 = require("../MxDbImage");
45
45
  var MxDbSVG_1 = require("../MxDbSVG");
46
46
  var MxDbAlignedDimension_1 = require("../MxDbAlignedDimension");
47
+ var MxDbLine_1 = require("../MxDbLine");
47
48
  function rxInitMxEntity() {
48
49
  new MxDbImage_1.default().rxInit();
49
50
  new MxDbSVG_1.default().rxInit();
50
51
  new MxDbAlignedDimension_1.default().rxInit();
52
+ new MxDbLine_1.default().rxInit();
51
53
  }
52
54
  /**
53
55
  * 加载MxDraw库的核心代码 才能使用Mx的其他模块