"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); }