forked from rlamana/a-aviator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
propeller.js
34 lines (31 loc) · 919 Bytes
/
propeller.js
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
/*!
* a-aviator <https://github.com/rlamana/a-aviator>
*
* Copyright (c) 2017, Ramon Lamana.
* Based on Karim Maaloul's code for 'The Aviator':
* <https://github.com/yakudoo/TheAviator>
*
* Released under the MIT License.
*/
/**
* Modifies propeller geometry and animates the component.
*/
AFRAME.registerComponent('propeller', {
dependencies: ['geometry'],
update() {
const mesh = this.el.getOrCreateObject3D('mesh', THREE.Mesh);
mesh.geometry.vertices[4].y -= 5;
mesh.geometry.vertices[4].z += 5;
mesh.geometry.vertices[5].y -= 5;
mesh.geometry.vertices[5].z -= 5;
mesh.geometry.vertices[6].y += 5;
mesh.geometry.vertices[6].z += 5;
mesh.geometry.vertices[7].y += 5;
mesh.geometry.vertices[7].z -= 5;
},
tick(time, timeDelta) {
// Rotate propeller and blades.
const object3D = this.el.object3D;
object3D.rotateX(.20 * timeDelta * 0.1);
}
});