fl-web-component 1.4.7 → 1.4.9-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.
- package/README.md +1 -28
- package/dist/fl-web-component.common.1.js +2 -2
- package/dist/fl-web-component.common.1.js.map +1 -1
- package/dist/fl-web-component.common.2.js.map +1 -1
- package/dist/fl-web-component.common.js +77420 -47296
- package/dist/fl-web-component.common.js.map +1 -1
- package/dist/fl-web-component.css +1 -1
- package/package.json +12 -4
- package/packages/components/com-flcanvas/components/entityFormatting.js +9 -1
- package/packages/components/com-graphics/box.json +77 -0
- package/packages/components/com-graphics/component/ann-tool.vue +465 -0
- package/packages/components/com-graphics/index copy.vue +1679 -0
- package/packages/components/com-graphics/index.vue +3890 -301
- package/packages/components/com-graphics/pid.vue +210 -44
- package/packages/components/com-graphics/test.html +127 -0
- package/packages/components/com-tiles/index.vue +187 -0
- package/packages/utils/StreamLoader.js +1498 -0
- package/packages/utils/StreamLoaderParser.worker.js +595 -0
- package/patches/camera-controls+2.9.0.patch +63 -63
- package/src/main.js +9 -1
- package/src/static/ann-img/mark_circle@2x.png +0 -0
- package/src/static/ann-img/mark_clear@2x.png +0 -0
- package/src/static/ann-img/mark_cloud@2x.png +0 -0
- package/src/static/ann-img/mark_color@2x.png +0 -0
- package/src/static/ann-img/mark_eraser@2x.png +0 -0
- package/src/static/ann-img/mark_exit@2x.png +0 -0
- package/src/static/ann-img/mark_finish@2x.png +0 -0
- package/src/static/ann-img/mark_font@2x.png +0 -0
- package/src/static/ann-img/mark_polyline@2x.png +0 -0
- package/src/static/ann-img/mark_rectangle@2x.png +0 -0
- package/src/static/ann-img/mark_zoomin@2x.png +0 -0
- package/src/static/ann-img/mark_zoomout@2x.png +0 -0
- package/src/utils/cloud.js +110 -0
- package/src/utils/cursor.js +10 -0
- package/src/utils/flgltf-parser.js +245 -193
- package/src/utils/instance-parser.js +718 -170
- package/dist/fl-web-component.common.3.js +0 -7740
- package/dist/fl-web-component.common.3.js.map +0 -1
|
@@ -1,193 +1,245 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
|
|
3
|
-
const NODE_TYPES = {
|
|
4
|
-
pbsGrp: 1,
|
|
5
|
-
major: 2,
|
|
6
|
-
model: 3,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
//
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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 };
|