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
|
"use strict";
Cubie.prototype.explosion = 0.55;
Cubie.prototype.setPos = function(x,y,z)
{
this.mesh.position.set(x * Cubie.prototype.explosion,
y * Cubie.prototype.explosion,
z * Cubie.prototype.explosion);
};
Cubie.prototype.updateExplosion = function()
{
this.setPos(this.normPos[0],this.normPos[1],this.normPos[2]);
};
Cubie.prototype.updatePosition = function(pos)
{
this.mesh.position.set((((Math.floor(pos/2) % 2) * (-2)) + 1) * Cubie.prototype.explosion,
((Math.floor(pos/4) * (-2)) + 1) * Cubie.prototype.explosion,
(((Math.floor((pos+1)/2) % 2) * (-2)) + 1) * Cubie.prototype.explosion);
};
Cubie.prototype.getPos = function()
{
return [this.mesh.position.x, this.mesh.position.y, this.mesh.position.z];
};
function Cubie(key,pos,colors)
{
this.key = key;
this.pos = pos;
this.colors = colors;
var materials = new Array(6);
var us = new Array(6);
for(var i = 0; i < materials.length; i++)
{
materials[i] = new THREE.MeshBasicMaterial({ color: 0x000000, side: THREE.FrontSide });
}
for(var i = 0; i < colors.length; i++)
{
materials[colors[i].key] = new THREE.MeshBasicMaterial({ color: textures[colors[i].value], side: THREE.FrontSide });
}
this.normPos = [0.0,0.0,0.0];
this.geometry = new THREE.BoxGeometry(1.0,1.0,1.0);
this.material = new THREE.MeshFaceMaterial(materials);
this.mesh = new THREE.Mesh(this.geometry,this.material);
this.normPos = [(((Math.floor(this.pos/2) % 2) * (-2)) + 1),
((Math.floor(this.pos/4) * (-2)) + 1),
(((Math.floor((this.pos+1)/2) % 2) * (-2)) + 1)];
this.mesh.position.set((((Math.floor(pos/2) % 2) * (-2)) + 1) * Cubie.prototype.explosion,
((Math.floor(pos/4) * (-2)) + 1) * Cubie.prototype.explosion,
(((Math.floor((pos+1)/2) % 2) * (-2)) + 1) * Cubie.prototype.explosion);
}
|