fl-web-component 2.0.0-beta.9 → 2.0.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 (33) hide show
  1. package/dist/fl-web-component.common.js +34592 -1519
  2. package/dist/fl-web-component.common.js.map +1 -1
  3. package/dist/fl-web-component.css +1 -1
  4. package/package.json +4 -15
  5. package/packages/components/com-card/index.vue +1 -1
  6. package/packages/components/com-flcanvas/components/bspline.js +31 -34
  7. package/packages/components/com-flcanvas/components/entityFormatting.js +810 -823
  8. package/packages/components/com-flcanvas/components/round10.js +17 -17
  9. package/packages/components/com-flcanvas/index.vue +314 -333
  10. package/packages/components/com-formDialog/index.vue +6 -4
  11. package/packages/components/com-graphics/component/ann-tool.vue +263 -208
  12. package/packages/components/com-graphics/index.vue +366 -773
  13. package/packages/components/com-graphics/pid.vue +304 -295
  14. package/packages/components/com-table/column-default.vue +2 -3
  15. package/packages/components/com-table/column-dynamic.vue +7 -4
  16. package/packages/components/com-table/column.vue +1 -2
  17. package/packages/components/com-table/index.vue +6 -5
  18. package/packages/components/com-tabs/index.vue +1 -2
  19. package/packages/components/com-tiles/index.vue +134 -136
  20. package/packages/components/com-treeDynamic/index.vue +1 -1
  21. package/packages/utils/StreamLoader.js +1548 -1489
  22. package/packages/utils/StreamLoaderParser.worker.js +9 -14
  23. package/src/main.js +2 -8
  24. package/src/utils/cloud.js +28 -28
  25. package/src/utils/cursor.js +11 -9
  26. package/src/utils/flgltf-parser.js +257 -245
  27. package/src/utils/instance-parser.js +20 -22
  28. package/src/utils/mini-devtool.js +94 -39
  29. package/src/utils/threejs/measure-angle.js +51 -13
  30. package/src/utils/threejs/measure-area.js +43 -12
  31. package/src/utils/threejs/measure-distance.js +43 -12
  32. package/src/utils/threejs/rain-shader.js +10 -10
  33. package/src/utils/threejs/snow-shader.js +9 -9
