feat: cube colours
This commit is contained in:
		
							parent
							
								
									908a38cfd1
								
							
						
					
					
						commit
						6620f20372
					
				
							
								
								
									
										11
									
								
								main.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								main.js
									
									
									
									
									
								
							@ -25,9 +25,14 @@ const controls = new OrbitControls(camera, renderer.domElement);
 | 
			
		||||
controls.enableDamping = true;
 | 
			
		||||
controls.update();
 | 
			
		||||
 | 
			
		||||
function makeCube(xCoord) {
 | 
			
		||||
// Make materials
 | 
			
		||||
const redMaterial = new THREE.MeshLambertMaterial({ color: 0xff0000 });
 | 
			
		||||
const greenMaterial = new THREE.MeshLambertMaterial({ color: 0x00ff00 });
 | 
			
		||||
const blueMaterial = new THREE.MeshLambertMaterial({ color: 0x0000ff });
 | 
			
		||||
const materials = [redMaterial, greenMaterial, blueMaterial];
 | 
			
		||||
 | 
			
		||||
function makeCube(xCoord, material) {
 | 
			
		||||
    const geometry = new THREE.BoxGeometry();
 | 
			
		||||
    const material = new THREE.MeshLambertMaterial({ color: 0x00ff00 });
 | 
			
		||||
    const cube = new THREE.Mesh(geometry, material);
 | 
			
		||||
    cube.position.set(xCoord, 0, 0);
 | 
			
		||||
    scene.add(cube);
 | 
			
		||||
@ -37,7 +42,7 @@ function makeCube(xCoord) {
 | 
			
		||||
 | 
			
		||||
let cubes = [];
 | 
			
		||||
for (let i = 0; i < 3; i++) {
 | 
			
		||||
    const cube = makeCube((i - 1)*2);
 | 
			
		||||
    const cube = makeCube((i - 1)*2, materials[i]);
 | 
			
		||||
    cubes.push(cube);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user