fl-web-component 1.2.2 → 1.2.4

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.
@@ -1 +1 @@
1
- @charset "UTF-8";#fl-model[data-v-3d926f5d],#konva-container[data-v-2733ad2c]{width:100%;height:100%;cursor:pointer}#konva-container[data-v-2733ad2c]{z-index:3;overflow:hidden}span[data-v-f547d5c6]{font-weight:bolder}.text[data-v-f547d5c6]{margin-top:20px}.line[data-v-f547d5c6]{border-bottom:1px solid #dcdfe6;margin:20px 0}.center[data-v-f547d5c6]{display:flex;flex-direction:column;align-items:center}.center .cen span[data-v-f547d5c6],.center .top span[data-v-f547d5c6]{color:"#53a8ff";display:inline-block;width:30px;height:30px;text-align:center;line-height:30px;border:1px solid;padding:5px;margin-bottom:10px;background-color:#e9f3ff}.center .cen span[data-v-f547d5c6]{margin:10px}.button[data-v-f547d5c6]{display:flex;justify-content:end;margin-top:20px}@font-face{font-family:iconfont;src:url(//at.alicdn.com/t/font_3226805_qqvo3ag3r8.woff2?t=1646635700216) format("woff2"),url(//at.alicdn.com/t/font_3226805_qqvo3ag3r8.woff?t=1646635700216) format("woff"),url(//at.alicdn.com/t/font_3226805_qqvo3ag3r8.ttf?t=1646635700216) format("truetype")}.iconfont[data-v-f547d5c6]{font-family:iconfont!important;font-size:50px;font-style:normal;color:"#53a8ff";-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-shubiao[data-v-f547d5c6]:before{content:""}#svg-tigger[data-v-09d5c9d8]{cursor:pointer;height:100%;width:100%}
1
+ @charset "UTF-8";#fl-model[data-v-581c5bb4],#konva-container[data-v-1eba8e28]{width:100%;height:100%;cursor:pointer}#konva-container[data-v-1eba8e28]{z-index:3;overflow:hidden}span[data-v-f547d5c6]{font-weight:bolder}.text[data-v-f547d5c6]{margin-top:20px}.line[data-v-f547d5c6]{border-bottom:1px solid #dcdfe6;margin:20px 0}.center[data-v-f547d5c6]{display:flex;flex-direction:column;align-items:center}.center .cen span[data-v-f547d5c6],.center .top span[data-v-f547d5c6]{color:"#53a8ff";display:inline-block;width:30px;height:30px;text-align:center;line-height:30px;border:1px solid;padding:5px;margin-bottom:10px;background-color:#e9f3ff}.center .cen span[data-v-f547d5c6]{margin:10px}.button[data-v-f547d5c6]{display:flex;justify-content:end;margin-top:20px}@font-face{font-family:iconfont;src:url(//at.alicdn.com/t/font_3226805_qqvo3ag3r8.woff2?t=1646635700216) format("woff2"),url(//at.alicdn.com/t/font_3226805_qqvo3ag3r8.woff?t=1646635700216) format("woff"),url(//at.alicdn.com/t/font_3226805_qqvo3ag3r8.ttf?t=1646635700216) format("truetype")}.iconfont[data-v-f547d5c6]{font-family:iconfont!important;font-size:50px;font-style:normal;color:"#53a8ff";-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-shubiao[data-v-f547d5c6]:before{content:""}#svg-tigger[data-v-0ec35ee4]{cursor:pointer;height:100%;width:100%}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fl-web-component",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "scripts": {
5
5
  "tip1": "仅调试本组件不涉及业务组件,请执行dev",
6
6
  "dev": "vue-cli-service serve",
@@ -11,7 +11,7 @@
11
11
  "build": "npm run lint && vue-cli-service build --target lib --name fl-web-component --formats commonjs ./src/main.js",
12
12
  "build:test": "vue-cli-service build --target lib --name fl-web-component --formats commonjs ./src/main.js",
13
13
  "publish:base": "npm run build && npm publish",
14
- "tip3": "发版注意: 小版本执行publish:fix,中版本执行publish:feat,大版本执行publish:perf",
14
+ "tip3": "发版注意: 【修改bug执行publish:fix】【新增功能执行publish:feat】【新特性执行publish:perf",
15
15
  "publish:fix": "npm version patch && npm run publish:base",
16
16
  "publish:feat": "npm version minor && npm run publish:base",
17
17
  "publish:perf": "npm version major && npm run publish:base"
@@ -67,6 +67,8 @@ export function centering(obj, container, konvaStage, scaleBy) {
67
67
  } else if (target[0].className === "Line") {
68
68
  const p = getAbsolutePoints(target[0].getPoints());
69
69
  computedCenter(p.x, p.y, container, konvaStage, scaleBy)
70
+ } else {
71
+ computedCenter(target[0].px, target[0].py, container, konvaStage, scaleBy)
70
72
  }
