-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcockpit.js
35 lines (32 loc) · 877 Bytes
/
cockpit.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
35
/*!
* 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 cockpit of the plane to look cooler.
*/
AFRAME.registerComponent('cockpit', {
dependencies: ['geometry'],
schema: {
type: 'string',
default: 'normal'
},
update() {
const mesh = this.el.getOrCreateObject3D('mesh', THREE.Mesh);
if (this.data === 'cool') {
mesh.geometry.vertices[4].y -= 10;
mesh.geometry.vertices[4].z += 20;
mesh.geometry.vertices[5].y -= 10;
mesh.geometry.vertices[5].z -= 20;
mesh.geometry.vertices[6].y += 30;
mesh.geometry.vertices[6].z += 20;
mesh.geometry.vertices[7].y += 30;
mesh.geometry.vertices[7].z -= 20;
}
}
});