@houstonp/rubiks-cube 1.0.0 → 1.0.1
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/index.js +82 -67
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -89,14 +89,17 @@ class RubiksCube extends HTMLElement {
|
|
|
89
89
|
const animationQueue = new AnimationQueue();
|
|
90
90
|
|
|
91
91
|
// initial camera animation
|
|
92
|
-
new TWEEN.
|
|
93
|
-
|
|
94
|
-
.
|
|
95
|
-
|
|
92
|
+
const cameraAnimationGroup = new TWEEN.Group();
|
|
93
|
+
cameraAnimationGroup.add(
|
|
94
|
+
new TWEEN.Tween(camera.position)
|
|
95
|
+
.to({ x: 3, y: 3, z: 4 }, 1000)
|
|
96
|
+
.easing(TWEEN.Easing.Cubic.InOut)
|
|
97
|
+
.start()
|
|
98
|
+
);
|
|
96
99
|
|
|
97
100
|
// animation loop
|
|
98
101
|
function animate() {
|
|
99
|
-
|
|
102
|
+
cameraAnimationGroup.update();
|
|
100
103
|
controls.update();
|
|
101
104
|
animationQueue.update();
|
|
102
105
|
const animationGroup = animationQueue.getAnimationGroup();
|
|
@@ -120,73 +123,85 @@ class RubiksCube extends HTMLElement {
|
|
|
120
123
|
});
|
|
121
124
|
this.addEventListener("camera", (e) => {
|
|
122
125
|
console.log(cube.getStickerState());
|
|
123
|
-
|
|
126
|
+
|
|
124
127
|
if (e.detail.action === "peek-toggle-horizontal") {
|
|
125
|
-
|
|
126
|
-
.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
cameraAnimationGroup.add(
|
|
129
|
+
new TWEEN.Tween(camera.position)
|
|
130
|
+
.to(
|
|
131
|
+
{
|
|
132
|
+
x: camera.position.x > 0 ? -2.5 : 2.5,
|
|
133
|
+
y: camera.position.y > 0 ? 2.5 : -2.5,
|
|
134
|
+
z: 4,
|
|
135
|
+
},
|
|
136
|
+
200
|
|
137
|
+
)
|
|
138
|
+
.start()
|
|
139
|
+
);
|
|
135
140
|
} else if (e.detail.action === "peek-toggle-vertical") {
|
|
136
|
-
|
|
137
|
-
.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
141
|
+
cameraAnimationGroup.add(
|
|
142
|
+
new TWEEN.Tween(camera.position)
|
|
143
|
+
.to(
|
|
144
|
+
{
|
|
145
|
+
x: camera.position.x > 0 ? 2.5 : -2.5,
|
|
146
|
+
y: camera.position.y > 0 ? -2.5 : 2.5,
|
|
147
|
+
z: 4,
|
|
148
|
+
},
|
|
149
|
+
200
|
|
150
|
+
)
|
|
151
|
+
.start()
|
|
152
|
+
);
|
|
153
|
+
} else if (e.etail.action === "peek-right") {
|
|
154
|
+
cameraAnimationGroup.add(
|
|
155
|
+
new TWEEN.Tween(camera.position)
|
|
156
|
+
.to(
|
|
157
|
+
{
|
|
158
|
+
x: 2.5,
|
|
159
|
+
y: camera.position.y > 0 ? 2.5 : -2.5,
|
|
160
|
+
z: 4,
|
|
161
|
+
},
|
|
162
|
+
200
|
|
163
|
+
)
|
|
164
|
+
.start()
|
|
165
|
+
);
|
|
157
166
|
} else if (e.detail.action === "peek-left") {
|
|
158
|
-
|
|
159
|
-
.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
cameraAnimationGroup.add(
|
|
168
|
+
new TWEEN.Tween(camera.position)
|
|
169
|
+
.to(
|
|
170
|
+
{
|
|
171
|
+
x: -2.5,
|
|
172
|
+
y: camera.position.y > 0 ? 2.5 : -2.5,
|
|
173
|
+
z: 4,
|
|
174
|
+
},
|
|
175
|
+
200
|
|
176
|
+
)
|
|
177
|
+
.start()
|
|
178
|
+
);
|
|
168
179
|
} else if (e.detail.action === "peek-up") {
|
|
169
|
-
|
|
170
|
-
.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
180
|
+
cameraAnimationGroup.add(
|
|
181
|
+
new TWEEN.Tween(camera.position)
|
|
182
|
+
.to(
|
|
183
|
+
{
|
|
184
|
+
x: camera.position.x > 0 ? 2.5 : -2.5,
|
|
185
|
+
y: 2.5,
|
|
186
|
+
z: 4,
|
|
187
|
+
},
|
|
188
|
+
200
|
|
189
|
+
)
|
|
190
|
+
.start()
|
|
191
|
+
);
|
|
179
192
|
} else if (e.detail.action === "peek-down") {
|
|
180
|
-
|
|
181
|
-
.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
193
|
+
cameraAnimationGroup.add(
|
|
194
|
+
new TWEEN.Tween(camera.position)
|
|
195
|
+
.to(
|
|
196
|
+
{
|
|
197
|
+
x: camera.position.x > 0 ? 2.5 : -2.5,
|
|
198
|
+
y: -2.5,
|
|
199
|
+
z: 4,
|
|
200
|
+
},
|
|
201
|
+
200
|
|
202
|
+
)
|
|
203
|
+
.start()
|
|
204
|
+
);
|
|
190
205
|
}
|
|
191
206
|
});
|
|
192
207
|
}
|