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.
Files changed (74) hide show
  1. package/dist/lib/MxModule/McEdGetPointWorldDrawObject/McEdGetPointWorldDrawObjectClass.js +1 -128
  2. package/dist/lib/MxModule/McEdGetPointWorldDrawObject/index.js +1 -5
  3. package/dist/lib/MxModule/McGeVector3d/McGeVector3d.js +1 -2
  4. package/dist/lib/MxModule/McGeVector3d/index.js +1 -3
  5. package/dist/lib/MxModule/McGiWorldDraw/McGiWorldDraw.js +1 -2
  6. package/dist/lib/MxModule/McGiWorldDraw/index.js +1 -2
  7. package/dist/lib/MxModule/McGiWorldDrawType/McGiWorldDrawType.js +1 -19
  8. package/dist/lib/MxModule/McGiWorldDrawType/index.js +1 -4
  9. package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/MrxDbgUiPrBaseReturn.js +1 -31
  10. package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/index.js +1 -5
  11. package/dist/lib/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.js +1 -150
  12. package/dist/lib/MxModule/MrxDbgUiPrPoint/index.js +1 -5
  13. package/dist/lib/MxModule/MxDbAlignedDimension/MxDbAlignedDimension.js +1 -213
  14. package/dist/lib/MxModule/MxDbAlignedDimension/index.js +1 -5
  15. package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +1 -241
  16. package/dist/lib/MxModule/MxDbEntity/index.js +1 -5
  17. package/dist/lib/MxModule/MxDbImage/MxDbImage.js +1 -160
  18. package/dist/lib/MxModule/MxDbImage/index.js +1 -5
  19. package/dist/lib/MxModule/MxDbLine/MxDbLine.js +1 -94
  20. package/dist/lib/MxModule/MxDbLine/index.js +1 -5
  21. package/dist/lib/MxModule/MxDbRect/MxDbRect.js +1 -273
  22. package/dist/lib/MxModule/MxDbRect/index.js +1 -4
  23. package/dist/lib/MxModule/MxDbSVG/MxDbSVG.js +1 -369
  24. package/dist/lib/MxModule/MxDbSVG/index.js +1 -5
  25. package/dist/lib/MxModule/MxDbSVGText/MxDbSVGText.js +1 -21
  26. package/dist/lib/MxModule/MxDbSVGText/index.js +1 -5
  27. package/dist/lib/MxModule/MxDrawObject/MxDrawObject.js +1 -754
  28. package/dist/lib/MxModule/MxDrawObject/index.js +1 -5
  29. package/dist/lib/MxModule/MxFilters/MxFilters.js +1 -201
  30. package/dist/lib/MxModule/MxFilters/index.js +1 -4
  31. package/dist/lib/MxModule/MxFun/MxFun.js +1 -630
  32. package/dist/lib/MxModule/MxFun/index.js +1 -9
  33. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js +1 -283
  34. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +1 -146
  35. package/dist/lib/MxModule/MxThreeJS/SVGLoader.js +1 -1862
  36. package/dist/lib/MxModule/MxThreeJS/index.js +1 -7
  37. package/dist/lib/MxModule/MxType/MxType.js +1 -27
  38. package/dist/lib/MxModule/MxType/index.js +1 -4
  39. package/dist/lib/MxModule/Mxassembly/Mxassembly.js +1 -18
  40. package/dist/lib/MxModule/Mxassembly/index.js +1 -9
  41. package/dist/lib/MxModule/loadCoreCode/index.js +1 -5
  42. package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +1 -125
  43. package/dist/lib/MxModule/loadCoreCode/mxUiData.js +1 -317
  44. package/dist/lib/MxModule/loadCoreCode/mxcadassembly_es5.js +1 -1519
  45. package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +1 -7361
  46. package/dist/lib/MxModule/store/PubsubClass.js +1 -40
  47. package/dist/lib/MxModule/store/StoreClass.js +1 -73
  48. package/dist/lib/MxModule/store/index.js +1 -16
  49. package/dist/lib/MxModule/store/store.js +1 -25
  50. package/dist/lib/MxModule/useCanvasResizeListener/index.js +1 -5
  51. package/dist/lib/MxModule/useCanvasResizeListener/useCanvasResizeListener.js +1 -95
  52. package/dist/lib/doc.js +1 -38
  53. package/dist/lib/mxdraw.js +1 -64
  54. package/dist/lib/tools/algorithm/math.js +1 -16
  55. package/dist/lib/tools/algorithm/random.js +1 -13
  56. package/dist/lib/tools/dom/create.js +1 -47
  57. package/dist/lib/tools/dynamicImport/index.js +1 -186
  58. package/dist/lib/tools/formatting/index.js +1 -20
  59. package/dist/lib/tools/proxy/index.js +1 -17
  60. package/dist/lib/tools/three/index.js +1 -124
  61. package/dist/lib/types/McEdGetPointWorldDrawObject.js +1 -2
  62. package/dist/lib/types/MrxDbgUiPrPoint.js +1 -2
  63. package/dist/lib/types/MxCADObject.js +1 -2
  64. package/dist/lib/types/MxDrawObject.js +1 -2
  65. package/dist/lib/types/MxFun.js +1 -2
  66. package/dist/lib/types/Mxassembly.js +1 -2
  67. package/dist/mxdraw.es5.js +1 -45
  68. package/dist/mxdraw.umd.js +1 -45
  69. package/dist/types/MxModule/MxFun/MxFun.d.ts +18 -1
  70. package/dist/types/MxModule/store/index.d.ts +2 -7
  71. package/dist/types/mxdraw.d.ts +1 -4
  72. package/package.json +6 -5
  73. package/dist/mxdraw.es5.js.map +0 -1
  74. package/dist/mxdraw.umd.js.map +0 -1
