fl-web-component 2.0.19 → 2.1.1-beta.0

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 (42) hide show
  1. package/dist/fl-web-component.common.1.js.map +1 -1
  2. package/dist/fl-web-component.common.2.js.map +1 -1
  3. package/dist/fl-web-component.common.js +5871 -1872
  4. package/dist/fl-web-component.common.js.map +1 -1
  5. package/dist/fl-web-component.css +1 -1
  6. package/package.json +4 -3
  7. package/packages/components/com-flcanvas/components/entityFormatting.js +134 -1
  8. package/packages/components/com-flcanvas/index.vue +335 -239
  9. package/packages/components/com-graphics/index.vue +433 -35
  10. package/packages/components/com-graphics/mock.json +115 -0
  11. package/packages/utils/StreamLoader.js +250 -107
  12. package/packages/utils/StreamLoaderParser.worker.js +180 -72
  13. package/src/utils/dxf-parser/AutoCadColorIndex.js +265 -0
  14. package/src/utils/dxf-parser/DimStyleCodes.js +33 -0
  15. package/src/utils/dxf-parser/DxfArrayScanner.js +151 -0
  16. package/src/utils/dxf-parser/DxfParser.js +918 -0
  17. package/src/utils/dxf-parser/ExtendedDataParser.js +117 -0
  18. package/src/utils/dxf-parser/LICENSE +21 -0
  19. package/src/utils/dxf-parser/ParseHelpers.js +140 -0
  20. package/src/utils/dxf-parser/README.md +8 -0
  21. package/src/utils/dxf-parser/entities/3dface.js +83 -0
  22. package/src/utils/dxf-parser/entities/arc.js +38 -0
  23. package/src/utils/dxf-parser/entities/attdef.js +89 -0
  24. package/src/utils/dxf-parser/entities/attribute.js +109 -0
  25. package/src/utils/dxf-parser/entities/circle.js +43 -0
  26. package/src/utils/dxf-parser/entities/dimension.js +71 -0
  27. package/src/utils/dxf-parser/entities/ellipse.js +48 -0
  28. package/src/utils/dxf-parser/entities/hatch.js +348 -0
  29. package/src/utils/dxf-parser/entities/insert.js +57 -0
  30. package/src/utils/dxf-parser/entities/line.js +34 -0
  31. package/src/utils/dxf-parser/entities/lwpolyline.js +103 -0
  32. package/src/utils/dxf-parser/entities/mtext.js +57 -0
  33. package/src/utils/dxf-parser/entities/point.js +35 -0
  34. package/src/utils/dxf-parser/entities/polyline.js +92 -0
  35. package/src/utils/dxf-parser/entities/solid.js +40 -0
  36. package/src/utils/dxf-parser/entities/spline.js +70 -0
  37. package/src/utils/dxf-parser/entities/text.js +50 -0
  38. package/src/utils/dxf-parser/entities/vertex.js +62 -0
  39. package/src/utils/flgltf-parser.js +21 -9
  40. package/src/utils/instance-parser.js +59 -59
  41. package/src/utils/threejs/measure-clear-distance.js +149 -123
  42. package/packages/components/com-graphics/box.json +0 -77
@@ -88,8 +88,11 @@ function createStreamState(prefixIdKey) {
88
88
  return {
89
89
  prefixIdKey: prefixIdKey || '',
90
90
  buffer: new Uint8Array(),
91
- pendingPrimitives: new Map(),
92
- expectingPrimitive: true,
91
+ pendingMesh: null,
92
+ pendingPrimitiveIds: new Set(),
93
+ pendingPrimitiveGroups: [],
94
+ pendingMatchedPrimitiveIds: new Set(),
95
+ expectingMesh: true,
93
96
  isFullProps: true,
94
97
  };
95
98
  }
