-
Notifications
You must be signed in to change notification settings - Fork 0
/
Octorok.js
110 lines (88 loc) · 3.05 KB
/
Octorok.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
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
import * as THREE from './libs/three.module.js'
import { MTLLoader } from './libs/MTLLoader.js'
import { OBJLoader } from './libs/OBJLoader.js'
import {Enemigo} from './Enemigo.js'
class Octorok extends Enemigo{
constructor(){
super();
var that = this;
var materiaLoader = new MTLLoader();
var objectLoader = new OBJLoader();
materiaLoader.load('models/octorok/octorok.mtl',
function(materials){
objectLoader.setMaterials(materials);
objectLoader.load('models/octorok/octorok.obj',
function(object){
var modelo = object;
var modelo = object
modelo.scale.set(200,200,200)
that.add(modelo);
},null,null);
});
var geometry = new THREE.BoxGeometry( 5.5, 10, 5.5 );
var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
this.cube = new THREE.Mesh( geometry, material );
this.cube.visible = false
this.add(this.cube)
this.fin_recorrido_z = false
this.fin_recorrido_x = true
this.fin_recorrido_z_2 = true
this.fin_recorrido_x_2 = true
this.signo_recorrido_z = +1
this.signo_recorrido_x = +1
this.orientacion = Octorok.LOOK_AT_DOWN;
this.name = 'Octorok'
}
rutaOctorok(){
if(!this.fin_recorrido_z){
if((this.position.z | 0) == 10){
this.fin_recorrido_z = true
this.fin_recorrido_x = false
this.rotateY(Math.PI/2)
this.orientacion = Octorok.LOOK_AT_RIGHT;
}
if(!this.fin_recorrido_z){
this.orientacion = Octorok.LOOK_AT_DOWN
this.position.z += 0.15
}
}
if(!this.fin_recorrido_x){
if((this.position.x | 0) == 12){
this.fin_recorrido_x = true
this.fin_recorrido_z_2 = false
this.rotateY(Math.PI/2)
this.orientacion = Octorok.LOOK_AT_UP;
}
if(!this.fin_recorrido_x){
this.position.x += 0.15
}
}
if(!this.fin_recorrido_z_2){
if((this.position.z | 0) == 0){
this.fin_recorrido_z_2 = true
this.fin_recorrido_x_2 = false
this.rotateY(Math.PI/2)
this.orientacion = Octorok.LOOK_AT_LEFT;
}
if(!this.fin_recorrido_z_2){
this.position.z -= 0.15
}
}
if(!this.fin_recorrido_x_2){
if((this.position.x | 0) == 0){
this.fin_recorrido_x_2 = true
this.fin_recorrido_z = false
this.rotateY(Math.PI/2)
}
if(!this.fin_recorrido_x_2){
this.position.x -= 0.15
}
}
}
}
//Orientaciones de Link
Octorok.LOOK_AT_UP = 5;
Octorok.LOOK_AT_DOWN = 6;
Octorok.LOOK_AT_RIGHT = 7;
Octorok.LOOK_AT_LEFT = 8;
export { Octorok };