@@ -1,283 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- ///////////////////////////////////////////////////////////////////////////////
4
- //版权所有(C)2002-2022,成都梦想凯德科技有限公司。
5
- //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
6
- //此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
7
- ///////////////////////////////////////////////////////////////////////////////
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"),math_1=require("../../tools/algorithm/math"),formatting_1=require("../../tools/formatting"),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){var i,a=document.createElement("canvas"),s=a.getContext("2d"),c=(0,formatting_1.formatString)("normal {0}px Arial","256");if(null==s)return null;s.font=c;var h=s.measureText(e);i=2*(0,math_1.floorPowerOfTwo)(h.width),a.width=i,a.height=256,s.font=c,s.textAlign="center",s.textBaseline="middle",s.fillStyle=(0,formatting_1.formatString)("rgba({0}, {1}, {2}, 1.0)",(o>>16&255)+"",(o>>8&255)+"",(255&o)+""),s.fillText(e,i/2,128);var l=new three_1.Texture(a);l.needsUpdate=!0;var p=new three_1.SpriteMaterial({transparent:!0,depthTest:!1,map:l});p.rotation=n;var u=new three_1.Sprite(p);return u.scale.set(i/256*r,r,1),u.position.set(t.x,t.y,t.z),u},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 new Promise(function(e){e(null)})},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"),SVGLoader_1=require("./SVGLoader"),three_2=require("../../tools/three"),MxThreeJSSVGData=function(){return function(){this.svg=new three_1.Group,this.aryMeterial=[]}}(),MxThreeJSBuffer=function(){function e(){this.mapSvgUrlToData=new Map}return e.prototype.loadSVGImp=function(e,t,r){(new SVGLoader_1.SVGLoader).load(e,function(e){for(var a=[],n=e.paths,o=new three_1.Group,l=0;l<n.length;l++){var i=n[l],u=i.userData.style.fill;if(void 0!==u&&"none"!==u){for(var s=new three_1.MeshBasicMaterial({color:t||(new three_1.Color).setStyle(u),opacity:i.userData.style.fillOpacity,transparent:i.userData.style.fillOpacity<1,side:three_1.DoubleSide,depthWrite:!1,wireframe:!1}),h=SVGLoader_1.SVGLoader.createShapes(i),f=0;f<h.length;f++){var d=h[f],p=new three_1.ShapeBufferGeometry(d),c=new three_1.Mesh(p,s);o.add(c)}a.push(s)}i.userData.style.stroke}r&&r(o,a)},void 0,function(){r&&r(null,null)})},e.prototype.loadSVG=function(e,t,r){var a=this,n=this.mapSvgUrlToData.get(e);n?r&&(null==n?r(null,null):r(n.svg.clone(),n.aryMeterial)):this.loadSVGImp(e,t,function(t,n){if(t&&n){var o=new MxThreeJSSVGData;o.svg=t,o.aryMeterial=n,a.mapSvgUrlToData.set(e,o),r&&r(o.svg.clone(),o.aryMeterial)}else a.mapSvgUrlToData.set(e,null),r&&r(null,null)})},e}();function default_1(e){var t=new MxThreeJSBuffer;e.createImage=function(e,t,r,a,n){(new three_1.TextureLoader).load(a,function(a){var o=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)(o,e);var i=new three_1.Mesh(o,l);i.material.depthTest=!1,n&&n(i)},void 0,function(e){console.log(e),n&&n(null)})},e.loadSVG=function(e,r,a){return a?(t.loadSVG(e,r,a),new Promise(function(e){e(null)})):new Promise(function(a){t.loadSVG(e,r,function(e){a(e)})})}}exports.default=default_1;