w-threejs-vue 1.0.19 → 1.0.21

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 (112) hide show
  1. package/README.md +1 -1
  2. package/dist/w-threejs-vue.umd.js +5 -5
  3. package/dist/w-threejs-vue.umd.js.map +1 -1
  4. package/docs/examples/app.html +1 -1
  5. package/docs/examples/app.umd.js +6 -6
  6. package/docs/examples/app.umd.js.map +1 -1
  7. package/docs/examples/ex-AppAxAxisXGridLineColor.html +1 -1
  8. package/docs/examples/ex-AppAxAxisXGridLineWidth.html +1 -1
  9. package/docs/examples/ex-AppAxAxisXLineColor.html +1 -1
  10. package/docs/examples/ex-AppAxAxisXLineWidth.html +1 -1
  11. package/docs/examples/ex-AppAxAxisXTickLabelColor.html +1 -1
  12. package/docs/examples/ex-AppAxAxisXTickLabelDig.html +1 -1
  13. package/docs/examples/ex-AppAxAxisXTickLabelDistance.html +1 -1
  14. package/docs/examples/ex-AppAxAxisXTickLabelFontFamily.html +1 -1
  15. package/docs/examples/ex-AppAxAxisXTickLabelFontSize.html +1 -1
  16. package/docs/examples/ex-AppAxAxisXTickLineColor.html +1 -1
  17. package/docs/examples/ex-AppAxAxisXTickLineLength.html +1 -1
  18. package/docs/examples/ex-AppAxAxisXTickLineWidth.html +1 -1
  19. package/docs/examples/ex-AppAxAxisXTickNum.html +1 -1
  20. package/docs/examples/ex-AppAxAxisXTitle.html +1 -1
  21. package/docs/examples/ex-AppAxAxisXTitleColor.html +1 -1
  22. package/docs/examples/ex-AppAxAxisXTitleDistance.html +1 -1
  23. package/docs/examples/ex-AppAxAxisXTitleFontFamily.html +1 -1
  24. package/docs/examples/ex-AppAxAxisXTitleFontSize.html +1 -1
  25. package/docs/examples/ex-AppAxAxisYGridLineColor.html +1 -1
  26. package/docs/examples/ex-AppAxAxisYGridLineWidth.html +1 -1
  27. package/docs/examples/ex-AppAxAxisYLineColor.html +1 -1
  28. package/docs/examples/ex-AppAxAxisYLineWidth.html +1 -1
  29. package/docs/examples/ex-AppAxAxisYTickLabelColor.html +1 -1
  30. package/docs/examples/ex-AppAxAxisYTickLabelDig.html +1 -1
  31. package/docs/examples/ex-AppAxAxisYTickLabelDistance.html +1 -1
  32. package/docs/examples/ex-AppAxAxisYTickLabelFontFamily.html +1 -1
  33. package/docs/examples/ex-AppAxAxisYTickLabelFontSize.html +1 -1
  34. package/docs/examples/ex-AppAxAxisYTickLineColor.html +1 -1
  35. package/docs/examples/ex-AppAxAxisYTickLineLength.html +1 -1
  36. package/docs/examples/ex-AppAxAxisYTickLineWidth.html +1 -1
  37. package/docs/examples/ex-AppAxAxisYTickNum.html +1 -1
  38. package/docs/examples/ex-AppAxAxisYTitle.html +1 -1
  39. package/docs/examples/ex-AppAxAxisYTitleColor.html +1 -1
  40. package/docs/examples/ex-AppAxAxisYTitleDistance.html +1 -1
  41. package/docs/examples/ex-AppAxAxisYTitleFontFamily.html +1 -1
  42. package/docs/examples/ex-AppAxAxisYTitleFontSize.html +1 -1
  43. package/docs/examples/ex-AppAxAxisZGridLineColor.html +1 -1
  44. package/docs/examples/ex-AppAxAxisZGridLineWidth.html +1 -1
  45. package/docs/examples/ex-AppAxAxisZLineColor.html +1 -1
  46. package/docs/examples/ex-AppAxAxisZLineWidth.html +1 -1
  47. package/docs/examples/ex-AppAxAxisZTickLabelColor.html +1 -1
  48. package/docs/examples/ex-AppAxAxisZTickLabelDig.html +1 -1
  49. package/docs/examples/ex-AppAxAxisZTickLabelDistance.html +1 -1
  50. package/docs/examples/ex-AppAxAxisZTickLabelFontFamily.html +1 -1
  51. package/docs/examples/ex-AppAxAxisZTickLabelFontSize.html +1 -1
  52. package/docs/examples/ex-AppAxAxisZTickLineColor.html +1 -1
  53. package/docs/examples/ex-AppAxAxisZTickLineLength.html +1 -1
  54. package/docs/examples/ex-AppAxAxisZTickLineWidth.html +1 -1
  55. package/docs/examples/ex-AppAxAxisZTickNum.html +1 -1
  56. package/docs/examples/ex-AppAxAxisZTitle.html +1 -1
  57. package/docs/examples/ex-AppAxAxisZTitleColor.html +1 -1
  58. package/docs/examples/ex-AppAxAxisZTitleDistance.html +1 -1
  59. package/docs/examples/ex-AppAxAxisZTitleFontFamily.html +1 -1
  60. package/docs/examples/ex-AppAxAxisZTitleFontSize.html +1 -1
  61. package/docs/examples/ex-AppBasicAutoRotateDeg.html +1 -1
  62. package/docs/examples/ex-AppBasicBackgroundColor.html +1 -1
  63. package/docs/examples/ex-AppBasicSize.html +1 -1
  64. package/docs/examples/ex-AppBasicUpload.html +1 -1
  65. package/docs/examples/ex-AppBasicUseAutoRotate.html +1 -1
  66. package/docs/examples/ex-AppCmCameraFar.html +1 -1
  67. package/docs/examples/ex-AppCmCameraFov.html +1 -1
  68. package/docs/examples/ex-AppCmCameraNear.html +1 -1
  69. package/docs/examples/ex-AppCmCameraOrthographicRatio.html +1 -1
  70. package/docs/examples/ex-AppCmCameraType.html +1 -1
  71. package/docs/examples/ex-AppCmGetCameraViewAngle.html +1 -1
  72. package/docs/examples/ex-AppCmSetCameraAzimuthAngle.html +1 -1
  73. package/docs/examples/ex-AppCmSetCameraPolarAngle.html +1 -1
  74. package/docs/examples/ex-AppCmSetCameraViewAngle.html +1 -1
  75. package/docs/examples/ex-AppHpHelperAxesLengthRatio.html +1 -1
  76. package/docs/examples/ex-AppHpHelperGridDensity.html +1 -1
  77. package/docs/examples/ex-AppHpHelperGridLengthRatio.html +1 -1
  78. package/docs/examples/ex-AppHpHelperGridPositionRatioZ.html +1 -1
  79. package/docs/examples/ex-AppHpUseHelperAxes.html +1 -1
  80. package/docs/examples/ex-AppHpUseHelperGrid.html +1 -1
  81. package/docs/examples/ex-AppLgLegendBackgroundColor.html +1 -1
  82. package/docs/examples/ex-AppLgLegendHeight.html +1 -1
  83. package/docs/examples/ex-AppLgLegendHeightMax.html +1 -1
  84. package/docs/examples/ex-AppLtLightAmbientColor.html +1 -1
  85. package/docs/examples/ex-AppLtLightDirectionColor.html +1 -1
  86. package/docs/examples/ex-AppLtLightDirectionIntensity.html +1 -1
  87. package/docs/examples/ex-AppLtLightDirectionPos.html +1 -1
  88. package/docs/examples/ex-AppLtLightPointColor.html +1 -1
  89. package/docs/examples/ex-AppLtLightPointDecay.html +1 -1
  90. package/docs/examples/ex-AppLtLightPointDistance.html +1 -1
  91. package/docs/examples/ex-AppLtLightPointIntensity.html +1 -1
  92. package/docs/examples/ex-AppLtLightPointPoss.html +1 -1
  93. package/docs/examples/ex-AppLtUseLightAmbient.html +1 -1
  94. package/docs/examples/ex-AppLtUseLightDirection.html +1 -1
  95. package/docs/examples/ex-AppLtUseLightPoint.html +1 -1
  96. package/docs/examples/ex-AppMhGetMeshsInfor.html +1 -1
  97. package/docs/examples/ex-AppMhSetMeshColor.html +1 -1
  98. package/docs/examples/ex-AppMhSetMeshLabelText.html +1 -1
  99. package/docs/examples/ex-AppMhSetMeshLabelTextColor.html +1 -1
  100. package/docs/examples/ex-AppMhSetMeshLabelTextFontFamily.html +1 -1
  101. package/docs/examples/ex-AppMhSetMeshLabelTextFontSize.html +1 -1
  102. package/docs/examples/ex-AppMhSetMeshLabelVisible.html +1 -1
  103. package/docs/examples/ex-AppMhSetMeshVisible.html +1 -1
  104. package/docs/examples/ex-AppMhUseAxis.html +1 -1
  105. package/docs/examples/ex-AppMuMenuIcons.html +1 -1
  106. package/docs/examples/ex-AppMuMenuTooltips.html +1 -1
  107. package/docs/index.html +1 -1
  108. package/docs/module-WThreejsVue.html +13 -1
  109. package/package.json +2 -2
  110. package/src/components/WThreejsVue.vue +154 -141
  111. package/src/js/addStl.mjs +22 -18
  112. package/src/js/addVtp.mjs +1 -1