@@ -1,245 +1,257 @@
1
- import * as THREE from 'three';
2
-
3
- const NODE_TYPES = {
4
- pbsGrp: 1,
5
- major: 2,
6
- model: 3,
7
- };
8
-
9
- // 处理mesh数据,生成drawObjs
10
- function processMeshData(input, options) {
11
- const drawObjMap = new Map();
12
-
13
- if (!input.mesh) {
14
- return [];
15
- }
16
-
17
- input.mesh.forEach(meshItem => {
18
- const geomList = [];
19
- meshItem.primitives.forEach(primitive => {
20
- const primitiveData = input.primitive.find(g => g.id === primitive.prmid);
21
- if (primitiveData) {
22
- const material = input.material?.find(m => m.id === primitiveData.material);
23
- const prop = {
24
- color: material?.color || [255, 255, 255, 1],
25
- fontsize: material?.fontsize !== undefined ? material?.fontsize : 20,
26
- frontname: material?.frontname !== undefined ? material?.frontname : '',
27
- italic: material?.italic,
28
- linepacing: 1, // 默认值
29
- linewidth: material?.linewidth !== undefined ? material?.linewidth : 1, // 默认值
30
- visible: material?.visible === false ? false : true,
31
- transparent: material?.transp !== undefined ? material?.transp : 0,
32
- };
33
-
34
- const identity = new THREE.Matrix4().identity();
35
-
36
- geomList.push({
37
- matrix: {
38
- val: primitive.matrix?.length ? primitive.matrix : identity.elements,
39
- // val: identity.elements,
40
- },
41
- // originMatrix: meshItem.id == primitive.prmid ? [] : identity.elements,
42
- prmid: primitive.prmid,
43
- geomId: primitiveData.id,
44
- type: primitiveData.geomType,
45
- text: primitiveData.geomText,
46
- points: primitiveData.position,
47
- alignType: primitiveData.alignType,
48
- normals: primitiveData.normal,
49
- triangles: primitiveData.indices || [],
50
- max: primitiveData.max,
51
- min: primitiveData.min,
52
- prop: prop,
53
- });
54
- }
55
- });
56
-
57
- drawObjMap.set(meshItem.id, {
58
- drawObjId: meshItem.id,
59
- geoms: geomList,
60
- // lodLevel: meshItem.type || 2,
61
- });
62
- });
63
-
64
- return Array.from(drawObjMap.values());
65
- }
66
-
67
- // 处理node数据,生成instances
68
- function processNodeData(input, options) {
69
- const flatNode = options?.flatNode;
70
-
71
- function flattenAndComputeWorldMatrices(
72
- nodes,
73
- result = [],
74
- // parentWorldMatrix = null,
75
- fatherId = ''
76
- ) {
77
- for (const node of nodes) {
78
- const { category, instanceId, matrix, children, drawObject, groupId, nodeType } = node;
79
-
80
- // 构造本地矩阵
81
- let localMatrix;
82
- if (matrix && matrix.val) {
83
- localMatrix = new THREE.Matrix4().fromArray(matrix.val);
84
- } else {
85
- localMatrix = new THREE.Matrix4().identity(); // 默认为单位矩阵
86
- }
87
-
88
- // 计算世界矩阵
89
- // const worldMatrix = parentWorldMatrix
90
- // ? parentWorldMatrix.clone().multiply(localMatrix)
91
- // : localMatrix.clone();
92
- const worldMatrix = localMatrix.clone();
93
-
94
- // 构造输出节点
95
- result.push({
96
- drawObject,
97
- category,
98
- instanceId,
99
- // matrix,
100
- matrix: {
101
- val: Array.from(worldMatrix.toArray()),
102
- },
103
- fatherId,
104
- groupId,
105
- nodeType,
106
- });
107
-
108
- // 递归处理子节点,传递当前世界矩阵
109
- if (children) {
110
- flattenAndComputeWorldMatrices(children, result, instanceId);
111
- }
112
- }
113
-
114
- return result;
115
- }
116
-
117
- if(!flatNode){
118
- const formatInstances = [];
119
- const preNode = input.node ? input.node : generateNode(input.mesh);
120
- const rootInstances = parseNode(preNode);
121
- flattenAndComputeWorldMatrices(rootInstances, formatInstances);
122
-
123
- return formatInstances
124
- }else{
125
- return parseNode(input.node, flatNode);
126
- }
127
- }
128
-
129
- // 处理一个primitive,生成多个drawObj
130
- function processOnePrimtiveToMultiMesh(primitive){
131
- return {
132
- instanceId: primitive.drawObjId, // 实例与drawObj一对多关系
133
- drawObject: primitive.geoms[0]?.prmid || '',
134
- matrix: primitive.geoms[0]?.matrix || [],
135
- }
136
- }
137
-
138
- // 主解析函数,整合两个独立模块的结果
139
- function parseData(input, options) {
140
- const drawObjs = processMeshData(input, options);
141
- const instances = drawObjs.map((item) => {
142
- return processOnePrimtiveToMultiMesh(item); // 实例与drawObj一对多关系
143
- })
144
- // const instances = drawObjs.map((item) => {
145
- // return {
146
- // instanceId: item.drawObjId, // 实例与drawObj一对一关系
147
- // drawObject: item.drawObjId,
148
- // }
149
- // })
150
- // const instances = processNodeData(input);
151
-
152
- const map = {
153
- drawObjs,
154
- instances,
155
- };
156
- // console.log('parseData', map);
157
- return map;
158
- }
159
-
160
- // 递归处理节点实例
161
- function parseNode(node, isFlatNode) {
162
- function processInstance(instance, parentInstanceId, instanceMap, groupId, isFlatNode) {
163
- const newInstance = {
164
- category: instance.category || instance.name,
165
- drawObject: instance.drawObject || instance.mesh,
166
- fatherId: parentInstanceId || '',
167
- instanceId: instance.id || instance.batchId,
168
- matrix: instance.matrix,
169
- children: [],
170
- nodeType: instance.nodeType,
171
- groupId: instance.nodeType === NODE_TYPES.pbsGrp ? instance._batchId : groupId,
172
- };
173
-
174
- if(!isFlatNode){
175
- // 处理子实例
176
- if (instance.children && instance.children.length > 0) {
177
- instance.children.forEach(childId => {
178
- const childInstance = instanceMap.get(childId);
179
- if (childInstance) {
180
- const processedChild = processInstance(
181
- childInstance,
182
- instance._batchId,
183
- instanceMap,
184
- newInstance.groupId
185
- );
186
- newInstance.children.push(processedChild);
187
- }
188
- });
189
- }
190
- }
191
-
192
- return newInstance;
193
- }
194
-
195
- const rootInstances = [];
196
- // 创建实例映射
197
- if(!isFlatNode){
198
- const instanceMap = new Map();
199
- node.forEach(instance => {
200
- instanceMap.set(instance.id, instance);
201
- });
202
-
203
- // 处理根实例
204
- instanceMap.forEach(instance => {
205
- let isRoot = true;
206
- instanceMap.forEach(otherInstance => {
207
- if (otherInstance.children && otherInstance.children.includes(instance.id)) {
208
- isRoot = false;
209
- }
210
- });
211
- if (isRoot) {
212
- const processed = processInstance(instance, instance._batchId, instanceMap);
213
- rootInstances.push(processed);
214
- }
215
- });
216
- }else{
217
- // 处理根实例
218
- node.forEach(instance => {
219
- const processed = processInstance(instance, instance._batchId, {}, 0, isFlatNode);
220
- rootInstances.push(processed);
221
- });
222
- }
223
- return rootInstances
224
- }
225
- // 生成默认node节点
226
- function generateNode(mesh) {
227
- let nodes = [];
228
- mesh.forEach(item => {
229
- if (item.primitives.length) {
230
- let tempNode = {
231
- id: item.id,
232
- _batchId: item.id,
233
- name: item.id,
234
- mesh: item.id,
235
- matrix: {},
236
- nodeType: 3,
237
- };
238
- nodes.push(tempNode);
239
- }
240
- });
241
-
242
- return nodes;
243
- }
244
-
245
- export { parseData, parseNode, processMeshData, processNodeData };
1
+ import * as THREE from 'three';
2
+
3
+ const NODE_TYPES = {
4
+ pbsGrp: 1,
5
+ major: 2,
6
+ model: 3,
7
+ };
8
+
9
+ // 处理mesh数据,生成drawObjs
10
+ function processMeshData(input, options) {
11
+ const drawObjMap = new Map();
12
+
13
+ if (!input.mesh) {
14
+ return [];
15
+ }
16
+
17
+ const mergeMaterialByMeshId = new Map();
18
+ const mergeMaterialList = input.mergeMaterial;
19
+ if (Array.isArray(mergeMaterialList)) {
20
+ for (let i = 0; i < mergeMaterialList.length; i++) {
21
+ const it = mergeMaterialList[i];
22
+ if (!it || it.id == null) continue;
23
+ mergeMaterialByMeshId.set(String(it.id), it);
24
+ }
25
+ }
26
+
27
+ input.mesh.forEach(meshItem => {
28
+ const geomList = [];
29
+ meshItem.primitives.forEach(primitive => {
30
+ const primitiveData = input.primitive.find(g => g.id === primitive.prmid);
31
+ if (primitiveData) {
32
+ const baseMaterial = input.material?.find(m => m.id === primitiveData.material);
33
+ const mergedMaterial = mergeMaterialByMeshId.get(String(meshItem.id));
34
+ const material = mergedMaterial || baseMaterial;
35
+ const prop = {
36
+ color: material?.color || [255, 255, 255, 1],
37
+ fontsize: material?.fontsize !== undefined ? material?.fontsize : 20,
38
+ frontname: material?.frontname !== undefined ? material?.frontname : '',
39
+ italic: material?.italic,
40
+ linepacing: 1, // 默认值
41
+ linewidth: material?.linewidth !== undefined ? material?.linewidth : 1, // 默认值
42
+ visible: material?.visible === false ? false : true,
43
+ transparent: material?.transp !== undefined ? material?.transp : 0,
44
+ };
45
+
46
+ const identity = new THREE.Matrix4().identity();
47
+
48
+ geomList.push({
49
+ matrix: {
50
+ val: primitive.matrix?.length ? primitive.matrix : identity.elements,
51
+ // val: identity.elements,
52
+ },
53
+ // originMatrix: meshItem.id == primitive.prmid ? [] : identity.elements,
54
+ prmid: primitive.prmid,
55
+ geomId: primitiveData.id,
56
+ type: primitiveData.geomType,
57
+ text: primitiveData.geomText,
58
+ points: primitiveData.position,
59
+ alignType: primitiveData.alignType,
60
+ normals: primitiveData.normal,
61
+ triangles: primitiveData.indices || [],
62
+ max: primitiveData.max,
63
+ min: primitiveData.min,
64
+ prop: prop,
65
+ });
66
+ }
67
+ });
68
+
69
+ drawObjMap.set(meshItem.id, {
70
+ drawObjId: meshItem.id,
71
+ geoms: geomList,
72
+ // lodLevel: meshItem.type || 2,
73
+ });
74
+ });
75
+
76
+ return Array.from(drawObjMap.values());
77
+ }
78
+
79
+ // 处理node数据,生成instances
80
+ function processNodeData(input, options) {
81
+ const flatNode = options?.flatNode;
82
+
83
+ function flattenAndComputeWorldMatrices(
84
+ nodes,
85
+ result = [],
86
+ // parentWorldMatrix = null,
87
+ fatherId = ''
88
+ ) {
89
+ for (const node of nodes) {
90
+ const { category, instanceId, matrix, children, drawObject, groupId, nodeType } = node;
91
+
92
+ // 构造本地矩阵
93
+ let localMatrix;
94
+ if (matrix && matrix.val) {
95
+ localMatrix = new THREE.Matrix4().fromArray(matrix.val);
96
+ } else {
97
+ localMatrix = new THREE.Matrix4().identity(); // 默认为单位矩阵
98
+ }
99
+
100
+ // 计算世界矩阵
101
+ // const worldMatrix = parentWorldMatrix
102
+ // ? parentWorldMatrix.clone().multiply(localMatrix)
103
+ // : localMatrix.clone();
104
+ const worldMatrix = localMatrix.clone();
105
+
106
+ // 构造输出节点
107
+ result.push({
108
+ drawObject,
109
+ category,
110
+ instanceId,
111
+ // matrix,
112
+ matrix: {
113
+ val: Array.from(worldMatrix.toArray()),
114
+ },
115
+ fatherId,
116
+ groupId,
117
+ nodeType,
118
+ });
119
+
120
+ // 递归处理子节点,传递当前世界矩阵
121
+ if (children) {
122
+ flattenAndComputeWorldMatrices(children, result, instanceId);
123
+ }
124
+ }
125
+
126
+ return result;
127
+ }
128
+
129
+ if (!flatNode) {
130
+ const formatInstances = [];
131
+ const preNode = input.node ? input.node : generateNode(input.mesh);
132
+ const rootInstances = parseNode(preNode);
133
+ flattenAndComputeWorldMatrices(rootInstances, formatInstances);
134
+
135
+ return formatInstances;
136
+ } else {
137
+ return parseNode(input.node, flatNode);
138
+ }
139
+ }
140
+
141
+ // 处理一个primitive,生成多个drawObj
142
+ function processOnePrimtiveToMultiMesh(primitive) {
143
+ return {
144
+ instanceId: primitive.drawObjId, // 实例与drawObj一对多关系
145
+ drawObject: primitive.geoms[0]?.prmid || '',
146
+ matrix: primitive.geoms[0]?.matrix || [],
147
+ };
148
+ }
149
+
150
+ // 主解析函数,整合两个独立模块的结果
151
+ function parseData(input, options) {
152
+ const drawObjs = processMeshData(input, options);
153
+ const instances = drawObjs.map(item => {
154
+ return processOnePrimtiveToMultiMesh(item); // 实例与drawObj一对多关系
155
+ });
156
+ // const instances = drawObjs.map((item) => {
157
+ // return {
158
+ // instanceId: item.drawObjId, // 实例与drawObj一对一关系
159
+ // drawObject: item.drawObjId,
160
+ // }
161
+ // })
162
+ // const instances = processNodeData(input);
163
+
164
+ const map = {
165
+ drawObjs,
166
+ instances,
167
+ };
168
+ // console.log('parseData', map);
169
+ return map;
170
+ }
171
+
172
+ // 递归处理节点实例
173
+ function parseNode(node, isFlatNode) {
174
+ function processInstance(instance, parentInstanceId, instanceMap, groupId, isFlatNode) {
175
+ const newInstance = {
176
+ category: instance.category || instance.name,
177
+ drawObject: instance.drawObject || instance.mesh,
178
+ fatherId: parentInstanceId || '',
179
+ instanceId: instance.id || instance.batchId,
180
+ matrix: instance.matrix,
181
+ children: [],
182
+ nodeType: instance.nodeType,
183
+ groupId: instance.nodeType === NODE_TYPES.pbsGrp ? instance._batchId : groupId,
184
+ };
185
+
186
+ if (!isFlatNode) {
187
+ // 处理子实例
188
+ if (instance.children && instance.children.length > 0) {
189
+ instance.children.forEach(childId => {
190
+ const childInstance = instanceMap.get(childId);
191
+ if (childInstance) {
192
+ const processedChild = processInstance(
193
+ childInstance,
194
+ instance._batchId,
195
+ instanceMap,
196
+ newInstance.groupId
197
+ );
198
+ newInstance.children.push(processedChild);
199
+ }
200
+ });
201
+ }
202
+ }
203
+
204
+ return newInstance;
205
+ }
206
+
207
+ const rootInstances = [];
208
+ // 创建实例映射
209
+ if (!isFlatNode) {
210
+ const instanceMap = new Map();
211
+ node.forEach(instance => {
212
+ instanceMap.set(instance.id, instance);
213
+ });
214
+
215
+ // 处理根实例
216
+ instanceMap.forEach(instance => {
217
+ let isRoot = true;
218
+ instanceMap.forEach(otherInstance => {
219
+ if (otherInstance.children && otherInstance.children.includes(instance.id)) {
220
+ isRoot = false;
221
+ }
222
+ });
223
+ if (isRoot) {
224
+ const processed = processInstance(instance, instance._batchId, instanceMap);
225
+ rootInstances.push(processed);
226
+ }
227
+ });
228
+ } else {
229
+ // 处理根实例
230
+ node.forEach(instance => {
231
+ const processed = processInstance(instance, instance._batchId, {}, 0, isFlatNode);
232
+ rootInstances.push(processed);
233
+ });
234
+ }
235
+ return rootInstances;
236
+ }
237
+ // 生成默认node节点
238
+ function generateNode(mesh) {
239
+ let nodes = [];
240
+ mesh.forEach(item => {
241
+ if (item.primitives.length) {
242
+ let tempNode = {
243
+ id: item.id,
244
+ _batchId: item.id,
245
+ name: item.id,
246
+ mesh: item.id,
247
+ matrix: {},
248
+ nodeType: 3,
249
+ };
250
+ nodes.push(tempNode);
251
+ }
252
+ });
253
+
254
+ return nodes;
255
+ }
256
+
257
+ export { parseData, parseNode, processMeshData, processNodeData };
@@ -184,8 +184,7 @@ async function handleInstancedMeshModel(
184
184
  meshNameConfig,
185
185
  customOpacity,
186
186
  options = {}
187
- )
188
- {
187
+ ) {
189
188
  // const getObjectByName = (name, passType = 'group') => {
190
189
  // if (!scene) return [];
191
190
  // const object = [];
@@ -282,7 +281,7 @@ async function handleInstancedMeshModel(
282
281
  if (group) {
283
282
  // console.log('add(group)')
284
283
  modelGroup.add(group);
285
- if(immediateUpdate){
284
+ if (immediateUpdate) {
286
285
  // 立即更新矩阵世界,确保位置正确
287
286
  group.updateMatrixWorld(true);
288
287
  }
@@ -355,12 +354,12 @@ function createInstancedGroup(
355
354
  // }
356
355
  // customColor 是原本初始化整个模型颜色的 这里暂时放弃
357
356
  // (mesh, instance.drawObject, instanceCount, customColor, customOpacity
358
- let color = options.colorConfig.get(instance.instanceId)
359
-
357
+ let color = options.colorConfig.get(instance.instanceId);
358
+
360
359
  const model = drawModel(mesh, instance.drawObject, instanceCount, color, customOpacity, {
361
360
  // lodLevel: drawObj.lodLevel || 2,
362
361
  activeInstanceCount,
363
- ...options
362
+ ...options,
364
363
  });
365
364
 
366
365
  if (!model) {
@@ -752,7 +751,6 @@ function draw3Dmodel(
752
751
  ) {
753
752
  // const { lodLevel } = options;
754
753
 
755
-
756
754
  // 解构几何数据中的自定义几何体和材质
757
755
  const {
758
756
  geometry: customGeometry,
@@ -875,9 +873,9 @@ function draw3Dmodel(
875
873
  // geometry.setAttribute('normal', new THREE.BufferAttribute(normal, 3));
876
874
  // }
877
875
  // }
878
-
876
+
879
877
  // triangle int16Array 索引时,需要转换为 uint16Array
880
- if(!customGeometry){
878
+ if (!customGeometry) {
881
879
  if (triangles && triangles.length) {
882
880
  geometry.setIndex(triangles instanceof Int16Array ? Array.from(triangles.buffer) : triangles);
883
881
  }
@@ -890,19 +888,19 @@ function draw3Dmodel(
890
888
  geometry.setAttribute('normal', new THREE.BufferAttribute(normal, 3));
891
889
  }
892
890
  }
893
-
891
+
894
892
  const { color, transparent } = prop;
895
893
  let material, mesh, colors, opacity;
896
- if (Array.isArray(color) && color.length) {
897
- colors = color;
898
- opacity = colors[3] || 1;
899
- } else if (typeof color === 'string') {
900
- colors = color.split(',');
901
- opacity = colors[3] || 1;
902
- } else {
903
- colors = [255, 255, 255];
904
- opacity = 1;
905
- }
894
+ if (Array.isArray(color) && color.length) {
895
+ colors = color;
896
+ opacity = colors[3] || 1;
897
+ } else if (typeof color === 'string') {
898
+ colors = color.split(',');
899
+ opacity = colors[3] || 1;
900
+ } else {
901
+ colors = [255, 255, 255];
902
+ opacity = 1;
903
+ }
906
904
 
907
905
  // 处理transparent透明度
908
906
  opacity = 1 - transparent;
@@ -919,7 +917,7 @@ function draw3Dmodel(
919
917
  : new THREE.Color(`rgb(${colors[0]}, ${colors[1]}, ${colors[2]})`),
920
918
  nOpacity: finalOpacity,
921
919
  // 这里记录模型原本的颜色 做颜色配置时 恢复原本的颜色用的
922
- oColor: new THREE.Color(`rgb(${colors[0]}, ${colors[1]}, ${colors[2]})`)
920
+ oColor: new THREE.Color(`rgb(${colors[0]}, ${colors[1]}, ${colors[2]})`),
923
921
  },
924
922
  // side: THREE.DoubleSide,
925
923
  // transparent: true,
@@ -1065,7 +1063,7 @@ function drawText(geom, instanceName, instanceCount, options = {}) {
1065
1063
 
1066
1064
  var loader = new FontLoader();
1067
1065
  var font = loader.parse(helvetikerFont);
1068
- var options = {
1066
+ options = {
1069
1067
  font: font, // 字体格式
1070
1068
  size: fontsize / 2 || 20, // 字体大小 TODO
1071
1069
  height: 1, // 字体深度