mxdraw 0.1.21 → 0.1.25
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/McGePoint3d/McGePoint3d.js +1 -0
- package/dist/lib/MxModule/McGePoint3d/index.js +1 -0
- package/dist/lib/MxModule/McGePoint3dArray/McGePoint3dArray.js +1 -0
- package/dist/lib/MxModule/McGePoint3dArray/index.js +1 -0
- package/dist/lib/MxModule/McGeTool/McGeTool.js +1 -0
- package/dist/lib/MxModule/McGeTool/index.js +1 -0
- package/dist/lib/MxModule/McGiWorldDraw/McGiWorldDraw.js +1 -3
- 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 -159
- package/dist/lib/MxModule/MrxDbgUiPrPoint/index.js +1 -5
- package/dist/lib/MxModule/Mx3PointArc/Mx3PointArc.js +1 -0
- package/dist/lib/MxModule/Mx3PointArc/index.js +1 -0
- package/dist/lib/MxModule/MxDb2LineAngularDimension/MxDb2LineAngularDimension.js +1 -0
- package/dist/lib/MxModule/MxDb2LineAngularDimension/index.js +1 -0
- package/dist/lib/MxModule/MxDbAlignedDimension/MxDbAlignedDimension.js +1 -213
- package/dist/lib/MxModule/MxDbAlignedDimension/index.js +1 -5
- package/dist/lib/MxModule/MxDbAnyLine/MxDbAnyLine.js +1 -0
- package/dist/lib/MxModule/MxDbAnyLine/index.js +1 -0
- package/dist/lib/MxModule/MxDbArea/MxDbArea.js +1 -0
- package/dist/lib/MxModule/MxDbArea/index.js +1 -0
- package/dist/lib/MxModule/MxDbCoord/MxDbCoord.js +1 -0
- package/dist/lib/MxModule/MxDbCoord/index.js +1 -0
- package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +1 -258
- 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/MxDbPolyline/MxDbPolyline.js +1 -97
- package/dist/lib/MxModule/MxDbPolyline/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 -419
- 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 -782
- 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 -676
- package/dist/lib/MxModule/MxFun/index.js +1 -4
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js +1 -283
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +1 -146
- 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 -20
- 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 -312
- package/dist/lib/MxModule/loadCoreCode/mxcadassembly_es5.js +1 -1519
- package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +1 -7363
- 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 -19
- 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 -67
- 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 -243
- 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/mxdraw.es5.js +1 -0
- package/dist/mxdraw.umd.js +1 -0
- package/dist/types/MxModule/McEdGetPointWorldDrawObject/McEdGetPointWorldDrawObjectClass.d.ts +9 -0
- package/dist/types/MxModule/McGePoint3d/McGePoint3d.d.ts +11 -0
- package/dist/types/MxModule/McGePoint3d/index.d.ts +3 -0
- package/dist/types/MxModule/McGePoint3dArray/McGePoint3dArray.d.ts +14 -0
- package/dist/types/MxModule/McGePoint3dArray/index.d.ts +3 -0
- package/dist/types/MxModule/McGeTool/McGeTool.d.ts +38 -0
- package/dist/types/MxModule/McGeTool/index.d.ts +4 -0
- package/dist/types/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.d.ts +18 -1
- package/dist/types/MxModule/Mx3PointArc/Mx3PointArc.d.ts +19 -0
- package/dist/types/MxModule/Mx3PointArc/index.d.ts +3 -0
- package/dist/types/MxModule/MxDb2LineAngularDimension/MxDb2LineAngularDimension.d.ts +22 -0
- package/dist/types/MxModule/MxDb2LineAngularDimension/index.d.ts +3 -0
- package/dist/types/MxModule/MxDbAnyLine/MxDbAnyLine.d.ts +18 -0
- package/dist/types/MxModule/MxDbAnyLine/index.d.ts +3 -0
- package/dist/types/MxModule/MxDbArea/MxDbArea.d.ts +17 -0
- package/dist/types/MxModule/MxDbArea/index.d.ts +3 -0
- package/dist/types/MxModule/MxDbCoord/MxDbCoord.d.ts +19 -0
- package/dist/types/MxModule/MxDbCoord/index.d.ts +3 -0
- package/dist/types/MxModule/MxDrawObject/MxDrawObject.d.ts +70 -1
- package/dist/types/MxModule/MxFun/MxFun.d.ts +95 -30
- package/dist/types/MxModule/Mxassembly/Mxassembly.d.ts +11 -2
- package/dist/types/MxModule/store/store.d.ts +2 -2
- package/dist/types/mxdraw.d.ts +17 -4
- package/dist/types/tools/three/index.d.ts +28 -1
- package/package.json +3 -2
- package/dist/lib/MxModule/McGeVector3d/McGeVector3d.js +0 -2
- package/dist/lib/MxModule/McGeVector3d/index.js +0 -3
- package/dist/lib/MxModule/MxThreeJS/SVGLoader.js +0 -1862
- package/dist/lib/types/McEdGetPointWorldDrawObject.js +0 -2
- package/dist/lib/types/MrxDbgUiPrPoint.js +0 -2
- package/dist/lib/types/MxCADObject.js +0 -2
- package/dist/lib/types/MxDrawObject.js +0 -2
- package/dist/lib/types/MxFun.js +0 -2
- package/dist/lib/types/Mxassembly.js +0 -2
- package/dist/types/MxModule/McGeVector3d/McGeVector3d.d.ts +0 -17
- package/dist/types/MxModule/McGeVector3d/index.d.ts +0 -3
- package/dist/types/MxModule/MxThreeJS/SVGLoader.d.ts +0 -22
- package/dist/types/types/McEdGetPointWorldDrawObject.d.ts +0 -9
- package/dist/types/types/MrxDbgUiPrPoint.d.ts +0 -23
- package/dist/types/types/MxCADObject.d.ts +0 -40
- package/dist/types/types/MxDrawObject.d.ts +0 -60
- package/dist/types/types/MxFun.d.ts +0 -47
- package/dist/types/types/Mxassembly.d.ts +0 -3
|
@@ -1,283 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
3
|
-
//版权所有(C)2002-2022,成都梦想凯德科技有限公司。
|
|
4
|
-
//本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
|
|
5
|
-
//此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
|
|
6
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
var three_1 = require("three");
|
|
9
|
-
var math_1 = require("../../tools/algorithm/math");
|
|
10
|
-
var formatting_1 = require("../../tools/formatting");
|
|
11
|
-
/**
|
|
12
|
-
* MxThreeJS 模块
|
|
13
|
-
* ##### 使用说明:
|
|
14
|
-
*
|
|
15
|
-
* > 基于three.js实现创建直线对象、加载图片、SVG等功能,以下是使用的流程:
|
|
16
|
-
* - 模块中大部分方法返回的{@link http://www.yanhuangxueyuan.com/threejs/docs/index.html#api/zh/core/Object3D | THREE.Object3D}类型继承创建的对象都可以通过取点对象{@link MrxDbgUiPrPointClass.value} 得到鼠标对应位置
|
|
17
|
-
* - {@link MrxDbgUiPrPointClass.go}和{@link MrxDbgUiPrPointClass.goWhile}方法监听鼠标点击事件回调中通过
|
|
18
|
-
* - {@link MxDrawObject.addObject} 方法添加到场景{@link MxDrawObject.getScene}中
|
|
19
|
-
* - 最后调用{@link MxFun.updateDisplay} 更新视图显示完成
|
|
20
|
-
*
|
|
21
|
-
* > 提示: 在实际开发中MxThreeJS是配合着{@link MxDrawObject} 和 {@link MrxDbgUiPrPointClass} 完成绘制线段、文字、图片等功能,当然你也可以使用{@link http://www.yanhuangxueyuan.com/threejs/docs/index.html | three.js}来完成MxThreeJS模块的这些工作
|
|
22
|
-
*
|
|
23
|
-
* > 该模块导出库时已实例化为对象,只需要调用实例方法 例如:
|
|
24
|
-
*
|
|
25
|
-
* ```typescript
|
|
26
|
-
* // html
|
|
27
|
-
* <button id="line">line</button>
|
|
28
|
-
*
|
|
29
|
-
* // js
|
|
30
|
-
* import Mx from "mxdraw"
|
|
31
|
-
* import Three from "three"
|
|
32
|
-
* Mx.loadCoreCode().then(()=> {
|
|
33
|
-
* Mx.MxFun.setMxServer()
|
|
34
|
-
* Mx.MxFun.createMxObject({
|
|
35
|
-
* callback(mxDraw, dom) {
|
|
36
|
-
* document.getElementById("line").onclick = ()=> {
|
|
37
|
-
* const getPoint = new Mx.MrxDbgUiPrPointClass()
|
|
38
|
-
* let lastPt, isLine
|
|
39
|
-
* getPoint.goWhile(()=> {
|
|
40
|
-
* const pt1 = getPoint.value()
|
|
41
|
-
* if(isLine) {
|
|
42
|
-
* const line = Mx.MxThreeJS.createLine(pt1, lastPt, 0xffffff)
|
|
43
|
-
* const currentDraw = Mx.MxFun.getCurrentDraw()
|
|
44
|
-
* currentDraw.addObject(line)
|
|
45
|
-
* Mx.MxFun.updateDisplay()
|
|
46
|
-
* }
|
|
47
|
-
* lastPt = pt1.clone()
|
|
48
|
-
* isLine = !isLine
|
|
49
|
-
* })
|
|
50
|
-
* }
|
|
51
|
-
* }
|
|
52
|
-
* })
|
|
53
|
-
* })
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
var MxThreeJS = /** @class */ (function () {
|
|
57
|
-
function MxThreeJS() {
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* 创建Three.js直线对象。
|
|
61
|
-
* @param vPt1 {@link http://www.yanhuangxueyuan.com/threejs/docs/index.html#api/zh/math/Vector3 | THREE.Vector3} 点1
|
|
62
|
-
* @param vPt2 {@link http://www.yanhuangxueyuan.com/threejs/docs/index.html#api/zh/math/Vector3 | THREE.Vector3} 点2
|
|
63
|
-
* @param iColor 颜色Color
|
|
64
|
-
* @returns {@link http://www.yanhuangxueyuan.com/threejs/docs/index.html#api/zh/objects/Line |THREE.Line}
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* Mx.MxThreeJS.createLine(new Three.Vector3(1,10,0), new Three.Vector3(1,300,0), 0)
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
MxThreeJS.prototype.createLine = function (vPt1, vPt2, iColor) {
|
|
71
|
-
var lineGeometry = new three_1.Geometry();
|
|
72
|
-
var lineMaterial = new three_1.LineBasicMaterial({ color: iColor });
|
|
73
|
-
lineGeometry.vertices.push(vPt1, vPt2);
|
|
74
|
-
return new three_1.Line(lineGeometry, lineMaterial);
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* 创建Three.js圆对象。
|
|
78
|
-
* @param mCenterPt 圆中心点
|
|
79
|
-
* @param dRadius 圆半径
|
|
80
|
-
* @param iColor 颜色
|
|
81
|
-
* @returns THREE.Object3D
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* Mx.MxThreeJS.createCircle(new Three.Vector3(1,10,0), 10, 0)
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
MxThreeJS.prototype.createCircle = function (mCenterPt, dRadius, iColor) {
|
|
88
|
-
var geometry = new three_1.CircleGeometry(dRadius, 64, 3, 2 * Math.PI);
|
|
89
|
-
var material = new three_1.LineBasicMaterial({ color: iColor });
|
|
90
|
-
geometry.vertices.shift();
|
|
91
|
-
var mEnt = new three_1.LineLoop(geometry, material);
|
|
92
|
-
mEnt.position.x = mCenterPt.x;
|
|
93
|
-
mEnt.position.y = mCenterPt.y;
|
|
94
|
-
mEnt.position.z = mCenterPt.z;
|
|
95
|
-
return mEnt;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* 创建Three.js点对象。
|
|
99
|
-
* @param mPt 点位置
|
|
100
|
-
* @param iColor 颜色
|
|
101
|
-
* @returns THREE.Points
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* Mx.MxThreeJS.createPoint(new Three.Vector3(1,10,0), 0)
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
MxThreeJS.prototype.createPoint = function (mPt, iColor) {
|
|
108
|
-
var pointsGeometry = new three_1.Geometry();
|
|
109
|
-
pointsGeometry.vertices.push(mPt);
|
|
110
|
-
var pointsMaterial = new three_1.PointsMaterial({ color: iColor, size: 3 });
|
|
111
|
-
var points = new three_1.Points(pointsGeometry, pointsMaterial);
|
|
112
|
-
return points;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* 创建Three.js 文字
|
|
116
|
-
* @param message 文字信息
|
|
117
|
-
* @param pt 位置
|
|
118
|
-
* @param iSize 文字大小
|
|
119
|
-
* @param fAngle 旋转角度
|
|
120
|
-
* @param iColor 颜色
|
|
121
|
-
* @returns THREE.Sprite
|
|
122
|
-
* @example
|
|
123
|
-
* ```typescript
|
|
124
|
-
* Mx.MxThreeJS.creatTextSprite("hello",new Three.Vector3(1,10,0), 90, 60, 0)
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
MxThreeJS.prototype.creatTextSprite = function (message, pt, iSize, fAngle, iColor) {
|
|
128
|
-
var textHeight = 256;
|
|
129
|
-
var canvas = document.createElement('canvas');
|
|
130
|
-
var context = canvas.getContext('2d');
|
|
131
|
-
var textWidth = 0;
|
|
132
|
-
var sFont = (0, formatting_1.formatString)('normal {0}px Arial', '' + textHeight);
|
|
133
|
-
/* istanbul ignore next */
|
|
134
|
-
if (context == null) {
|
|
135
|
-
/* istanbul ignore next */
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
context.font = sFont;
|
|
139
|
-
var metrics = context.measureText(message);
|
|
140
|
-
// 保证纹理的尺寸是2次方。
|
|
141
|
-
textWidth = (0, math_1.floorPowerOfTwo)(metrics.width) * 2;
|
|
142
|
-
canvas.width = textWidth;
|
|
143
|
-
canvas.height = textHeight;
|
|
144
|
-
context.font = sFont;
|
|
145
|
-
context.textAlign = 'center';
|
|
146
|
-
context.textBaseline = 'middle';
|
|
147
|
-
context.fillStyle = (0, formatting_1.formatString)('rgba({0}, {1}, {2}, 1.0)', ((iColor >> 16) & 0xff) + '', ((iColor >> 8) & 0xff) + '', (iColor & 0xff) + '');
|
|
148
|
-
//const sColor = formatString('#{0}', iColor.toString(16))
|
|
149
|
-
context.fillText(message, textWidth / 2, textHeight / 2);
|
|
150
|
-
var texture = new three_1.Texture(canvas);
|
|
151
|
-
texture.needsUpdate = true;
|
|
152
|
-
var material = new three_1.SpriteMaterial({
|
|
153
|
-
transparent: true,
|
|
154
|
-
depthTest: false,
|
|
155
|
-
map: texture
|
|
156
|
-
});
|
|
157
|
-
//material.transparent = false;
|
|
158
|
-
material.rotation = fAngle;
|
|
159
|
-
var sprite = new three_1.Sprite(material);
|
|
160
|
-
sprite.scale.set((textWidth / textHeight) * iSize, iSize, 1);
|
|
161
|
-
sprite.position.set(pt.x, pt.y, pt.z);
|
|
162
|
-
return sprite;
|
|
163
|
-
};
|
|
164
|
-
/**
|
|
165
|
-
* 根据三角形数组,创建Three.js Mesh
|
|
166
|
-
* @param points 由三个点组成的数组
|
|
167
|
-
* @param iColor 颜色
|
|
168
|
-
* @param opacity 透明度
|
|
169
|
-
* @returns THREE.Mesh
|
|
170
|
-
* @example
|
|
171
|
-
* ```typescript
|
|
172
|
-
* Mx.MxThreeJS.createTriangle(
|
|
173
|
-
* [new THREE.Vector3(1,2,2),new THREE.Vector3(1,65,4),new THREE.Vector3(12,2,2)],
|
|
174
|
-
* 0,
|
|
175
|
-
* 1
|
|
176
|
-
* )
|
|
177
|
-
* ```
|
|
178
|
-
*/
|
|
179
|
-
MxThreeJS.prototype.createTriangle = function (points, iColor, opacity) {
|
|
180
|
-
if (opacity === void 0) { opacity = 1.0; }
|
|
181
|
-
if (points.length < 3) {
|
|
182
|
-
return null;
|
|
183
|
-
}
|
|
184
|
-
var iLen = points.length;
|
|
185
|
-
var geometry = new three_1.Geometry();
|
|
186
|
-
for (var i = 0; i + 2 < iLen; i += 3) {
|
|
187
|
-
geometry.vertices.push(points[i]);
|
|
188
|
-
geometry.vertices.push(points[i + 1]);
|
|
189
|
-
geometry.vertices.push(points[i + 2]);
|
|
190
|
-
var face = new three_1.Face3(i, i + 1, i + 2);
|
|
191
|
-
geometry.faces.push(face);
|
|
192
|
-
}
|
|
193
|
-
geometry.computeFaceNormals();
|
|
194
|
-
geometry.computeVertexNormals();
|
|
195
|
-
// 如果需要renderOrder管用,必须在Material属性中,加入transparent: true,depthTest:false这两个值才行。
|
|
196
|
-
var material = new three_1.MeshBasicMaterial({
|
|
197
|
-
color: iColor,
|
|
198
|
-
transparent: true,
|
|
199
|
-
depthTest: false,
|
|
200
|
-
side: three_1.DoubleSide,
|
|
201
|
-
opacity: opacity
|
|
202
|
-
});
|
|
203
|
-
var mTriangle = new three_1.Mesh(geometry, material);
|
|
204
|
-
return mTriangle;
|
|
205
|
-
};
|
|
206
|
-
/**
|
|
207
|
-
* 创建连续直线
|
|
208
|
-
* @param points 由多个点组成的数组
|
|
209
|
-
* @param iColor 颜色
|
|
210
|
-
* @returns THREE.Line
|
|
211
|
-
* @example
|
|
212
|
-
* ```typescript
|
|
213
|
-
* Mx.MxThreeJS.createLines([new THREE.Vector3(1,2,2),new THREE.Vector3(1,65,4),new THREE.Vector3(12,2,2)], 0)
|
|
214
|
-
* ```
|
|
215
|
-
*/
|
|
216
|
-
MxThreeJS.prototype.createLines = function (points, iColor) {
|
|
217
|
-
var lineGeometry = new three_1.Geometry();
|
|
218
|
-
lineGeometry.vertices = points;
|
|
219
|
-
//var lineMaterial = new LineBasicMaterial({ color: iColor,linewidth: 500 });
|
|
220
|
-
var lineMaterial = new three_1.LineBasicMaterial({ color: iColor });
|
|
221
|
-
var line = new three_1.Line(lineGeometry, lineMaterial);
|
|
222
|
-
return line;
|
|
223
|
-
};
|
|
224
|
-
/**
|
|
225
|
-
* 创建虚线
|
|
226
|
-
* @param points 由多个点组成的数组
|
|
227
|
-
* @param iColor 颜色
|
|
228
|
-
* @param dashSize 短划线的大小
|
|
229
|
-
* @param gapSize 短划线之间的距离
|
|
230
|
-
* @returns THREE.Line
|
|
231
|
-
* @example
|
|
232
|
-
* ```typescript
|
|
233
|
-
* Mx.MxThreeJS.createDashedLines([new THREE.Vector3(1,2,2),new THREE.Vector3(1,65,4),new THREE.Vector3(12,2,2)], 10, 20, 2)
|
|
234
|
-
* ```
|
|
235
|
-
*/
|
|
236
|
-
MxThreeJS.prototype.createDashedLines = function (points, iColor, dashSize, gapSize) {
|
|
237
|
-
var lineGeometry = new three_1.Geometry();
|
|
238
|
-
lineGeometry.vertices = points;
|
|
239
|
-
var line = new three_1.Line(lineGeometry, new three_1.LineDashedMaterial({
|
|
240
|
-
color: iColor,
|
|
241
|
-
dashSize: dashSize,
|
|
242
|
-
gapSize: gapSize //短划线之间的距离
|
|
243
|
-
}));
|
|
244
|
-
line.computeLineDistances();
|
|
245
|
-
return line;
|
|
246
|
-
};
|
|
247
|
-
/**
|
|
248
|
-
* 创建Image
|
|
249
|
-
* @param pos 图片中心点位置,屏幕坐标,屏幕坐标的Y轴向上。坐标原点在左下角.
|
|
250
|
-
* @param w 图片宽度
|
|
251
|
-
* @param h 图片高度
|
|
252
|
-
* @param imageUrlPath 图片URl地址
|
|
253
|
-
* @param callResult 图片加载完成的回调 回调参数:THREE.Mesh
|
|
254
|
-
* @returns void
|
|
255
|
-
* @example
|
|
256
|
-
* ```typescript
|
|
257
|
-
* Mx.MxThreeJS.createImage(new THREE.Vector3(12,2,2), 10, 20, "../img/icon.png", (mesh)=> {
|
|
258
|
-
* console.log(mesh)
|
|
259
|
-
* })
|
|
260
|
-
* ```
|
|
261
|
-
*/
|
|
262
|
-
MxThreeJS.prototype.createImage = function (pos, w, h, imageUrlPath, callResult) { };
|
|
263
|
-
/**
|
|
264
|
-
* 加载SVG
|
|
265
|
-
* @param url SVG路径地址,该函数具有缓存功能,下次加载同样的图片,可以直接返回.
|
|
266
|
-
* @param color 颜色
|
|
267
|
-
* @param callResult SVG加载完成的回调 回调参数:THREE.Object3D和Array<THREE.MeshBasicMaterial>
|
|
268
|
-
* @returns void
|
|
269
|
-
* @example
|
|
270
|
-
* ```typescript
|
|
271
|
-
* Mx.MxThreeJS.loadSVG("../img/icon.svg", 10, 20, 1.5, new THREE.Color(0xff0000), (threeobj, aryMeterial)=> {
|
|
272
|
-
* console.log(threeobj, aryMeterial)
|
|
273
|
-
* })
|
|
274
|
-
* ```
|
|
275
|
-
*/
|
|
276
|
-
MxThreeJS.prototype.loadSVG = function (url, color, callResult) {
|
|
277
|
-
return new Promise(function (resolve) {
|
|
278
|
-
resolve(null);
|
|
279
|
-
});
|
|
280
|
-
};
|
|
281
|
-
return MxThreeJS;
|
|
282
|
-
}());
|
|
283
|
-
exports.default = MxThreeJS;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var three_1=require("three"),store_1=require("../store"),MxThreeJS=function(){function e(){}return e.prototype.createLine=function(e,t,r){var n=new three_1.Geometry,o=new three_1.LineBasicMaterial({color:r});return n.vertices.push(e,t),new three_1.Line(n,o)},e.prototype.createCircle=function(e,t,r){var n=new three_1.CircleGeometry(t,64,3,2*Math.PI),o=new three_1.LineBasicMaterial({color:r});n.vertices.shift();var i=new three_1.LineLoop(n,o);return i.position.x=e.x,i.position.y=e.y,i.position.z=e.z,i},e.prototype.createPoint=function(e,t){var r=new three_1.Geometry;r.vertices.push(e);var n=new three_1.PointsMaterial({color:t,size:3});return new three_1.Points(r,n)},e.prototype.creatTextSprite=function(e,t,r,n,o){return store_1.default.state.MxFun.getMxThreeJS().creatTextSprite(e,t,r,n,o)},e.prototype.createTriangle=function(e,t,r){if(void 0===r&&(r=1),e.length<3)return null;for(var n=e.length,o=new three_1.Geometry,i=0;i+2<n;i+=3){o.vertices.push(e[i]),o.vertices.push(e[i+1]),o.vertices.push(e[i+2]);var a=new three_1.Face3(i,i+1,i+2);o.faces.push(a)}o.computeFaceNormals(),o.computeVertexNormals();var s=new three_1.MeshBasicMaterial({color:t,transparent:!0,depthTest:!1,side:three_1.DoubleSide,opacity:r});return new three_1.Mesh(o,s)},e.prototype.createLines=function(e,t){var r=new three_1.Geometry;r.vertices=e;var n=new three_1.LineBasicMaterial({color:t});return new three_1.Line(r,n)},e.prototype.createDashedLines=function(e,t,r,n){var o=new three_1.Geometry;o.vertices=e;var i=new three_1.Line(o,new three_1.LineDashedMaterial({color:t,dashSize:r,gapSize:n}));return i.computeLineDistances(),i},e.prototype.createImage=function(e,t,r,n,o){},e.prototype.loadSVG=function(e,t,r){return r?(store_1.default.state.MxFun.loadSVG(e,t,r),new Promise(function(e){e(null)})):new Promise(function(r){store_1.default.state.MxFun.loadSVG(e,t,function(e){r(e)})})},e}();exports.default=MxThreeJS;
|
|
@@ -1,146 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var three_1 = require("three");
|
|
4
|
-
// import { SVGLoader } from 'three/examples/jsm/loaders/SVGLoader'
|
|
5
|
-
var SVGLoader_1 = require("./SVGLoader");
|
|
6
|
-
var three_2 = require("../../tools/three");
|
|
7
|
-
var MxThreeJSSVGData = /** @class */ (function () {
|
|
8
|
-
function MxThreeJSSVGData() {
|
|
9
|
-
this.svg = new three_1.Group();
|
|
10
|
-
this.aryMeterial = [];
|
|
11
|
-
}
|
|
12
|
-
return MxThreeJSSVGData;
|
|
13
|
-
}());
|
|
14
|
-
var MxThreeJSBuffer = /** @class */ (function () {
|
|
15
|
-
function MxThreeJSBuffer() {
|
|
16
|
-
this.mapSvgUrlToData = new Map();
|
|
17
|
-
}
|
|
18
|
-
MxThreeJSBuffer.prototype.loadSVGImp = function (url, color, callResult) {
|
|
19
|
-
var loader = new SVGLoader_1.SVGLoader();
|
|
20
|
-
loader.load(url, function (data) {
|
|
21
|
-
var aryMeterial = [];
|
|
22
|
-
var paths = data.paths;
|
|
23
|
-
var group = new three_1.Group();
|
|
24
|
-
var drawStrokes = false;
|
|
25
|
-
var drawFillShapes = true;
|
|
26
|
-
var fillShapesWireframe = false;
|
|
27
|
-
var strokesWireframe = false;
|
|
28
|
-
for (var i = 0; i < paths.length; i++) {
|
|
29
|
-
var path = paths[i];
|
|
30
|
-
var fillColor = path.userData.style.fill;
|
|
31
|
-
if (drawFillShapes && fillColor !== undefined && fillColor !== 'none') {
|
|
32
|
-
var material = new three_1.MeshBasicMaterial({
|
|
33
|
-
color: color ? color : new three_1.Color().setStyle(fillColor),
|
|
34
|
-
opacity: path.userData.style.fillOpacity,
|
|
35
|
-
transparent: path.userData.style.fillOpacity < 1,
|
|
36
|
-
side: three_1.DoubleSide,
|
|
37
|
-
depthWrite: false,
|
|
38
|
-
wireframe: fillShapesWireframe
|
|
39
|
-
});
|
|
40
|
-
// const shapes = path.toShapes( true );
|
|
41
|
-
var shapes = SVGLoader_1.SVGLoader.createShapes(path);
|
|
42
|
-
for (var j = 0; j < shapes.length; j++) {
|
|
43
|
-
var shape = shapes[j];
|
|
44
|
-
var geometry = new three_1.ShapeBufferGeometry(shape);
|
|
45
|
-
var mesh = new three_1.Mesh(geometry, material);
|
|
46
|
-
group.add(mesh);
|
|
47
|
-
}
|
|
48
|
-
aryMeterial.push(material);
|
|
49
|
-
}
|
|
50
|
-
var strokeColor = path.userData.style.stroke;
|
|
51
|
-
if (drawStrokes && strokeColor !== undefined && strokeColor !== 'none') {
|
|
52
|
-
var material = new three_1.MeshBasicMaterial({
|
|
53
|
-
color: color ? color : new three_1.Color().setStyle(strokeColor),
|
|
54
|
-
opacity: path.userData.style.strokeOpacity,
|
|
55
|
-
transparent: path.userData.style.strokeOpacity < 1,
|
|
56
|
-
side: three_1.DoubleSide,
|
|
57
|
-
depthWrite: false,
|
|
58
|
-
wireframe: strokesWireframe
|
|
59
|
-
});
|
|
60
|
-
for (var j = 0, jl = path.subPaths.length; j < jl; j++) {
|
|
61
|
-
var subPath = path.subPaths[j];
|
|
62
|
-
var geometry = SVGLoader_1.SVGLoader.pointsToStroke(subPath.getPoints(), path.userData.style, 12, 0.001);
|
|
63
|
-
if (geometry) {
|
|
64
|
-
var mesh = new three_1.Mesh(geometry, material);
|
|
65
|
-
group.add(mesh);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
aryMeterial.push(material);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
callResult && callResult(group, aryMeterial);
|
|
72
|
-
}, undefined, function () {
|
|
73
|
-
callResult && callResult(null, null);
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
MxThreeJSBuffer.prototype.loadSVG = function (url, color, callResult) {
|
|
77
|
-
var _this = this;
|
|
78
|
-
var data = this.mapSvgUrlToData.get(url);
|
|
79
|
-
if (data) {
|
|
80
|
-
if (callResult) {
|
|
81
|
-
if (data == null)
|
|
82
|
-
callResult(null, null);
|
|
83
|
-
else
|
|
84
|
-
callResult(data.svg.clone(), data.aryMeterial);
|
|
85
|
-
}
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
this.loadSVGImp(url, color, function (group, aryMeterial) {
|
|
90
|
-
if (group && aryMeterial) {
|
|
91
|
-
var data_1 = new MxThreeJSSVGData();
|
|
92
|
-
data_1.svg = group;
|
|
93
|
-
data_1.aryMeterial = aryMeterial;
|
|
94
|
-
_this.mapSvgUrlToData.set(url, data_1);
|
|
95
|
-
callResult && callResult(data_1.svg.clone(), data_1.aryMeterial);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
_this.mapSvgUrlToData.set(url, null);
|
|
99
|
-
callResult && callResult(null, null);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
return MxThreeJSBuffer;
|
|
105
|
-
}());
|
|
106
|
-
function default_1(MxThreeJS) {
|
|
107
|
-
var mxThreeJsBuffer = new MxThreeJSBuffer();
|
|
108
|
-
MxThreeJS.createImage = function (pos, w, h, imageUrlPath, callResult) {
|
|
109
|
-
new three_1.TextureLoader().load(imageUrlPath, function (texture) {
|
|
110
|
-
var geometry = new three_1.PlaneGeometry(w, h);
|
|
111
|
-
// 测试 transparent: true,打开,renderOrder才管用。
|
|
112
|
-
var materialTexture = new three_1.MeshLambertMaterial({
|
|
113
|
-
map: texture,
|
|
114
|
-
transparent: true,
|
|
115
|
-
side: three_1.DoubleSide
|
|
116
|
-
});
|
|
117
|
-
if (materialTexture.map)
|
|
118
|
-
materialTexture.map.needsUpdate = true;
|
|
119
|
-
(0, three_2.setGeometrPostion)(geometry, pos);
|
|
120
|
-
//var mesh = new Mesh(geometry, material);
|
|
121
|
-
var mesh = new three_1.Mesh(geometry, materialTexture);
|
|
122
|
-
mesh.material['depthTest'] = false;
|
|
123
|
-
//mesh.renderOrder = renderOrder;
|
|
124
|
-
callResult && callResult(mesh);
|
|
125
|
-
}, undefined, function (err) {
|
|
126
|
-
console.log(err);
|
|
127
|
-
callResult && callResult(null);
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
MxThreeJS.loadSVG = function (url, color, callResult) {
|
|
131
|
-
if (callResult) {
|
|
132
|
-
mxThreeJsBuffer.loadSVG(url, color, callResult);
|
|
133
|
-
return new Promise(function (resolve) {
|
|
134
|
-
resolve(null);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
return new Promise(function (resolve) {
|
|
139
|
-
mxThreeJsBuffer.loadSVG(url, color, function (threeobj) {
|
|
140
|
-
resolve(threeobj);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
exports.default = default_1;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var three_1=require("three"),three_2=require("../../tools/three");function default_1(e){e.createImage=function(e,t,r,a,o){(new three_1.TextureLoader).load(a,function(a){var n=new three_1.PlaneGeometry(t,r),l=new three_1.MeshLambertMaterial({map:a,transparent:!0,side:three_1.DoubleSide});l.map&&(l.map.needsUpdate=!0),(0,three_2.setGeometrPostion)(n,e);var s=new three_1.Mesh(n,l);s.material.depthTest=!1,o&&o(s)},void 0,function(e){console.log(e),o&&o(null)})}}exports.default=default_1;
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var MxThreeJS_mixin_1 = require("./MxThreeJS.mixin");
|
|
4
|
-
var MxThreeJS_1 = require("./MxThreeJS");
|
|
5
|
-
var MxThreeJS = new MxThreeJS_1.default();
|
|
6
|
-
(0, MxThreeJS_mixin_1.default)(MxThreeJS);
|
|
7
|
-
exports.default = MxThreeJS;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var MxThreeJS_mixin_1=require("./MxThreeJS.mixin"),MxThreeJS_1=require("./MxThreeJS"),MxThreeJS=new MxThreeJS_1.default;(0,MxThreeJS_mixin_1.default)(MxThreeJS),exports.default=MxThreeJS;
|
|
@@ -1,27 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @module MxType*/
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
/**
|
|
5
|
-
* 动态绘制类型
|
|
6
|
-
* @example ```typescript
|
|
7
|
-
|
|
8
|
-
* ```
|
|
9
|
-
*/
|
|
10
|
-
var MxCloneType;
|
|
11
|
-
(function (MxCloneType) {
|
|
12
|
-
/** 正常Clone */
|
|
13
|
-
MxCloneType[MxCloneType["kClone"] = 1] = "kClone";
|
|
14
|
-
/** 动态拖动Clone */
|
|
15
|
-
MxCloneType[MxCloneType["kDragClone"] = 2] = "kDragClone";
|
|
16
|
-
})(MxCloneType || (MxCloneType = {}));
|
|
17
|
-
var MxCloneType2;
|
|
18
|
-
(function (MxCloneType2) {
|
|
19
|
-
/** 正常Clone */
|
|
20
|
-
MxCloneType2[MxCloneType2["kClone"] = 1] = "kClone";
|
|
21
|
-
/** 动态拖动Clone */
|
|
22
|
-
MxCloneType2[MxCloneType2["kDragClone"] = 2] = "kDragClone";
|
|
23
|
-
})(MxCloneType2 || (MxCloneType2 = {}));
|
|
24
|
-
exports.default = {
|
|
25
|
-
MxCloneType: MxCloneType,
|
|
26
|
-
MxCloneType2: MxCloneType2
|
|
27
|
-
};
|
|
1
|
+
"use strict";var MxCloneType,MxCloneType2;Object.defineProperty(exports,"__esModule",{value:!0}),function(e){e[e.kClone=1]="kClone",e[e.kDragClone=2]="kDragClone"}(MxCloneType||(MxCloneType={})),function(e){e[e.kClone=1]="kClone",e[e.kDragClone=2]="kDragClone"}(MxCloneType2||(MxCloneType2={})),exports.default={MxCloneType:MxCloneType,MxCloneType2:MxCloneType2};
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var MxType_1 = require("./MxType");
|
|
4
|
-
exports.default = MxType_1.default;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var MxType_1=require("./MxType");exports.default=MxType_1.default;
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/** @module Mxassembly */
|
|
4
|
-
var store_1 = require("../store/store");
|
|
5
|
-
/**
|
|
6
|
-
* Mxassembly 模块
|
|
7
|
-
* 导出库时已实例化,只需要调用实例方法 例如:
|
|
8
|
-
* ```typescript
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
var Mxassembly = /** @class */ (function () {
|
|
12
|
-
function Mxassembly() {
|
|
13
|
-
}
|
|
14
|
-
Mxassembly.prototype.NewMcGeVector3d = function () {
|
|
15
|
-
var _a;
|
|
16
|
-
return (_a = new store_1.default.state.Mxassembly) === null || _a === void 0 ? void 0 : _a.McGeVector3d();
|
|
17
|
-
};
|
|
18
|
-
return Mxassembly;
|
|
19
|
-
}());
|
|
20
|
-
exports.default = Mxassembly;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var store_1=require("../store/store"),Mxassembly=function(){function t(){this.mxassembly=null}return t.prototype.initImp=function(){this.mxassembly||store_1.default.state.Mxassembly&&(this.mxassembly=store_1.default.state.Mxassembly)},t.prototype.NewMcGePoint3d=function(t,e,s){this.initImp();var r=new this.mxassembly.McGePoint3d;return t&&(r.x=t),e&&(r.y=e),s&&(r.z=s),r},t.prototype.NewMcGePoint3dArray=function(t){var e=this;this.initImp();var s=new this.mxassembly.McGePoint3dArray;return t&&t.forEach(function(t){var r=e.NewMcGePoint3d();r.x=t.x,r.y=t.y,r.z=t.z,s.append(r)}),s},t}();exports.default=Mxassembly;
|
|
@@ -1,9 +1 @@
|
|
|
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();
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Mxassembly_1=require("./Mxassembly");exports.default=new Mxassembly_1.default;
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/** @module loadCoreCode */
|
|
4
|
-
var loadCoreCode_1 = require("./loadCoreCode");
|
|
5
|
-
exports.default = loadCoreCode_1.default;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var loadCoreCode_1=require("./loadCoreCode");exports.default=loadCoreCode_1.default;
|
|
@@ -1,125 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
/** @module loadCoreCode */
|
|
40
|
-
var dynamicImport_1 = require("../../tools/dynamicImport");
|
|
41
|
-
var store_1 = require("../store");
|
|
42
|
-
var mxfun_es5_js_1 = require("./mxfun.es5.js");
|
|
43
|
-
var mxcadassembly_es5_js_1 = require("./mxcadassembly_es5.js");
|
|
44
|
-
function rxInitMxEntity() {
|
|
45
|
-
var _a;
|
|
46
|
-
/*
|
|
47
|
-
new MxDbImage().rxInit()
|
|
48
|
-
new MxDbSVG().rxInit()
|
|
49
|
-
new MxDbAlignedDimension().rxInit()
|
|
50
|
-
new MxDbLine().rxInit()
|
|
51
|
-
new MxDbRect().rxInit()
|
|
52
|
-
*/
|
|
53
|
-
(_a = store_1.default.state.MxFun) === null || _a === void 0 ? void 0 : _a.initDynamicCreate(dynamicImport_1.dynamicCreateMxObject);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* 加载MxDraw库的核心代码 才能使用Mx的其他模块
|
|
57
|
-
* @returns Promise<{@link MxFun}>
|
|
58
|
-
* @example
|
|
59
|
-
* ```
|
|
60
|
-
* Mx.loadCoreCode().then(()=> console.log("加载完成", Mx.MxFun))
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
function loadCoreCode() {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var _this = this;
|
|
66
|
-
return __generator(this, function (_a) {
|
|
67
|
-
return [2 /*return*/, new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
|
|
68
|
-
var _a, _b, e_1;
|
|
69
|
-
return __generator(this, function (_c) {
|
|
70
|
-
switch (_c.label) {
|
|
71
|
-
case 0:
|
|
72
|
-
_c.trys.push([0, 2, , 3]);
|
|
73
|
-
if (store_1.default.state.MxFun) {
|
|
74
|
-
console.error('内部已调用loadCoreCode, 无需重复调用!');
|
|
75
|
-
return [2 /*return*/, rej({
|
|
76
|
-
code: 'error',
|
|
77
|
-
msg: '内部已调用loadCoreCode, 无需重复调用'
|
|
78
|
-
})];
|
|
79
|
-
}
|
|
80
|
-
_a = window;
|
|
81
|
-
_b = window;
|
|
82
|
-
return [4 /*yield*/, (0, dynamicImport_1.dynamicImport)('jquery')];
|
|
83
|
-
case 1:
|
|
84
|
-
_a.$ = _b.jQuery = _c.sent();
|
|
85
|
-
window.MxDocumentReady = undefined;
|
|
86
|
-
window.MxUiMain = function (requireFun) {
|
|
87
|
-
var MxFun = requireFun('./MxFun').MxFun;
|
|
88
|
-
store_1.default.commit('setMxFun', MxFun);
|
|
89
|
-
store_1.default.events.emit('MxUiMain', requireFun);
|
|
90
|
-
window.MxUiMain = undefined;
|
|
91
|
-
};
|
|
92
|
-
// 与MxMain有冲突(执行顺序有问题)
|
|
93
|
-
// window.MxDocumentReady = (requireFun: (path: string) => RequireFunReturnObjectType, mxinit: () => void) => {
|
|
94
|
-
// store.events.emit("MxDocumentReady", requireFun, mxinit)
|
|
95
|
-
// mxinit()
|
|
96
|
-
// }
|
|
97
|
-
window.MxMain = function (requireFun) {
|
|
98
|
-
store_1.default.events.emit('MxMain', requireFun);
|
|
99
|
-
window.MxMain = undefined;
|
|
100
|
-
rxInitMxEntity();
|
|
101
|
-
res();
|
|
102
|
-
return 0;
|
|
103
|
-
};
|
|
104
|
-
(0, mxcadassembly_es5_js_1.default)().then(function (mxassembly) {
|
|
105
|
-
//console.log(mxassembly);
|
|
106
|
-
store_1.default.commit('setMxassembly', mxassembly);
|
|
107
|
-
});
|
|
108
|
-
// 加载mxfun.min.js,mxfun()相当直接模拟了mxfun.min.js的加载。
|
|
109
|
-
(0, mxfun_es5_js_1.default)();
|
|
110
|
-
return [3 /*break*/, 3];
|
|
111
|
-
case 2:
|
|
112
|
-
e_1 = _c.sent();
|
|
113
|
-
rej({
|
|
114
|
-
code: 'error',
|
|
115
|
-
msg: e_1
|
|
116
|
-
});
|
|
117
|
-
return [3 /*break*/, 3];
|
|
118
|
-
case 3: return [2 /*return*/];
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}); })];
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
exports.default = loadCoreCode;
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function u(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}s((r=r.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};Object.defineProperty(exports,"__esModule",{value:!0});var dynamicImport_1=require("../../tools/dynamicImport"),store_1=require("../store"),mxfun_es5_js_1=require("./mxfun.es5.js"),mxcadassembly_es5_js_1=require("./mxcadassembly_es5.js");function rxInitMxEntity(){var e;null===(e=store_1.default.state.MxFun)||void 0===e||e.initDynamicCreate(dynamicImport_1.dynamicCreateMxObject)}function loadCoreCode(){return __awaiter(this,void 0,void 0,function(){var e=this;return __generator(this,function(t){return[2,new Promise(function(t,n){return __awaiter(e,void 0,void 0,function(){var e,r,o;return __generator(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),store_1.default.state.MxFun?(console.error("内部已调用loadCoreCode, 无需重复调用!"),[2,n({code:"error",msg:"内部已调用loadCoreCode, 无需重复调用"})]):(e=window,r=window,[4,(0,dynamicImport_1.dynamicImport)("jquery")]);case 1:return e.$=r.jQuery=i.sent(),window.MxDocumentReady=void 0,window.MxUiMain=function(e){var t=e("./MxFun").MxFun;store_1.default.commit("setMxFun",t),store_1.default.events.emit("MxUiMain",e),window.MxUiMain=void 0},window.MxMain=function(e){return store_1.default.events.emit("MxMain",e),window.MxMain=void 0,rxInitMxEntity(),t(),0},(0,mxcadassembly_es5_js_1.default)().then(function(e){store_1.default.commit("setMxassembly",e)}),(0,mxfun_es5_js_1.default)(),[3,3];case 2:return o=i.sent(),n({code:"error",msg:o}),[3,3];case 3:return[2]}})})})]})})}exports.default=loadCoreCode;
|