Created
July 10, 2012 21:04
-
-
Save mlamina/3086225 to your computer and use it in GitHub Desktop.
Methode um eine bestimmte Anzahl von 3D Wuerfeln gleichmaeßig in einem groeßeren Wuerfel zu platzieren.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createCoreCubes : function(numCores) { | |
// CPU Cubes | |
this._cpuCubes = []; | |
var NUM_CUBES = numCores || CONFIG.nodeCoreCount, | |
NUM_COLS = Math.floor( Math.sqrt( NUM_CUBES ) ), | |
rowcount = 0, | |
GAP_SIZE = (this._width - hana.stats.constants.CUBE_SIZE*NUM_COLS) / (NUM_COLS + 1) ; | |
var | |
geometry = new THREE.CubeGeometry( | |
hana.stats.constants.CUBE_SIZE, | |
hana.stats.constants.CUBE_SIZE / 2, | |
hana.stats.constants.CUBE_SIZE ), | |
marginX = this._width/2 - (hana.stats.constants.CUBE_SIZE*NUM_COLS + (GAP_SIZE)*(NUM_COLS - 1)) / 2, | |
marginZ = this._depth/2 - (hana.stats.constants.CUBE_SIZE*(NUM_COLS+1) + (GAP_SIZE)*(NUM_COLS)) / 2; | |
for ( var i = 0; i < NUM_CUBES; i ++ ) { | |
//log(material); | |
var cube = new hana.stats.CpuCube( geometry, { | |
x: marginX + Math.floor( (hana.stats.constants.CUBE_SIZE + GAP_SIZE) * ( i % NUM_COLS ) - this._width/2), | |
y: 0, | |
z: marginZ + Math.floor( rowcount * (hana.stats.constants.CUBE_SIZE + GAP_SIZE) - this._depth/2 ) | |
}, this._height, { x: -this._width/2 }); | |
this.mesh.add(cube.mesh); | |
this._cpuCubes.push(cube); | |
if ((i+1) % NUM_COLS == 0) rowcount++; | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment