emacroh5lib 1.0.81 → 1.0.84

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/ob.rar ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emacroh5lib",
3
- "version": "1.0.81",
3
+ "version": "1.0.84",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
File without changes
@@ -1,7 +1,9 @@
1
1
  <template>
2
2
  <div class="duo-viewer" v-if="show" ref="duoViewer" @click="clickAgent">
3
3
  <div class="duo-viewer-mask">
4
- <div id="WebGL-output" class="duo-viewer-mask__image" :style="viewerStyle()">
4
+ <div id="WebGL-output" class="duo-viewer-mask__image" :style="viewerStyle()" v-loading="loading"
5
+ element-loading-text="模型加载中" element-loading-spinner="el-icon-loading"
6
+ element-loading-background="rgba(0, 0, 0, 0.8)">
5
7
  </div>
6
8
  </div>
7
9
  <div class="duo-viewer-footer" v-if="showThumbnail">
@@ -57,7 +59,7 @@
57
59
  import { AsciiEffect } from "three/examples/jsm/effects/AsciiEffect.js";
58
60
  import { BufferGeometryUtils } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
59
61
 
60
- import { Message } from 'element-ui'
62
+ import { Message, MessageBox } from 'element-ui'
61
63
 
62
64
  // import TWEEN from "@tweenjs/tween.js";
63
65
  // import Stats from "stats.js";
@@ -73,6 +75,7 @@
73
75
  index: 0,
74
76
  imgUrl: "",
75
77
  isCreatePoster: false,
78
+ loading: true,
76
79
  gl: {
77
80
  scene: null,
78
81
  renderer: null,
@@ -125,6 +128,10 @@
125
128
  showThumbnail: {
126
129
  type: Boolean,
127
130
  default: false,
131
+ },
132
+ background: {
133
+ type: Number,
134
+ default: 0xb9d3ff,
128
135
  }
129
136
  },
130
137
  computed: {
@@ -144,6 +151,7 @@
144
151
  watch: {
145
152
  show(val) {
146
153
  if (val) {
154
+ this.loading = true
147
155
  this.$emit("open");
148
156
  this.index = this.currentIndex;
149
157
  this.loadModel(this.currentModel)
@@ -154,6 +162,9 @@
154
162
  },
155
163
  mounted() {
156
164
 
165
+ // this.show = true
166
+
167
+
157
168
 
158
169
  // Message.success("按键提示 ");
159
170
 
@@ -356,15 +367,15 @@
356
367
 
357
368
  // 计算空间两点中点
358
369
  getCenterPosition(A, B) {
359
- let pos = { x: (A.x + B.x) / 2, y: (A.y + B.y) / 2, z: (A.z + B.z) / 2 }
360
- return pos
370
+ if (A.z == null || B.z == null) {
371
+ return { x: (A.x + B.x) / 2, y: (A.y + B.y) / 2 }
372
+ }
373
+ return { x: (A.x + B.x) / 2, y: (A.y + B.y) / 2, z: (A.z + B.z) / 2 }
361
374
  },
362
375
 
363
376
 
364
377
  setObject() {
365
378
 
366
-
367
-
368
379
  const materials = this.gl.materials
369
380
  const geometry = this.gl.geometry
370
381
  const camera = this.gl.camera
@@ -382,12 +393,11 @@
382
393
  let box = new THREE.Box3().setFromObject(geometry);
383
394
  let center = box.getCenter(geometry.position);
384
395
  let size = box.getSize(new THREE.Vector3())
385
-
386
396
  const ratio = Math.abs(200 / size.x);
387
397
  geometry.scale.set(ratio, ratio, ratio);
388
398
 
389
399
 
390
-
400
+ // 设置旋转点
391
401
  const boxHelper = new THREE.BoxHelper(geometry);
392
402
  this.gl.boxHelper = boxHelper
393
403
  boxHelper.geometry.computeBoundingBox()
@@ -397,9 +407,17 @@
397
407
  geometry.position.z += (-centerPoint.z)
398
408
  geometry.position.x += (-centerPoint.x)
399
409
  geometry.position.y += (-centerPoint.y)
400
- this.gl.geometry = pivot
410
+ // this.gl.geometry = pivot
401
411
  scene.add(pivot);
402
412
 
413
+ this.loading = false
414
+
415
+
416
+ const keyEvent = new KeyboardEvent('keydown', {
417
+ bubbles: true, cancelable: true, keyCode: 90
418
+ });
419
+ document.dispatchEvent(keyEvent);
420
+
403
421
 
404
422
 
405
423
 
@@ -630,8 +648,6 @@
630
648
 
631
649
 
632
650
 
633
-
634
-
635
651
  // return
636
652
 
637
653
 
@@ -682,9 +698,6 @@
682
698
  // );
683
699
 
684
700
 
685
-
686
-
687
-
688
701
  // geometry.computeVertexNormals();
689
702
  // geometry.center();
690
703
  // let material = new THREE.MeshPhongMaterial({ color: 0xffff00, shading: THREE.SmoothShading });
@@ -692,23 +705,37 @@
692
705
 
693
706
  // const box = new THREE.BoxHelper(mesh, 0xffff00);
694
707
 
695
- // console.log("尺寸", box);
696
-
697
708
 
698
709
  // var scale = this.computeScale(geometry);
699
710
  // mesh.scale.multiplyScalar(scale);
700
711
  // mesh.position.set(0, 0, 0);
701
712
  // this.gl.scene.add(mesh);
702
-
703
713
  }
704
-
705
-
706
-
707
-
708
-
709
-
714
+ }, progress => {
715
+ }, error => {
716
+ Message({
717
+ message: objPath + '加载出错',
718
+ type: 'error',
719
+ duration: 0,
720
+ showClose: true
721
+ })
722
+
723
+ setTimeout(() => {
724
+ this.show = false
725
+ }, 1000);
726
+ })
727
+ }, progress => {
728
+ }, error => {
729
+ Message({
730
+ message: mtlPath + '加载出错',
731
+ type: 'error',
732
+ duration: 0,
733
+ showClose: true
710
734
  })
711
735
 
736
+ setTimeout(() => {
737
+ this.show = false
738
+ }, 1000);
712
739
  })
713
740
 
714
741
  }
@@ -719,7 +746,7 @@
719
746
 
720
747
  // this.gl.scene.rotateY(45)
721
748
 
722
- let axes = new THREE.AxisHelper(100);
749
+ let axes = new THREE.AxisHelper(20);
723
750
  this.gl.scene.add(axes);
724
751
 
725
752
  //点光源
@@ -735,8 +762,8 @@
735
762
  /**
736
763
  * 相机设置
737
764
  */
738
- let width = window.innerWidth * 0.8; //窗口宽度
739
- let height = window.innerHeight * 0.8; //窗口高度
765
+ let width = window.innerWidth * 0.85; //窗口宽度
766
+ let height = window.innerHeight * 0.85; //窗口高度
740
767
  let k = width / height; //窗口宽高比
741
768
  let s = 300; //三维场景显示范围控制系数,系数越大,显示的范围越大
742
769
  //创建相机对象
@@ -748,7 +775,7 @@
748
775
  */
749
776
  this.gl.renderer = new THREE.WebGLRenderer();
750
777
  this.gl.renderer.setSize(width, height); //设置渲染区域尺寸
751
- this.gl.renderer.setClearColor(0xb9d3ff, 1); //设置背景颜色
778
+ this.gl.renderer.setClearColor(this.background, 1); //设置背景颜色
752
779
 
753
780
  this.gl.WebGLoutput.innerHTML = ""
754
781
  this.gl.renderer.domElement.style.width = "100%"
@@ -835,6 +862,20 @@
835
862
  })
836
863
 
837
864
 
865
+ document.addEventListener("keydown", event => {
866
+
867
+ if (event.key == '') {
868
+ const gl = this.gl
869
+ const zd = gl.camera.position.z !== 0 ? -gl.camera.position.z : -d
870
+ gl.camera.position.set(0, 0, zd);
871
+ gl.camera.lookAt(new THREE.Vector3(0, 0, 0));
872
+ gl.ambient.position.set(0, 0, zd);
873
+ gl.pointLight.position.set(0, 0, zd);
874
+ gl.axialDirection = zd > 0 ? 'z' : '-z';
875
+ }
876
+
877
+ })
878
+
838
879
 