@@ -1,143 +1,138 @@
1
1
  <template>
2
- <div :style="`width:${widthInp}px; height:${heightInp}px;`">
3
-
4
- <div style="position:relative; width:0px; height:0px;" v-if="loading">
5
- <div style="position:absolute; top:0px; left:0px;">
6
- <WIconLoading></WIconLoading>
7
- </div>
8
- </div>
9
-
10
- <div style="position:relative;">
11
-
12
- <div
13
- ref="panel"
14
- :style="`position:relative; width:${widthInp}px; height:${heightInp}px; opacity:${loading?0:1};`"
15
- v-domresize
16
- @domresize="resizePanel"
17
- ></div>
18
-
19
- <!-- 須使用pointer-events:none吃掉事件, 才能點擊選單區透明區域 -->
20
- <div
21
- :style="`position:absolute; top:0px; left:0px; pointer-events:none;`"
22
- v-if="!loading"
23
- >
24
-
25
- <div :style="`padding:${space}px; display:flex; align-items:flex-start;`">
26
-
27
- <!-- 設定區 -->
28
- <!-- 須使用pointer-events:auto恢復子元素接收事件, 才能點擊與捲動選單 -->
29
- <WPanelScrolly
30
- :style="`width:${panelItemsIconSize}px; height:${panelItemsHeight}px; pointer-events:auto;`"
31
- :bar-opacity="0"
32
- :bar-opacity-hover="0.8"
33
- >
34
-
35
- <WGroupIconCheck
36
- :items="useItems"
37
- :dir="'vertical'"
38
- :iconColor="'#aaa'"
39
- :iconColorHover="'#ccc'"
40
- :iconColorFocus="'#ccc'"
41
- :iconColorActive="'#fff'"
42
- :backgroundColor="'#000'"
43
- :backgroundColorHover="'#111'"
44
- :backgroundColorFocus="'#111'"
45
- :backgroundColorActive="'#444'"
46
- :seplineColor="'#333'"
47
- :tooltipTextFontSize="'0.7rem'"
48
- :value="itemsSelects"
49
- _input="updateItem"
50
- @click="ckItem"
51
- ></WGroupIconCheck>
52
-
53
- </WPanelScrolly>
54
-
55
- <template v-if="useLegend">
56
-
57
- <div :style="`padding-left:${space}px;`"></div>
58
-
59
- <!-- 圖例區 -->
60
- <!-- 須使用pointer-events:none吃掉事件, 才能點擊選單區透明區域 -->
61
- <div :style="`padding:5px; border-radius:4px; background:${useLegendBackgroundColor}; pointer-events:auto;`">
62
- <div :style="`${useLegendHeight}`">
63
-
64
- <div
65
- :style="``"
66
- :key="'km-'+km"
67
- v-for="(m,km) in meshs"
68
- >
69
-
70
- <div style="display:flex; align-items:center; padding:3px;">
71
-
72
- <WIcon
73
- style="cursor:pointer;"
74
- :icon="m.visible?mdiEyeOutline:mdiEyeOffOutline"
75
- :color="'#ccc'"
76
- :colorHover="'#ddd'"
77
- :size="20"
78
- @click="toggleMeshVisible(m,km)"
79
- ></WIcon>
80
-
81
- <div style="padding-left:5px;"></div>
82
-
83
- <WColorSelect
84
- :colorBlockBorderColor="'#888'"
85
- :showColorText="false"
86
- _colorTextColor="'#ddd'"
87
- :panelBackgroundColor="'#111'"
88
- :toolBackgroundColor="'#222'"
89
- :menuIconColor="'#666'"
90
- :menuIconColorHover="'#777'"
91
- :menuIconColorActive="'#ddd'"
92
- :borderColor="'#333'"
93
- :borderColorHover="'#333'"
94
- :borderColorActive="'#444'"
95
- :backgroundColor="'#111'"
96
- :menuBackgroundColor="'#111'"
97
- :menuBackgroundColorHover="'#222'"
98
- :menuBackgroundColorActive="'#333'"
99
- :menuTextColor="'#b2b2b2'"
100
- :menuTextColorHover="'#ccc'"
101
- :menuTextColorActive="'#ddd'"
102
- :menuTextFontSize="'0.75rem'"
103
- :inputBorderColor="'#444'"
104
- :inputBorderColorHover="'#555'"
105
- :inputBorderColorActive="'#666'"
106
- :inputBackgroundColor="'#000'"
107
- :inputBackgroundColorHover="'#111'"
108
- :inputBackgroundColorActive="'#222'"
109
- :inputTextColor="'#999'"
110
- :inputLabelColor="'#888'"
111
- :barProgColor="'#888'"
112
- :barProgBackgroundColor="'#222'"
113
- :barSliderBackgroundColor="'#ccc'"
114
- :barSliderBackgroundColorHover="'#ddd'"
115
- :btnTextColor="'#eee'"
116
- :btnTextColorHover="'#fff'"
117
- :btnTextColorActive="'#fff'"
118
- :btnBackgroundColor="'#444'"
119
- :btnBackgroundColorHover="'#555'"
120
- :btnBackgroundColorActive="'#555'"
121
- :value="getMeshColor(m)"
122
- @input="(c)=>{setMeshColor(m,km,c)}"
123
- ></WColorSelect>
124
-
125
- <div style="padding-left:5px;"></div>
126
-
127
- <div :style="`color:${m.labelTextColor}; font-size:${m.labelTextFontSize}; font-family:${m.labelTextFontFamily};`">
128
- {{m.labelText}}
129
- </div>
130
-
2
+ <div
3
+ :style="`position:relative; width:${widthInp}px; height:${heightInp}px;`"
4
+ :loading="loading"
5
+ >
6
+
7
+ <!-- 圖台區 -->
8
+ <div
9
+ ref="panel"
10
+ :style="`width:${widthInp}px; height:${heightInp}px; opacity:${loading?0:1};`"
11
+ v-domresize
12
+ @domresize="resizePanel"
13
+ ></div>
14
+
15
+ <!-- 輔助區 -->
16
+ <!-- 須使用pointer-events:none吃掉事件, 才能點擊選單區透明區域 -->
17
+ <div
18
+ :style="`position:absolute; top:0px; left:0px; pointer-events:none;`"
19
+ v-if="!loading"
20
+ >
21
+
22
+ <div :style="`padding:${space+menuYShiftInp}px ${space}px ${space}px ${space}px; display:flex; align-items:flex-start;`">
23
+
24
+ <!-- 設定區 -->
25
+ <!-- 須使用pointer-events:auto恢復子元素接收事件, 才能點擊與捲動選單 -->
26
+ <WPanelScrolly
27
+ :style="`width:${panelItemsIconSize}px; height:${panelItemsHeight}px; pointer-events:auto;`"
28
+ :bar-opacity="0"
29
+ :bar-opacity-hover="0.8"
30
+ >
31
+
32
+ <WGroupIconCheck
33
+ :items="useItems"
34
+ :dir="'vertical'"
35
+ :iconColor="'#aaa'"
36
+ :iconColorHover="'#ccc'"
37
+ :iconColorFocus="'#ccc'"
38
+ :iconColorActive="'#fff'"
39
+ :backgroundColor="'#000'"
40
+ :backgroundColorHover="'#111'"
41
+ :backgroundColorFocus="'#111'"
42
+ :backgroundColorActive="'#444'"
43
+ :seplineColor="'#333'"
44
+ :tooltipTextFontSize="'0.7rem'"
45
+ :value="itemsSelects"
46
+ _input="updateItem"
47
+ @click="ckItem"
48
+ ></WGroupIconCheck>
49
+
50
+ </WPanelScrolly>
51
+
52
+ <template v-if="useLegend">
53
+
54
+ <div :style="`padding-left:${space}px;`"></div>
55
+
56
+ <!-- 圖例區 -->
57
+ <!-- 須使用pointer-events:none吃掉事件, 才能點擊選單區透明區域 -->
58
+ <div :style="`padding:5px; border-radius:4px; background:${useLegendBackgroundColor}; pointer-events:auto;`">
59
+ <div :style="`${useLegendHeight}`">
60
+
61
+ <div
62
+ :style="``"
63
+ :key="'km-'+km"
64
+ v-for="(m,km) in meshs"
65
+ >
66
+
67
+ <div style="display:flex; align-items:center; padding:3px;">
68
+
69
+ <WIcon
70
+ style="cursor:pointer;"
71
+ :icon="m.visible?mdiEyeOutline:mdiEyeOffOutline"
72
+ :color="'#ccc'"
73
+ :colorHover="'#ddd'"
74
+ :size="20"
75
+ @click="toggleMeshVisible(m,km)"
76
+ ></WIcon>
77
+
78
+ <div style="padding-left:5px;"></div>
79
+
80
+ <WColorSelect
81
+ :colorBlockBorderColor="'#888'"
82
+ :showColorText="false"
83
+ _colorTextColor="'#ddd'"
84
+ :panelBackgroundColor="'#111'"
85
+ :toolBackgroundColor="'#222'"
86
+ :menuIconColor="'#666'"
87
+ :menuIconColorHover="'#777'"
88
+ :menuIconColorActive="'#ddd'"
89
+ :borderColor="'#333'"
90
+ :borderColorHover="'#333'"
91
+ :borderColorActive="'#444'"
92
+ :backgroundColor="'#111'"
93
+ :menuBackgroundColor="'#111'"
94
+ :menuBackgroundColorHover="'#222'"
95
+ :menuBackgroundColorActive="'#333'"
96
+ :menuTextColor="'#b2b2b2'"
97
+ :menuTextColorHover="'#ccc'"
98
+ :menuTextColorActive="'#ddd'"
99
+ :menuTextFontSize="'0.75rem'"
100
+ :inputBorderColor="'#444'"
101
+ :inputBorderColorHover="'#555'"
102
+ :inputBorderColorActive="'#666'"
103
+ :inputBackgroundColor="'#000'"
104
+ :inputBackgroundColorHover="'#111'"
105
+ :inputBackgroundColorActive="'#222'"
106
+ :inputTextColor="'#999'"
107
+ :inputLabelColor="'#888'"
108
+ :barProgColor="'#888'"
109
+ :barProgBackgroundColor="'#222'"
110
+ :barSliderBackgroundColor="'#ccc'"
111
+ :barSliderBackgroundColorHover="'#ddd'"
112
+ :btnTextColor="'#eee'"
113
+ :btnTextColorHover="'#fff'"
114
+ :btnTextColorActive="'#fff'"
115
+ :btnBackgroundColor="'#444'"
116
+ :btnBackgroundColorHover="'#555'"
117
+ :btnBackgroundColorActive="'#555'"
118
+ :value="getMeshColor(m)"
119
+ @input="(c)=>{setMeshColor(m,km,c)}"
120
+ ></WColorSelect>
121
+
122
+ <div style="padding-left:5px;"></div>
123
+
124
+ <div :style="`color:${m.labelTextColor}; font-size:${m.labelTextFontSize}; font-family:${m.labelTextFontFamily};`">
125
+ {{m.labelText}}
131
126
  </div>