71
73
  }
72
74
  } else {
@@ -76,6 +78,8 @@ export function centering(obj, container, konvaStage, scaleBy) {
76
78
  } else if (target[0].className === "Line") {
77
79
  const p = getAbsolutePoints(target[0].getPoints());
78
80
  computedCenter(p.x, p.y, container, konvaStage, scaleBy)
81
+ } else {
82
+ computedCenter(target[0].px, target[0].py, container, konvaStage, scaleBy)
79
83
  }
80
84
  }
81
85
  }
@@ -212,6 +212,8 @@ var preTarget = [];
212
212
  context.moveTo(x1, -parseFloat(y1));
213
213
  context.lineTo(x2, -parseFloat(y2));
214
214
  }
215
+ shape.px = entity.x1
216
+ shape.py = -entity.y1
215
217
  }
216
218
  if (entity.type === 'polyline') {
217
219
  let flag = false;
@@ -237,6 +239,8 @@ var preTarget = [];
237
239
  }
238
240
  }
239
241
  }
242
+ shape.px = points[0]
243
+ shape.py = points[1]
240
244
  }
241
245
  }
242
246
  // context.closePath();
@@ -273,7 +277,9 @@ var preTarget = [];
273
277
  // });
274
278
  konvaStage.setX(x);
275
279
  konvaStage.setY(y); // 750
276
- this.$emit('loaded')
280
+ setTimeout(() => {
281
+ this.$emit('loaded')
282
+ }, 100)
277
283
  },
278
284
  toPdf(name) {
279
285
  // get data URL with default settings
@@ -26,6 +26,7 @@
26
26
  outlineComposer,
27
27
  renderTarget,
28
28
  sceneClock,
29
+ mat4
29
30
  ] = (function* (v) {
30
31
  while (true) yield v;
31
32
  })(null);
@@ -100,6 +101,8 @@
100
101
  },
101
102
  created() {
102
103
  CameraControls.install({ THREE: this.THREE });
104
+ mat4 = new this.THREE.Matrix4();
105
+ mat4.makeRotationX(-Math.PI / 2);
103
106
  fpsClock = new this.THREE.Clock();
104
107
  raycaster = new this.THREE.Raycaster();
105
108
  sceneClock = new this.THREE.Clock();
@@ -228,9 +231,8 @@
228
231
  .multiplyScalar(0.5);
229
232
  scene.add(modelGroup);
230
233
  // 适配客户端的坐标系,threejs坐标需绕x轴旋转90度
231
- const mat4 = new this.THREE.Matrix4();
232
- mat4.makeRotationX(-Math.PI / 2);
233
234
  modelGroup.applyMatrix4(mat4);
235
+ modelGroup.updateMatrixWorld();
234
236
  modelGroup.traverse(child => {
235
237
  if (child.isMesh) {
236
238
  const json = this.getMeshCenterAndVolume(child);
@@ -519,10 +521,9 @@
519
521
  if (obj.isGroup) {
520
522
  this.setModelCenter(obj);
521
523
  } else if (obj.isMesh) {
522
- let box = this.getSize(obj)
523
- let center = this.getCenter(obj)
524
- this.locateByCenterBox(center, box)
525
- // this.setModelCenter(obj.parent);
524
+ let center = this.getCenter(obj);
525
+ let size = this.getSize(obj);
526
+ this.locateByCenterBox(center, size)
526
527
  }
527
528
  }
528
529
  },
@@ -587,9 +588,17 @@
587
588
  center: {x: 0, y: 0, z: 0},
588
589
  box: {x: 0, y: 0, z: 0}
589
590
  */
590
- locateByCenterBox(center, box) {
591
- let cameraCenter = new this.THREE.Vector3(center.x, center.y, center.z).addScalar(
592
- Math.max(box.x, box.y, box.z)
591
+ locateByCenterBox(center, size) {
592
+ let maxDim = Math.max(size.x, size.y, size.z);
593
+ let fov = camera.fov * (Math.PI / 180);
594
+ let distance = Math.min(
595
+ maxDim * 100, // 最大距离限制
596
+ Math.abs((maxDim * 1.0) / Math.sin(fov / 2))
597
+ );
598
+ let direction = new this.THREE.Vector3(1, 1, 1).normalize();
599
+ let p = (new this.THREE.Vector3().copy(center)).add(direction.multiplyScalar(distance));
600
+ let cameraCenter = new this.THREE.Vector3(p.x, p.y, p.z).addScalar(
601
+ Math.max(size.x, size.y, size.z)
593
602
  );
594
603
  cameraControls.setLookAt(
595
604
  cameraCenter.x,
@@ -614,10 +623,6 @@
614
623
  const divLabel = new CSS2DObject(data.billboard);
615
624
  divLabel.name = data.labelClass; // 这个是用来清除广告牌用的
616
625
  divLabel.position.set(data.x, data.y, data.z);
617
- // 由于场景做了翻转 所以要把它翻转回来
618
- // const mat4 = new this.THREE.Matrix4();
619
- // mat4.makeRotationX(Math.PI / 2);
620
- // divLabel.applyMatrix4(mat4);
621
626
  scene.add(divLabel);
622
627
  return divLabel;
623
628
  },
@@ -1426,8 +1431,6 @@
1426
1431
  let center = new this.THREE.Vector3();
1427
1432
  obj.boundingBox.getCenter(center);
1428
1433
  if (obj.userData.is3D) {
1429
- const mat4 = new this.THREE.Matrix4();
1430
- mat4.makeRotationX(-Math.PI / 2);
1431
1434
  center.applyMatrix4(mat4)
1432
1435
  }
1433
1436
  return center;
@@ -1436,8 +1439,6 @@
1436
1439
  let size = new this.THREE.Vector3();
1437
1440
  obj.boundingBox.getSize(size);
1438
1441
  if (obj.userData.is3D) {
1439
- const mat4 = new this.THREE.Matrix4();
1440
- mat4.makeRotationX(-Math.PI / 2);
1441
1442
  size.applyMatrix4(mat4)
1442
1443
  }
1443
1444
  return size;
@@ -111,7 +111,6 @@
111
111
  参数:svgIds: [], 需要高亮的id的集合, flag: true / false, 是否要定位目标元素, color: '', 高亮的颜色
112
112
  */
113
113
  highLight(svgIds, flag = false, color) {
114
- console.log(svgIds)
115
114
  if (svgIds === null || svgIds === undefined) {
116
115
  throw new Error('svgIds should be an array');
117
116
  } else {
@@ -112,6 +112,10 @@ function parseData(input) {
112
112
  };
113
113
 
114
114
  geomList.push({
115
+ matrix: {
116
+ val: primitive.matrix,
117
+ },
118
+ prmid: primitive.prmid,
115
119
  geomId: primitiveData.id,
116
120
  type: primitiveData.geomType,
117
121
  text: primitiveData.geomText,
@@ -138,7 +142,7 @@ function parseData(input) {
138
142
  drawObjs: Array.from(drawObjMap.values()),
139
143
  instances: formatInstances,
140
144
  };
141
- // console.log('parseData', map);
145
+ console.log('parseData', map);
142
146
  return map;
143
147
  }
144
148
 
@@ -86,13 +86,18 @@ function handleInstancedMeshModel(
86
86
  if (item.instanceId == instances[i].instanceId) {
87
87
  model.userData.instanceIndex = index;
88
88
  model.userData.instanceId = instances[i].instanceId;
89
+ model.userData.primId = mesh.prmid;
89
90
  model.name =
90
91
  meshName !== '' ? instances[i].instanceId + meshName : instances[i].instanceId;
91
92
  const matrixVal = item.matrix?.val;
92
93
  if (matrixVal) {
93
94
  const m4 = new THREE.Matrix4();
95
+ const meshMatrix = new THREE.Matrix4();
96
+ const geomMatrix = new THREE.Matrix4();
94
97
  // m4.setPosition(new THREE.Vector3(9999999, 9999999, 9999999)); // TODO 临时隐藏方案
95
- m4.elements = item.matrix.val;
98
+ meshMatrix.elements = item.matrix.val;
99
+ geomMatrix.elements = mesh.matrix.val;
100
+ m4.multiplyMatrices(meshMatrix, geomMatrix);
96
101
  model.setMatrixAt(index, m4);
97
102
  const copyMatrix = new THREE.Matrix4().copy(m4);
98
103
  model.userData.copyMatrix = copyMatrix;
@@ -112,8 +117,8 @@ function handleInstancedMeshModel(
112
117
  }
113
118
  }
114
119
  }
115
- // console.log('modelGroup', modelGroup);
116
- // console.log('drawObjMapInstance', drawObjMapInstance);
120
+ console.log('modelGroup', modelGroup);
121
+ console.log('drawObjMapInstance', drawObjMapInstance);
117
122
  return modelGroup;
118
123
  // timeRender();
119
124
  // console.log('scene', scene)
@@ -318,8 +323,9 @@ function draw3Dmodel(geom, instanceName, instanceCount, nColor, nOpacity) {
318
323
  material = customMaterial ||
319
324
  new THREE.MeshStandardMaterial({
320
325
  ...materialOptions,
321
- roughness: 0.8,
322
- envMapIntensity: 0.5, // 调低环境贴图的强度
326
+ roughness: 0.6,
327
+ metalness: 0.5,
328
+ envMapIntensity: 1, // 调低环境贴图的强度
323
329
  // wireframe: true
324
330
  });
325
331