-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathBall.vue
189 lines (173 loc) · 3.79 KB
/
Ball.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
<template lang="pug">
.app(tabindex="1", ref="app", @keyup.right.space="impressNextStep", @keyup.left="impressPrevStep")
impress-viewport(ref="impress", :steps="steps", :config="config")
.planet-ring
</template>
<script>
import Vue from 'vue'
import VueImpress from '../src'
Vue.use(VueImpress)
const steps = []
const radius = 500
// const initDegree = 0
// const zStep = 15
const size = 12
const degreeStep = 360 / size
for (let i = 0; i < size; i += 1) {
// const rotateX = i * 10
// const xRadius = (rotateX * Math.PI) / 180
// const rotateZ = (Math.random() * 720) - 360
// const zRadius = (rotateZ * Math.PI) / 180
// const zRadius = (90 * Math.PI) / 180
// console.log(Math.sin(zRadius))
const degree = (degreeStep * i * Math.PI) / 180
steps.push({
// x: Math.cos(xRadius) * (Math.sin(zRadius) * radius),
// y: Math.sin(xRadius) * (Math.sin(zRadius) * radius),
// z: Math.cos(zRadius) * radius,
// rotateY: rotateZ,
// rotateX: 90 - rotateX,
x: Math.cos(degree) * radius,
y: 0,
z: Math.sin(degree) * radius,
rotateY: 90 - (degreeStep * i),
content: 'center'
})
}
/* 上扬30度 */
const rotateOrder = ['y', 'x', 'z']
const yUp30 = Math.sin((30 * Math.PI) / 180) * radius
const xRadius30 = Math.cos((30 * Math.PI) / 180) * radius
for (let i = 0; i < size; i += 1) {
const degree = (degreeStep * i * Math.PI) / 180
steps.push({
x: Math.cos(degree) * xRadius30,
y: -yUp30,
z: Math.sin(degree) * xRadius30,
rotateY: 90 - (degreeStep * i),
rotateX: 30,
rotateOrder,
content: 'up30'
})
}
/* 下30度 */
for (let i = 0; i < size; i += 1) {
const degree = (degreeStep * i * Math.PI) / 180
steps.push({
x: Math.cos(degree) * xRadius30,
y: yUp30,
z: Math.sin(degree) * xRadius30,
rotateY: 90 - (degreeStep * i),
rotateX: -30,
rotateOrder,
content: 'down30'
})
}
/* 上60度 */
const yUp60 = Math.sin((60 * Math.PI) / 180) * radius
const xRadius60 = Math.cos((60 * Math.PI) / 180) * radius
for (let i = 0; i < size; i += 1) {
const degree = (degreeStep * i * Math.PI) / 180
steps.push({
x: Math.cos(degree) * xRadius60,
y: -yUp60,
z: Math.sin(degree) * xRadius60,
rotateY: 90 - (degreeStep * i),
rotateX: 60,
rotateOrder,
content: 'up'
})
}
/* 下60度 */
for (let i = 0; i < size; i += 1) {
const degree = (degreeStep * i * Math.PI) / 180
steps.push({
x: Math.cos(degree) * xRadius60,
y: yUp60,
z: Math.sin(degree) * xRadius60,
rotateY: 90 - (degreeStep * i),
rotateX: -60,
rotateOrder,
content: 'down60'
})
}
/* bottom */
steps.push({
x: 0,
y: -radius,
z: 0,
rotateX: 90,
content: 'top'
})
steps.push({
x: 0,
y: radius,
z: 0,
rotateX: -90,
content: 'bottom'
})
steps.unshift({
x: 0,
id: 'overview',
content: '',
scale: 3,
rotateX: 30,
})
export default {
methods: {
impressPrevStep() {
this.$refs.impress.prevStep()
},
impressNextStep() {
this.$refs.impress.nextStep()
},
},
mounted() {
this.$refs.app.focus()
},
data() {
return {
config: {
width: 800,
height: 800,
},
steps,
}
},
}
</script>
<style>
html, body {
overflow: hidden;
height: 100%;
padding: 0;
margin: 0;
box-sizing: border-box;
}
.impress-step {
text-align: center;
cursor: pointer;
}
.impress-step.active {
cursor: auto;
}
.impress-step:nth-of-type(even) {
color: red;
}
.impress-step:nth-of-type(odd) {
color: blue;
}
.impress-viewport .planet-ring {
width: 2000px;
height: 2000px;
position: absolute;
border: 70px solid;
border-radius: 50%;
transform: rotateX(-90deg);
transition: opacity 3s;
opacity: .1;
}
.impress-viewport.overview .planet-ring {
opacity: .5;
}
</style>