132
127
 
133
128
  </div>
134
129
 
135
130
  </div>
136
- </div>
137
131
 
138
- </template>
132
+ </div>
133
+ </div>
139
134
 
140
- </div>
135
+ </template>
141
136
 
142
137
  </div>
143
138
 
@@ -172,7 +167,6 @@ import strleft from 'wsemi/src/strleft.mjs'
172
167
  import strdelleft from 'wsemi/src/strdelleft.mjs'
173
168
  import oc from 'wsemi/src/color.mjs'
174
169
  import domResize from 'w-component-vue/src/js/domResize.mjs'
175
- import WIconLoading from 'w-component-vue/src/components/WIconLoading.vue'
176
170
  import WPanelScrolly from 'w-component-vue/src/components/WPanelScrolly.vue'
177
171
  import WGroupIconCheck from 'w-component-vue/src/components/WGroupIconCheck.vue'
178
172
  import WIcon from 'w-component-vue/src/components/WIcon.vue'
@@ -273,6 +267,7 @@ let pathYZ = `M 22.049294,18.372083 H 12.678108 V 17.831045 L 20.097742,6.740768
273
267
  * @vue-prop {Number} [opt.cameraOrthographicRatio] 輸入正交相機比例數字
274
268
  * @vue-prop {Number} [opt.cameraAzimuthAngle] 輸入相機方位角(水平角度)數字,因可通過UI改變導致Vue無法監聽變數有變而觸發computed,故建議直接使用setCameraAzimuthAngle變更
275
269
  * @vue-prop {Number} [opt.cameraPolarAngle] 輸入相機極角(垂直角度)數字,因可通過UI改變導致Vue無法監聯變數有變而觸發computed,故建議直接使用setCameraPolarAngle變更
270
+ * @vue-prop {Number} [opt.menuYShift=0] 輸入選單區域頂部位移數字,單位px,正值向下移動,預設0
276
271
  * @vue-prop {Boolean} [opt.useSetting=true] 輸入是否顯示設定選單布林值,預設true
277
272
  * @vue-prop {String} [opt.menuSettingIcon] 輸入設定選單圖示SVG path字串,預設mdiCogOutline
278
273
  * @vue-prop {String} [opt.menuSettingTooltip='Settings'] 輸入設定選單tooltip文字字串,預設'Settings'
@@ -313,7 +308,6 @@ export default {
313
308
  domresize: domResize(),
314
309
  },
315
310
  components: {
316
- WIconLoading,
317
311
  WPanelScrolly,
318
312
  WGroupIconCheck,
319
313
  WIcon,
@@ -451,6 +445,21 @@ export default {
451
445
  return h
452
446
  },
453
447
 
448
+ menuYShiftInp: function() {
449
+ //console.log('computed menuYShiftInp')
450
+
451
+ let vo = this
452
+
453
+ //y
454
+ let y = get(vo, 'opt.menuYShift', null)
455
+ if (!isnum(y)) {
456
+ y = 0
457
+ }
458
+ y = cdbl(y)
459
+
460
+ return y
461
+ },
462
+
454
463
  useMenuItemHelperAxesInp: function() {
455
464
  //console.log('computed useMenuItemHelperAxesInp')
456
465
 
@@ -1018,8 +1027,9 @@ export default {
1018
1027
  return
1019
1028
  }
1020
1029
 
1021
- //show loading
1030
+ //show and emit loading
1022
1031
  vo.loading = true
1032
+ vo.$emit('loading', true)
1023
1033
 
1024
1034
  //optPlot3d
1025
1035
  let optUsed = cloneDeep(vo.opt)
@@ -1077,8 +1087,9 @@ export default {
1077
1087
  //save applied opt
1078
1088
  vo.optTemp = cloneDeep(optUsed)
1079
1089
 
1080
- //hide loading
1090
+ //hide and emit loading
1081
1091
  vo.loading = false
1092
+ vo.$emit('loading', false)
1082
1093
 
1083
1094
  //resolveInit
1084
1095
  resolveInit()
@@ -1095,8 +1106,9 @@ export default {
1095
1106
  }
1096
1107
  // console.log('error', err)
1097
1108
 
1098
- //reset
1109
+ //reset and emit loading
1099
1110
  vo.loading = false
1111
+ vo.$emit('loading', false)
1100
1112
 
1101
1113
  //emit
1102
1114
  vo.$emit('error', err)
@@ -1108,12 +1120,12 @@ export default {
1108
1120
 
1109
1121
  //on
1110
1122
  ev.on('init', handleInit)
1111
- ev.on('loading', (msg) => {
1123
+ ev.on('prog', (msg) => {
1112
1124
  if (vo.disposed || nid !== vo.nidInit) {
1113
1125
  return
1114
1126
  }
1115
- // console.log('loading', msg)
1116
- vo.$emit('loading', msg)
1127
+ // console.log('prog', msg)
1128
+ vo.$emit('prog', msg)
1117
1129
  })
1118
1130
  ev.on('error', handleError)
1119
1131
  ev.on('dispose', () => {
@@ -1174,8 +1186,9 @@ export default {
1174
1186
  return
1175
1187
  }
1176
1188
 
1177
- //reset
1189
+ //reset and emit loading
1178
1190
  vo.loading = false
1191
+ vo.$emit('loading', false)
1179
1192
 
1180
1193
  //emit
1181
1194
  vo.$emit('error', err)
package/src/js/addStl.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import get from 'lodash-es/get.js'
2
- import isNumber from 'lodash-es/isNumber.js'
1
+ import get from 'lodash-es/get.js'
2
+ import isNumber from 'lodash-es/isNumber.js'
3
3
  import isestr from 'wsemi/src/isestr.mjs'
4
4
  // import genPm from 'wsemi/src/genPm.mjs'
5
5
  import oc from 'wsemi/src/color.mjs'
@@ -28,13 +28,17 @@ let addStl = async(ev, url, opt = {}) => {
28
28
 
29
29
  //loader
30
30
  let loader = new STLLoader()
31
- let geometry = await loader.loadAsync(url, (xhr) => {
32
- let prog = (xhr.loaded / xhr.total) * 100
33
- ev.emit('loading', {
34
- url,
35
- prog,
36
- })
37
- })
31
+ let geometry = await loader.loadAsync(url, (xhr) => {
32
+ let loaded = xhr.loaded || 0
33
+ let total = xhr.total || 0
34
+ let prog = total > 0 ? (loaded / total) * 100 : null
35
+ ev.emit('prog', {
36
+ url,
37
+ loaded,
38
+ total,
39
+ prog,
40
+ })
41
+ })
38
42
  // let lad = (url) => {
39
43
  // let pm = genPm()
40
44
  // let onLoad = (res) => {
@@ -56,15 +60,15 @@ let addStl = async(ev, url, opt = {}) => {
56
60
  // loader.load(url, onLoad, onProgress, onError)
57
61
  // return pm
58
62
  // }
59
- // let geometry = await lad(url)
60
- // console.log('geometry', geometry)
61
-
62
- // STLLoader 不保證後續流程需要的 bounding 資訊已存在,這裡先補齊。
63
- geometry.computeBoundingBox()
64
- geometry.computeBoundingSphere()
65
-
66
- //material, MeshLambertMaterial, MeshPhysicalMaterial
67
- let material = new THREE.MeshLambertMaterial({
63
+ // let geometry = await lad(url)
64
+ // console.log('geometry', geometry)
65
+
66
+ // STLLoader 不保證後續流程需要的 bounding 資訊已存在,這裡先補齊。
67
+ geometry.computeBoundingBox()
68
+ geometry.computeBoundingSphere()
69
+
70
+ //material, MeshLambertMaterial, MeshPhysicalMaterial
71
+ let material = new THREE.MeshLambertMaterial({
68
72
 
69
73
  // visible:false,
70
74
 
package/src/js/addVtp.mjs CHANGED
@@ -29,7 +29,7 @@ let addVtp = async(ev, url, opt = {}) => {
29
29
 
30
30
  let polyData = await loadVtpAsPolyData(url, {
31
31
  onProgress: (msg) => {
32
- ev.emit('loading', msg)
32
+ ev.emit('prog', msg)
33
33
  },
34
34
  })
35
35