fl-web-component 1.0.5 → 1.0.7
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/fl-web-component.common.js +480 -56
- package/dist/fl-web-component.css +1 -1
- package/dist/fl-web-component.umd.js +480 -56
- package/dist/fl-web-component.umd.min.js +29 -24
- package/package.json +1 -1
- package/packages/components/com-graphics/index.vue +30 -28
- package/src/main.js +2 -0
- package/src/utils/flgltf-parser.js +4 -2
- package/src/utils/instance-parser.js +2 -1
- package/src/utils/mock.js +84498 -84498
package/package.json
CHANGED
|
@@ -175,8 +175,9 @@
|
|
|
175
175
|
modelGroup = handleInstancedMeshModel(instances, drawObjs, '', scene, color);
|
|
176
176
|
scene.add(modelGroup);
|
|
177
177
|
// this.compileShader();
|
|
178
|
-
cameraControls.fitToSphere(
|
|
179
|
-
|
|
178
|
+
// cameraControls.fitToSphere(scene, true); // TODO 待处理,先用 setModelCenter 进行定位
|
|
179
|
+
this.setModelCenter(modelGroup);
|
|
180
|
+
// cameraControls.saveState();
|
|
180
181
|
}
|
|
181
182
|
},
|
|
182
183
|
compileShader() {
|
|
@@ -229,7 +230,7 @@
|
|
|
229
230
|
mouse.y = -(event.clientY / instructions.offsetHeight) * 2 + 1;
|
|
230
231
|
raycaster.setFromCamera(mouse, camera);
|
|
231
232
|
const intersects = raycaster.intersectObjects(scene.children, true);
|
|
232
|
-
let params = {}
|
|
233
|
+
let params = {};
|
|
233
234
|
let cameraData = {
|
|
234
235
|
position: {
|
|
235
236
|
x: cameraControls.camera.position.x,
|
|
@@ -251,8 +252,8 @@
|
|
|
251
252
|
x: intersects[0].point.x,
|
|
252
253
|
y: intersects[0].point.y,
|
|
253
254
|
z: intersects[0].point.z,
|
|
254
|
-
}
|
|
255
|
-
}
|
|
255
|
+
},
|
|
256
|
+
};
|
|
256
257
|
} else {
|
|
257
258
|
params = {
|
|
258
259
|
objects: [],
|
|
@@ -262,8 +263,8 @@
|
|
|
262
263
|
x: -1,
|
|
263
264
|
y: -1,
|
|
264
265
|
z: -1,
|
|
265
|
-
}
|
|
266
|
-
}
|
|
266
|
+
},
|
|
267
|
+
};
|
|
267
268
|
}
|
|
268
269
|
if (event.button === 0) {
|
|
269
270
|
this.$emit('leftClick', params);
|
|
@@ -287,26 +288,26 @@
|
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
},
|
|
290
|
-
setModelCenter() {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
291
|
+
setModelCenter(mesh) {
|
|
292
|
+
const box3 = new this.THREE.Box3();
|
|
293
|
+
box3.setFromObject(mesh);
|
|
294
|
+
const center = new this.THREE.Vector3();
|
|
295
|
+
box3.getCenter(center);
|
|
296
|
+
const size = box3.getSize(new this.THREE.Vector3());
|
|
297
|
+
camera.position.set(center.x, center.y + size.y, center.z + size.z / 2);
|
|
298
|
+
camera.lookAt(new this.THREE.Vector3(center.x, center.y, center.z));
|
|
299
|
+
cameraControls.setLookAt(
|
|
300
|
+
center.x,
|
|
301
|
+
center.y + size.y,
|
|
302
|
+
center.z + size.z / 2,
|
|
303
|
+
center.x,
|
|
304
|
+
center.y,
|
|
305
|
+
center.z,
|
|
306
|
+
true
|
|
307
|
+
);
|
|
308
|
+
cameraControls.update(0);
|
|
309
|
+
camera.updateProjectionMatrix();
|
|
310
|
+
cameraControls.saveState();
|
|
310
311
|
},
|
|
311
312
|
// 修改指定模型实体属性
|
|
312
313
|
/**
|
|
@@ -415,7 +416,8 @@
|
|
|
415
416
|
locateModel(id) {
|
|
416
417
|
let obj = scene.getObjectByName(id);
|
|
417
418
|
if (obj) {
|
|
418
|
-
cameraControls.fitToSphere(obj.parent, true);
|
|
419
|
+
// cameraControls.fitToSphere(obj.parent, true); // TODO 待处理,先用 setModelCenter 进行定位
|
|
420
|
+
this.setModelCenter(obj.parent);
|
|
419
421
|
// cameraControls.fitToBox( obj, true);
|
|
420
422
|
}
|
|
421
423
|
},
|
package/src/main.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import FlModel from '../packages/components/com-graphics/index.vue';
|
|
2
2
|
import Fl2dcanvas from '../packages/components/com-flcanvas/index.vue';
|
|
3
|
+
import * as THREE from 'three';
|
|
3
4
|
const components = [
|
|
4
5
|
FlModel,
|
|
5
6
|
Fl2dcanvas
|
|
6
7
|
];
|
|
7
8
|
|
|
8
9
|
const install = (Vue) => {
|
|
10
|
+
Vue.prototype.THREE = THREE
|
|
9
11
|
components.forEach(component => {
|
|
10
12
|
Vue.component(component.name, component);
|
|
11
13
|
});
|
|
@@ -132,10 +132,12 @@ function parseData(input) {
|
|
|
132
132
|
const formatInstances = [];
|
|
133
133
|
flattenAndComputeWorldMatrices(rootInstances, formatInstances);
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
const map = {
|
|
136
136
|
drawObjs: Array.from(drawObjMap.values()),
|
|
137
137
|
instances: formatInstances,
|
|
138
|
-
}
|
|
138
|
+
}
|
|
139
|
+
console.log('parseData', map)
|
|
140
|
+
return map;
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
export { parseData };
|
|
@@ -31,7 +31,7 @@ function handleInstancedMeshModel(instances, drawObjs, type, scene, customColor)
|
|
|
31
31
|
for (let i = 0; i < instances.length; i++) {
|
|
32
32
|
formatInstancedMap(instances[i], drawObjs);
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
console.log('drawObjMapInstance', drawObjMapInstance)
|
|
35
35
|
// 第二阶段:遍历所有实例进行处理
|
|
36
36
|
for (let i = 0; i < instances.length; i++) {
|
|
37
37
|
let targetGroup, instancedMeshIndex, drawObjectName;
|
|
@@ -93,6 +93,7 @@ function handleInstancedMeshModel(instances, drawObjs, type, scene, customColor)
|
|
|
93
93
|
modelGroup.add(group);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
console.log('modelGroup', modelGroup)
|
|
96
97
|
return modelGroup;
|
|
97
98
|
// timeRender();
|
|
98
99
|
// console.log('scene', scene)
|