locked
move all the ccolored cubes in one corner RRS feed

  • Question

  • User186897 posted

    Hello

    I have below code which creates a cube out of cubes with a random transparent...I want to display the colored ones in one corner and transparent ones in the other corner of the cube...how do I do that

    if (resultlabel == 4) {
    				    var geometry = new THREE.BoxGeometry(50, 50, 50);
    
    				    var ax = ay = az = -400;
    
    
    
    				    for (var i = 0; i < 512; i++) {
    				        var newColor;
    				        var opaqueness = 0.8;
    				        var colornum = Math.floor(Math.random() * 4);
    				        if (colornum == 0) newColor = 0x04B45F;
    				        if (colornum == 1) {
    				            newColor = 0x04B45F;
    				            opaqueness = 0.05;
    				        }
    				        if (colornum == 2) {
    				            newColor = 0x04B45F;
    				            opaqueness = 0.05;
    				        }
    				        if (colornum == 3) {
    				            newColor = 0x04B45F;
    				            opaqueness = 0.05;
    				        }
    				        if (colornum == 4) 
    				            newColor = 0x04B45F;
    				            
    				        if (colornum == 5) {
    				            newColor = 0x04B45F;
    				            opaqueness = 0.05;
    				        }
    				        if (colornum == 3) 
    				            newColor = 0x04B45F;
    				            
    				        var object = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial({ color: newColor, transparent: true, opacity: opaqueness }));
    
    
    				        object.position.x = ax;
    				        object.position.y = ay;
    				        object.position.z = az;
    
    				        object.scale.x = 2;
    				        object.scale.y = 2;
    				        object.scale.z = 2;
    
    				        object.castShadow = true;
    				        object.receiveShadow = true;
    
    				        scene.add(object);
    
    				        objects.push(object);
    
    				        ax = ax + 100;
    				        if (ax > 300) {
    				            ax = -400;
    				            ay = ay + 100;
    				        }
    				        if (ay > 300) {
    				            ay = -400;
    				            az = az + 100;
    				        }
    
    				    }
    
    				}

    Monday, August 22, 2016 12:49 PM

All replies