This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
App.vue
318 lines (297 loc) · 7.72 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
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
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<template>
<v-app>
<v-navigation-drawer
temporary
data-e2e="menu"
v-model="drawer"
width="400"
>
<v-list dense>
<v-list-item>
<v-list-item-content>
<v-list-item-title class="title">Plane</v-list-item-title>
<v-list-item-action-text>
<slider
data-e2e="plane-x"
label="X"
value="viewer.plane.X"
v-model="viewer.plane.X"
/>
<slider
data-e2e="plane-y"
label="Y"
value="viewer.plane.Y"
v-model="viewer.plane.Y"
/>
</v-list-item-action-text>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content>
<v-list-item-title class="title">Position</v-list-item-title>
<v-list-item-action-text>
<slider
data-e2e="position-x"
label="X"
:min="-20"
:max="20"
value="viewer.position.X"
v-model="viewer.position.X"
/>
<slider
data-e2e="position-y"
label="Y"
:min="-20"
:max="20"
value="viewer.position.Y"
v-model="viewer.position.Y"
/>
<slider
data-e2e="position-z"
label="Z"
:min="-20"
:max="20"
value="viewer.position.Z"
v-model="viewer.position.Z"
/>
</v-list-item-action-text>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content>
<v-list-item-title class="title">Rotation</v-list-item-title>
<v-list-item-action-text>
<slider
data-e2e="rotation-x"
label="X"
:min="-180"
:max="180"
value="viewer.rotation.X"
v-model="viewer.rotation.X"
/>
<slider
data-e2e="rotation-y"
label="Y"
:min="-180"
:max="180"
value="viewer.rotation.Y"
v-model="viewer.rotation.Y"
/>
<slider
data-e2e="rotation-z"
label="Z"
:min="-180"
:max="180"
value="viewer.rotation.Z"
v-model="viewer.rotation.Z"
/>
</v-list-item-action-text>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content>
<v-list-item-title class="title">Scale</v-list-item-title>
<v-list-item-action-text>
<slider
data-e2e="scale-x"
label="X"
:min="0"
:max="10"
value="viewer.scale.X"
v-model="viewer.scale.X"
/>
<slider
data-e2e="scale-y"
label="Y"
:min="0"
:max="10"
value="viewer.scale.Y"
v-model="viewer.scale.Y"
/>
<slider
data-e2e="scale-z"
label="Z"
:min="0"
:max="10"
value="viewer.scale.Z"
v-model="viewer.scale.Z"
/>
</v-list-item-action-text>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content>
<v-list-item-title class="title">Theme</v-list-item-title>
<v-list-item-action-text>
<color-picker
data-e2e="background-color"
label="Background Color"
v-model="viewer.theme.background"
/>
</v-list-item-action-text>
<v-list-item-action-text>
<color-picker
data-e2e="plane-color"
label="Plane Color"
v-model="viewer.theme.plane"
/>
</v-list-item-action-text>
<v-list-item-action-text>
<color-picker
data-e2e="primary-color"
label="Primary Color"
v-model="viewer.theme.primary"
/>
</v-list-item-action-text>
<v-list-item-action-text>
<color-picker
data-e2e="secondary-color"
label="Secondary Color"
v-model="viewer.theme.secondary"
/>
</v-list-item-action-text>
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-dialog persistent v-model="progress.visible">
<v-card>
<v-card-title class="headline">Progress</v-card-title>
<v-card-text>
<v-progress-linear
stream
color="primary"
:buffer-value="progress.value"
:value="progress.value"
></v-progress-linear>
</v-card-text>
</v-card>
</v-dialog>
<v-btn
icon
class="menu-icon"
@click="drawer = !drawer"
data-e2e="toggle-menu"
>
<v-icon>mdi-menu</v-icon>
</v-btn>
<v-snackbar :value="true" timeout="-1">
<v-file-input
:accept="accepts"
@change="upload"
data-e2e="file-input"
label="File"
/>
</v-snackbar>
<three-d-viewer
:extension="viewer.extension"
:file="viewer.file"
:plane="viewer.plane"
:position="viewer.position"
:rotation="viewer.rotation"
:scale="viewer.scale"
:theme="viewer.theme"
@done="done"
@progress="update"
class="emulate-root"
data-e2e="three-d-viewer"
/>
</v-app>
</template>
<script>
//Imports
import colorPicker from './color-picker';
import slider from './slider.vue';
import {FileFormats} from 'unified-3d-loader';
//Compute accepted extensions and mime types
const accepts = Object.values(FileFormats).map(format => format.extensions.map(extension => '.' + extension).join(',') + ',' + format.mimes.join(',')).join(',') + ',.gcode';
export default {
data: () => ({
accepts,
drawer: false,
progress: {
value: 0,
visible: false
},
viewer: {
plane: {
X: 10,
Y: 10
},
extension: '',
file: new ArrayBuffer(0),
position: {
X: 5,
Y: 0,
Z: -5
},
rotation: {
X: -90,
Y: 0,
Z: 180
},
scale: {
X: 0.1,
Y: 0.1,
Z: 0.1
},
theme: {
background: '#dfe4ed',
plane: '#586375',
primary: '#4287f5',
secondary: '#0a2f6b'
}
}
}),
components: {
'color-picker': colorPicker,
slider
},
methods: {
done()
{
this.progress.visible = false;
},
update(progress)
{
this.progress.value = progress;
},
async upload(file)
{
//Reset progress bar and display it
this.progress.value = 0;
this.progress.visible = true;
//Set extension
this.viewer.extension = file.name.split('.').pop();
//Get the array buffer
this.viewer.file = await file.arrayBuffer();
}
}
};
</script>
<style>
:root {
overflow-y: auto;
}
.emulate-root {
background: var(--foreground);
display: flex;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
.menu-icon {
left: 5px;
position: absolute !important;
top: 5px;
z-index: 5;
}
.v-list {
max-height: 80vh;
}
.v-navigation-drawer {
z-index: 10;
}
</style>