839
880
  document.addEventListener("keyup", event => {
840
881
 
@@ -865,8 +906,6 @@
865
906
  // gl.geometry.rotateX(new THREE.Vector3(1, 0, 0), 90)
866
907
 
867
908
  }
868
-
869
-
870
909
  if (event.key == 'y') {
871
910
 
872
911
  // gl.camera.position.set(0, 0, 0);
@@ -884,7 +923,6 @@
884
923
 
885
924
  gl.axialDirection = yd > 0 ? 'y' : '-y';
886
925
  }
887
-
888
926
  if (event.key == 'z') {
889
927
 
890
928
  const zd = gl.camera.position.z !== 0 ? -gl.camera.position.z : -d
@@ -897,7 +935,6 @@
897
935
 
898
936
  gl.axialDirection = zd > 0 ? 'z' : '-z';
899
937
  }
900
-
901
938
  if (event.key == '=') {
902
939
  gl.pointLight.intensity += 0.2
903
940
  }
@@ -917,12 +954,17 @@
917
954
  // const d = (0 * Math.PI) / 180;
918
955
  // gl.axisHelper.rotation.set(d, 0, 0);
919
956
 
920
- gl.camera.position.set(500, 300, 200); //设置相机位置
921
- gl.camera.lookAt(new THREE.Vector3(0, 0, 0)); //设置相机方向(指向的场景对象)
922
- gl.pointLight.position.set(200, 300, 100); //点光源位置,参数分别代表:
923
- gl.ambient.position.set(200, 300, 100); //点光源位置,参数分别代表:
957
+ // gl.camera.position.set(500, 300, 200); //设置相机位置
958
+ // gl.camera.lookAt(new THREE.Vector3(0, 0, 0)); //设置相机方向(指向的场景对象)
959
+ // gl.pointLight.position.set(200, 300, 100); //点光源位置,参数分别代表:
960
+ // gl.ambient.position.set(200, 300, 100); //点光源位置,参数分别代表:
924
961
 
925
- gl.scene.rotateX(THREE.Math.degToRad(90))
962
+ // gl.scene.rotateX(THREE.Math.degToRad(90))
963
+
964
+ gl.camera.position.set(d, d, d);
965
+ gl.camera.lookAt(new THREE.Vector3(0, 0, 0));
966
+
967
+ gl.axialDirection = 'o'
926
968
  }
927
969
 
928
970
 
@@ -988,6 +1030,8 @@
988
1030
 
989
1031
  if (gl.isRotate) {
990
1032
 
1033
+ // console.log("旋转", event);
1034
+
991
1035
  const x = -(gl.startEvent.offsetX - event.offsetX)
992
1036
  const y = -(gl.startEvent.offsetY - event.offsetY)
993
1037
 
@@ -1034,6 +1078,14 @@
1034
1078
  }
1035
1079
  }
1036
1080
 
1081
+ if (gl.axialDirection == 'o') {
1082
+ if (Math.abs(x) > Math.abs(y)) {
1083
+ gl.geometry.rotateOnWorldAxis(new THREE.Vector3(1, 1, 1), x * 0.001)
1084
+ } else {
1085
+ gl.geometry.rotateOnWorldAxis(new THREE.Vector3(1, 1, 1), y * 0.001)
1086
+ }
1087
+ }
1088
+
1037
1089
  // gl.geometry.rotateX(x * 0.001)
1038
1090
  // gl.geometry.rotateY(y * 0.001)
1039
1091
 
@@ -1094,6 +1146,14 @@
1094
1146
  }
1095
1147
  }
1096
1148
 
1149
+ if (gl.axialDirection == 'o') {
1150
+ if (Math.abs(x) > Math.abs(y)) {
1151
+ gl.geometry.position.set(gl.geometry.position.x + x, gl.geometry.position.y + x, gl.geometry.position.z + x)
1152
+ } else {
1153
+ gl.geometry.position.set(gl.geometry.position.x + y, gl.geometry.position.y + y, gl.geometry.position.z + y)
1154
+ }
1155
+ }
1156
+
1097
1157
  }
1098
1158
 
1099
1159
 
@@ -27,7 +27,7 @@
27
27
  </Draw>
28
28
 
29
29
  <!-- <video-viewer :list="srcList" :show.sync="showVideoViewer" width="80%" height="80%" /> -->
30
- <model-viewer :list="modelList" :show.sync="showModelViewer" width="80%" height="80%" />
30
+ <model-viewer :list="modelList" :show.sync="showModelViewer" width="80%" height="80%" :background="0xff0000" />
31
31
 
32
32
  </div>
33
33
  </template>
@@ -83,8 +83,8 @@
83
83
  name: "产品1",
84
84
  // mtl: "http://www.emacrosys.cn:8019/H5/GetFile?type=0&path=C:\\SOP\\PCB001\\test.mtl",
85
85
  // obj: "http://www.emacrosys.cn:8019/H5/GetFile?type=0&path=C:/SOP/PCB001/test.obj"
86
- mtl: "http://www.emacrosys.cn:8019/H5/GetFile?type=0&path=C:\\SOP\\File\\book\\test4.mtl",
87
- obj: "http://www.emacrosys.cn:8019/H5/GetFile?type=0&path=C:\\SOP\\File\\book\\test4.obj"
86
+ mtl: "http://www.emacrosys.cn:8019/H5/GetFile?type=0&path=C:\\SOP\\File\\book\\test7.mtl",
87
+ obj: "http://www.emacrosys.cn:8019/H5/GetFile?type=0&path=C:\\SOP\\File\\book\\test7.obj"
88
88
  }, {
89
89
  type: "obj",
90
90
  name: "产品2",
@@ -0,0 +1,103 @@
1
+ # WaveFront *.mtl file (generated by Cinema 4D)
2
+
3
+ newmtl default
4
+ Kd 1 1 1
5
+
6
+ newmtl 材质.1
7
+ Ka 1 1 1
8
+ Kd 0.12300000339746 0.12884999811649 0.15000000596046
9
+ Ks 1 1 1
10
+ Ns 50
11
+ illum 7
12
+
13
+ newmtl 材质.10
14
+ Ka 1 1 1
15
+ Kd 0.95999997854233 0.79295998811722 0.12479999661446
16
+ Ks 1 1 1
17
+ Ns 50
18
+ illum 7
19
+
20
+ newmtl 材质.7
21
+ Ka 1 1 1
22
+ Kd 1 1 1
23
+ Ks 1 1 1
24
+ Ns 90
25
+ illum 7
26
+
27
+ newmtl 材质.4
28
+ Ka 1 1 1
29
+ Kd 0.9200000166893 0.9200000166893 0.9200000166893
30
+ Ks 1 1 1
31
+ Ns 4
32
+ illum 7
33
+
34
+ newmtl 材质.2
35
+ Ka 1 1 1
36
+ Kd 0.87000000476837 0.21750000119209 0.21750000119209
37
+ Ks 1 1 1
38
+ Ns 50
39
+ illum 7
40
+
41
+ newmtl 材质.9
42
+ Ka 1 1 1
43
+ Kd 1 1 1
44
+ Ks 0.68000000715256 0.59273332357407 0.30599999427795
45
+ Ns 90
46
+ illum 7
47
+
48
+ newmtl 材质.5
49
+ Ka 1 1 1
50
+ Kd 0.23275999724865 0.200100004673 0.68999999761581
51
+ Ks 1 1 1
52
+ Ns 50
53
+ illum 7
54
+
55
+ newmtl 材质.6
56
+ Ka 1 1 1
57
+ Kd 1 1 1
58
+ Ks 1 1 1
59
+ Ns 50
60
+ illum 7
61
+
62
+ newmtl 材质.8
63
+ Ka 1 1 1
64
+ Kd 0.75999999046326 0.37873333692551 0.22800000011921
65
+ Ks 1 1 1
66
+ Ns 50
67
+ illum 7
68
+
69
+ newmtl 材质
70
+ Ka 1 1 1
71
+ Kd 0.62999999523163 0.62999999523163 0.62999999523163
72
+ Ks 1 1 1
73
+ Ns 50
74
+ illum 7
75
+
76
+ newmtl 材质.1
77
+ Ka 1 1 1
78
+ Kd 0.15639999508858 0.15934666991234 0.17000000178814
79
+ Ks 1 1 1
80
+ Ns 50
81
+ illum 7
82
+
83
+ newmtl 材质
84
+ Ka 1 1 1
85
+ Kd 0.78200000524521 0.79673331975937 0.85000002384186
86
+ Ks 1 1 1
87
+ Ns 50
88
+ illum 7
89
+
90
+ newmtl 材质.10
91
+ Ka 1 1 1
92
+ Kd 0.95999997854233 0.79295998811722 0.12479999661446
93
+ Ks 1 1 1
94
+ Ns 50
95
+ illum 7
96
+
97
+ newmtl 材质.3
98
+ Ka 1 1 1
99
+ Kd 0.88999998569489 0.82770001888275 0.14239999651909
100
+ Ks 1 1 1
101
+ Ns 50
102
+ illum 7
103
+