@@ -105,101 +108,179 @@ function parseStreamChunk(state, chunkView, flushing = false) {
105
108
  const meshes = [];
106
109
  const primitives = [];
107
110
 
108
- while (state.buffer.length > 0) {
109
- if (state.expectingPrimitive) {
110
- if (state.buffer.length < 12) break;
111
+ const commitPendingMesh = () => {
112
+ if (!state.pendingMesh) return;
111
113
 
112
- try {
113
- const dataView = new DataView(
114
- state.buffer.buffer,
115
- state.buffer.byteOffset,
116
- state.buffer.byteLength
117
- );
118
- const primitiveResult = parsePrimitive(dataView, state.buffer, 0, state.isFullProps);
119
- const primitiveData = primitiveResult.primitive;
120
-
121
- _applyPrefixId(primitiveData, 'id', null, state.prefixIdKey);
122
- _applyPrefixId(primitiveData, 'material', null, state.prefixIdKey);
123
-
124
- if (state.isFullProps) {
125
- const { position, normal, posindex, nolindex, indices } =
126
- parsePrimitiveData(primitiveData);
127
- const formatted = formatPrimitiveData({ position, normal, posindex, nolindex });
128
- delete primitiveData.nolindex;
129
- delete primitiveData.posindex;
130
- primitiveData.position = formatted.position;
131
- primitiveData.normal = formatted.normal;
132
- primitiveData.indices = indices;
133
- }
114
+ const meshList = Array.isArray(state.pendingMesh) ? state.pendingMesh : [state.pendingMesh];
115
+ meshList.forEach(mesh => {
116
+ meshes.push(mesh);
117
+ primitives.push(state.pendingPrimitiveGroups);
118
+ });
134
119
 
135
- state.pendingPrimitives.set(primitiveData.id, primitiveData);
136
- state.expectingPrimitive = false;
137
- state.buffer = state.buffer.slice(primitiveResult.offset);
138
- } catch (e) {
120
+ state.pendingMesh = null;
121
+ state.pendingPrimitiveIds = new Set();
122
+ state.pendingPrimitiveGroups = [];
123
+ state.pendingMatchedPrimitiveIds = new Set();
124
+ };
125
+
126
+ while (state.buffer.length > 0) {
127
+ if (state.expectingMesh) {
128
+ const meshResult = tryParseMeshFromState(state);
129
+ if (meshResult.status === 'incomplete') break;
130
+ if (meshResult.status === 'invalid') {
139
131
  break;
140
132
  }
141
- } else {
142
- if (state.buffer.length < 4) break;
143
133
 
144
- const length = new DataView(state.buffer.buffer, state.buffer.byteOffset).getUint32(0, false);
145
- if (length > 10 * 1024 * 1024) {
146
- state.expectingPrimitive = true;
134
+ commitPendingMesh();
135
+ state.pendingMesh = meshResult.mesh;
136
+ state.pendingPrimitiveIds = new Set(collectMeshPrimitiveIds(meshResult.mesh));
137
+ state.pendingPrimitiveGroups = [];
138
+ state.pendingMatchedPrimitiveIds = new Set();
139
+ state.expectingMesh = false;
140
+ state.buffer = state.buffer.slice(meshResult.totalLen);
141
+ } else {
142
+ const nextMeshResult = tryParseMeshFromState(state);
143
+ if (nextMeshResult.status === 'success') {
144
+ commitPendingMesh();
145
+ state.pendingMesh = nextMeshResult.mesh;
146
+ state.pendingPrimitiveIds = new Set(collectMeshPrimitiveIds(nextMeshResult.mesh));
147
+ state.pendingPrimitiveGroups = [];
148
+ state.pendingMatchedPrimitiveIds = new Set();
149
+ state.expectingMesh = false;
150
+ state.buffer = state.buffer.slice(nextMeshResult.totalLen);
147
151
  continue;
148
152
  }
149
153
 
150
- const totalLen = 4 + length;
151
- if (state.buffer.length < totalLen) break;
152
-
153
- const data = state.buffer.slice(4, totalLen);
154
- let mesh = null;
154
+ if (state.buffer.length < 12) break;
155
155
 
156
+ let primitiveResult = null;
156
157
  try {
157
- const jsonStr = utf8Decoder.decode(data);
158
- mesh = JSON.parse(jsonStr);
158
+ primitiveResult = parsePrimitiveFromState(state);
159
159
  } catch (e) {
160
- state.expectingPrimitive = true;
161
- continue;
160
+ break;
162
161
  }
163
162
 
164
- if (mesh) {
165
- state.isFullProps = true;
163
+ const primitiveData = primitiveResult.primitive;
166
164
 
167
- _applyPrefixId(mesh, 'id', null, state.prefixIdKey);
168
- if (Array.isArray(mesh)) {
169
- mesh.forEach(item => {
170
- _applyPrefixId(item.primitives, 'prmid', item.documentId, state.prefixIdKey);
171
- });
172
- } else {
173
- _applyPrefixId(mesh.primitives, 'prmid', mesh.documentId, state.prefixIdKey);
174
- }
165
+ if (state.pendingPrimitiveIds.has(primitiveData.id)) {
166
+ state.pendingPrimitiveGroups.push(primitiveData);
167
+ state.pendingMatchedPrimitiveIds.add(primitiveData.id);
168
+ }
175
169
 
176
- const docId = mesh.id;
177
- const meshToPrimId = mesh.primitives.map(item => item.prmid);
178
- const hasPendingPrimitive = meshToPrimId.some(item => state.pendingPrimitives.has(item));
179
- const hasPendingMesh = state.pendingPrimitives.has(docId);
180
-
181
- if (hasPendingMesh || hasPendingPrimitive) {
182
- let primitiveData = state.pendingPrimitives.get(docId);
183
- if (!hasPendingMesh && hasPendingPrimitive) {
184
- primitiveData = state.pendingPrimitives.get(meshToPrimId[0]);
185
- }
186
- meshes.push(mesh);
187
- primitives.push(primitiveData);
188
- }
170
+ state.buffer = state.buffer.slice(primitiveResult.consumedBytes);
189
171
 
190
- state.expectingPrimitive = false;
191
- state.buffer = state.buffer.slice(totalLen);
172
+ if (
173
+ state.pendingPrimitiveIds.size > 0 &&
174
+ state.pendingMatchedPrimitiveIds.size >= state.pendingPrimitiveIds.size
175
+ ) {
176
+ commitPendingMesh();
177
+ state.expectingMesh = true;
192
178
  }
193
179
  }
194
180
  }
195
181
 
196
182
  if (flushing) {
183
+ commitPendingMesh();
197
184
  state.buffer = new Uint8Array();
198
185
  }
199
186
 
200
187
  return { meshes, primitives };
201
188
  }
202
189
 
190
+ function normalizeStreamMesh(mesh, prefixIdKey) {
191
+ _applyPrefixId(mesh, 'id', null, prefixIdKey);
192
+ const meshList = Array.isArray(mesh) ? mesh : [mesh];
193
+
194
+ meshList.forEach(item => {
195
+ if (!item) return;
196
+ if (!Array.isArray(item.primitives)) {
197
+ item.primitives = [];
198
+ }
199
+ _applyPrefixId(item.primitives, 'prmid', item.documentId, prefixIdKey);
200
+ });
201
+
202
+ return mesh;
203
+ }
204
+
205
+ function collectMeshPrimitiveIds(mesh) {
206
+ const ids = [];
207
+ const meshList = Array.isArray(mesh) ? mesh : [mesh];
208
+
209
+ meshList.forEach(item => {
210
+ if (!item || !Array.isArray(item.primitives)) return;
211
+ item.primitives.forEach(primitive => {
212
+ if (primitive && primitive.prmid != null) {
213
+ ids.push(primitive.prmid);
214
+ }
215
+ });
216
+ });
217
+
218
+ return ids;
219
+ }
220
+
221
+ function isValidStreamMesh(mesh) {
222
+ const meshList = Array.isArray(mesh) ? mesh : [mesh];
223
+ if (meshList.length === 0) return false;
224
+ return meshList.every(item => item && typeof item === 'object' && Array.isArray(item.primitives));
225
+ }
226
+
227
+ function tryParseMeshFromState(state) {
228
+ if (state.buffer.length < 4) {
229
+ return { status: 'incomplete' };
230
+ }
231
+
232
+ const length = new DataView(state.buffer.buffer, state.buffer.byteOffset).getUint32(0, false);
233
+ if (length <= 0 || length > 10 * 1024 * 1024) {
234
+ return { status: 'invalid' };
235
+ }
236
+
237
+ const totalLen = 4 + length;
238
+ if (state.buffer.length < totalLen) {
239
+ return { status: 'incomplete' };
240
+ }
241
+
242
+ try {
243
+ const data = state.buffer.slice(4, totalLen);
244
+ const parsedMesh = JSON.parse(utf8Decoder.decode(data));
245
+ if (!isValidStreamMesh(parsedMesh)) {
246
+ return { status: 'invalid' };
247
+ }
248
+ const mesh = normalizeStreamMesh(parsedMesh, state.prefixIdKey);
249
+ return { status: 'success', mesh, totalLen };
250
+ } catch (e) {
251
+ return { status: 'invalid' };
252
+ }
253
+ }
254
+
255
+ function parsePrimitiveFromState(state) {
256
+ const dataView = new DataView(
257
+ state.buffer.buffer,
258
+ state.buffer.byteOffset,
259
+ state.buffer.byteLength
260
+ );
261
+ const primitiveResult = parsePrimitive(dataView, state.buffer, 0, state.isFullProps);
262
+ const primitiveData = primitiveResult.primitive;
263
+
264
+ _applyPrefixId(primitiveData, 'id', null, state.prefixIdKey);
265
+ _applyPrefixId(primitiveData, 'material', null, state.prefixIdKey);
266
+
267
+ if (state.isFullProps) {
268
+ const { position, normal, posindex, nolindex, indices } =
269
+ parsePrimitiveData(primitiveData);
270
+ const formatted = formatPrimitiveData({ position, normal, posindex, nolindex });
271
+ delete primitiveData.nolindex;
272
+ delete primitiveData.posindex;
273
+ primitiveData.position = formatted.position;
274
+ primitiveData.normal = formatted.normal;
275
+ primitiveData.indices = indices;
276
+ }
277
+
278
+ return {
279
+ primitive: primitiveData,
280
+ consumedBytes: primitiveResult.offset,
281
+ };
282
+ }
283
+
203
284
  function parseBufferData(buffer, prefixIdKey) {
204
285
  let uint8Array = null;
205
286
  let dataView = null;
@@ -288,8 +369,20 @@ function parsePrimitive(dataView, uint8Array, offset, isFullProps = true) {
288
369
  if (dataView.byteLength < offset + 12) {
289
370
  throw new Error('Insufficient data for primitive header');
290
371
  }
291
- primitive.id = dataView.getInt32(offset, false);
372
+ const primitiveIdTextLen = dataView.getUint32(offset, false);
292
373
  offset += 4;
374
+ if (primitiveIdTextLen === 0xffffffff) {
375
+ primitive.id = null;
376
+ } else if (primitiveIdTextLen > 0) {
377
+ if (dataView.byteLength < offset + primitiveIdTextLen) {
378
+ throw new Error('Insufficient data for primitive id content');
379
+ }
380
+ const textBytes = uint8Array.subarray(offset, offset + primitiveIdTextLen);
381
+ primitive.id = utf8Decoder.decode(textBytes);
382
+ offset += primitiveIdTextLen;
383
+ } else {
384
+ primitive.id = '';
385
+ }
293
386
 
294
387
  if (dataView.byteLength < offset + 4) {
295
388
  throw new Error('Insufficient data for GeomText length');
@@ -309,8 +402,23 @@ function parsePrimitive(dataView, uint8Array, offset, isFullProps = true) {
309
402
  primitive.documentId = '';
310
403
  }
311
404
 
312
- primitive.material = dataView.getInt32(offset, false);
405
+ if (dataView.byteLength < offset + 4) {
406
+ throw new Error('Insufficient data for Material length');
407
+ }
408
+ const materialTextLen = dataView.getUint32(offset, false);
313
409
  offset += 4;
410
+ if (materialTextLen === 0xffffffff) {
411
+ primitive.material = null;
412
+ } else if (materialTextLen > 0) {
413
+ if (dataView.byteLength < offset + materialTextLen) {
414
+ throw new Error('Insufficient data for Material content');
415
+ }
416
+ const textBytes = uint8Array.subarray(offset, offset + materialTextLen);
417
+ primitive.material = utf8Decoder.decode(textBytes);
418
+ offset += materialTextLen;
419
+ } else {
420
+ primitive.material = '';
421
+ }
314
422
 
315
423
  if (dataView.byteLength < offset + 4) {
316
424
  throw new Error('Insufficient data for GeomText length');
@@ -0,0 +1,265 @@
1
+ /**
2
+ * AutoCad files sometimes use an indexed color value between 1 and 255 inclusive.
3
+ * Each value corresponds to a color. index 1 is red, that is 16711680 or 0xFF0000.
4
+ * index 0 and 256, while included in this array, are actually reserved for inheritance
5
+ * values in AutoCad so they should not be used for index color lookups.
6
+ */
7
+
8
+ export default [
9
+ 0,
10
+ 16711680,
11
+ 16776960,
12
+ 65280,
13
+ 65535,
14
+ 255,
15
+ 16711935,
16
+ 16777215,
17
+ 8421504,
18
+ 12632256,
19
+ 16711680,
20
+ 16744319,
21
+ 13369344,
22
+ 13395558,
23
+ 10027008,
24
+ 10046540,
25
+ 8323072,
26
+ 8339263,
27
+ 4980736,
28
+ 4990502,
29
+ 16727808,
30
+ 16752511,
31
+ 13382400,
32
+ 13401958,
33
+ 10036736,
34
+ 10051404,
35
+ 8331008,
36
+ 8343359,
37
+ 4985600,
38
+ 4992806,
39
+ 16744192,
40
+ 16760703,
41
+ 13395456,
42
+ 13408614,
43
+ 10046464,
44
+ 10056268,
45
+ 8339200,
46
+ 8347455,
47
+ 4990464,
48
+ 4995366,
49
+ 16760576,
50
+ 16768895,
51
+ 13408512,
52
+ 13415014,
53
+ 10056192,
54
+ 10061132,
55
+ 8347392,
56
+ 8351551,
57
+ 4995328,
58
+ 4997670,
59
+ 16776960,
60
+ 16777087,
61
+ 13421568,
62
+ 13421670,
63
+ 10000384,
64
+ 10000460,
65
+ 8355584,
66
+ 8355647,
67
+ 5000192,
68
+ 5000230,
69
+ 12582656,
70
+ 14679935,
71
+ 10079232,
72
+ 11717734,
73
+ 7510016,
74
+ 8755276,
75
+ 6258432,
76
+ 7307071,
77
+ 3755008,
78
+ 4344870,
79
+ 8388352,
80
+ 12582783,
81
+ 6736896,
82
+ 10079334,
83
+ 5019648,
84
+ 7510092,
85
+ 4161280,
86
+ 6258495,
87
+ 2509824,
88
+ 3755046,
89
+ 4194048,
90
+ 10485631,
91
+ 3394560,
92
+ 8375398,
93
+ 2529280,
94
+ 6264908,
95
+ 2064128,
96
+ 5209919,
97
+ 1264640,
98
+ 3099686,
99
+ 65280,
100
+ 8388479,
101
+ 52224,
102
+ 6736998,
103
+ 38912,
104
+ 5019724,
105
+ 32512,
106
+ 4161343,
107
+ 19456,
108
+ 2509862,
109
+ 65343,
110
+ 8388511,
111
+ 52275,
112
+ 6737023,
113
+ 38950,
114
+ 5019743,
115
+ 32543,
116
+ 4161359,
117
+ 19475,
118
+ 2509871,
119
+ 65407,
120
+ 8388543,
121
+ 52326,
122
+ 6737049,
123
+ 38988,
124
+ 5019762,
125
+ 32575,
126
+ 4161375,
127
+ 19494,
128
+ 2509881,
129
+ 65471,
130
+ 8388575,
131
+ 52377,
132
+ 6737074,
133
+ 39026,
134
+ 5019781,
135
+ 32607,
136
+ 4161391,
137
+ 19513,
138
+ 2509890,
139
+ 65535,
140
+ 8388607,
141
+ 52428,
142
+ 6737100,
143
+ 39064,
144
+ 5019800,
145
+ 32639,
146
+ 4161407,
147
+ 19532,
148
+ 2509900,
149
+ 49151,
150
+ 8380415,
151
+ 39372,
152
+ 6730444,
153
+ 29336,
154
+ 5014936,
155
+ 24447,
156
+ 4157311,
157
+ 14668,
158
+ 2507340,
159
+ 32767,
160
+ 8372223,
161
+ 26316,
162
+ 6724044,
163
+ 19608,
164
+ 5010072,
165
+ 16255,
166
+ 4153215,
167
+ 9804,
168
+ 2505036,
169
+ 16383,
170
+ 8364031,
171
+ 13260,
172
+ 6717388,
173
+ 9880,
174
+ 5005208,
175
+ 8063,
176
+ 4149119,
177
+ 4940,
178
+ 2502476,
179
+ 255,
180
+ 8355839,
181
+ 204,
182
+ 6710988,
183
+ 152,
184
+ 5000344,
185
+ 127,
186
+ 4145023,
187
+ 76,
188
+ 2500172,
189
+ 4129023,
190
+ 10452991,
191
+ 3342540,
192
+ 8349388,
193
+ 2490520,
194
+ 6245528,
195
+ 2031743,
196
+ 5193599,
197
+ 1245260,
198
+ 3089996,
199
+ 8323327,
200
+ 12550143,
201
+ 6684876,
202
+ 10053324,
203
+ 4980888,
204
+ 7490712,
205
+ 4128895,
206
+ 6242175,
207
+ 2490444,
208
+ 3745356,
209
+ 12517631,
210
+ 14647295,
211
+ 10027212,
212
+ 11691724,
213
+ 7471256,
214
+ 8735896,
215
+ 6226047,
216
+ 7290751,
217
+ 3735628,
218
+ 4335180,
219
+ 16711935,
220
+ 16744447,
221
+ 13369548,
222
+ 13395660,
223
+ 9961624,
224
+ 9981080,
225
+ 8323199,
226
+ 8339327,
227
+ 4980812,
228
+ 4990540,
229
+ 16711871,
230
+ 16744415,
231
+ 13369497,
232
+ 13395634,
233
+ 9961586,
234
+ 9981061,
235
+ 8323167,
236
+ 8339311,
237
+ 4980793,
238
+ 4990530,
239
+ 16711807,
240
+ 16744383,
241
+ 13369446,
242
+ 13395609,
243
+ 9961548,
244
+ 9981042,
245
+ 8323135,
246
+ 8339295,
247
+ 4980774,
248
+ 4990521,
249
+ 16711743,
250
+ 16744351,
251
+ 13369395,
252
+ 13395583,
253
+ 9961510,
254
+ 9981023,
255
+ 8323103,
256
+ 8339279,
257
+ 4980755,
258
+ 4990511,
259
+ 3355443,
260
+ 5987163,
261
+ 8684676,
262
+ 11382189,
263
+ 14079702,
264
+ 16777215
265
+ ];
@@ -0,0 +1,33 @@
1
+ /** Dimension style variables are used either in DIMSTYLE table or in DIMENSION entity style
2
+ * override in XDATA.
3
+ */
4
+ const codes = new Map([
5
+ [140, "DIMTXT"],
6
+ [142, "DIMTSZ"],
7
+ [144, "DIMLFAC"],
8
+ [147, "DIMGAP"],
9
+ [173, "DIMSAH"],
10
+ [175, "DIMSOXD"],
11
+ [176, "DIMCLRD"],
12
+ [177, "DIMCLRE"],
13
+ [178, "DIMCLRT"],
14
+ [271, "DIMDEC"],
15
+ [278 ,"DIMDSEP"],
16
+ [281, "DIMSD1"],
17
+ [282, "DIMSD2"],
18
+ [3, "DIMPOST"],
19
+ [40, "DIMSCALE"],
20
+ [41, "DIMASZ"],
21
+ [42, "DIMEXO"],
22
+ [44, "DIMEXE"],
23
+ [45, "DIMRND"],
24
+ [46, "DIMDLE"],
25
+ [5, "DIMBLK"],
26
+ [6, "DIMBLK1"],
27
+ [7, "DIMBLK2"],
28
+ [75, "DIMSE1"],
29
+ [76, "DIMSE2"],
30
+ [78, "DIMZIN"],
31
+ ])
32
+
33
+ export default codes