Math.radians = function(degrees) { return degrees * Math.PI / 180; }; var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); var posCenter = [0, 0]; var box_width = 30; var box_height = 50; var box_depth = 2; var facettes = []; var material; var pivots=[]; var depth = (Math.sqrt(3)/2) * box_width var cell = new THREE.Object3D(); scene.add(cell); for(var i=0; i<6;i++) { pivots[i] = new THREE.Object3D(); cell.add(pivots[i]); //material = new THREE.MeshLambertMaterial( { color: 0xccccff } ); var geometry = new THREE.BoxGeometry( box_width, box_height, box_depth); facettes[i] = new THREE.Mesh( geometry, material ); pivots[i].add( facettes[i] ); facettes[i].position.set(0, 0, depth); switch(i) { case 0: pivots[i].rotation.y= Math.radians(0*60); break; case 1: pivots[i].rotation.y= Math.radians(1*60); break; case 2: pivots[i].rotation.y= Math.radians(2*60); break; case 3: pivots[i].rotation.y= Math.radians(3*60); break; case 4: pivots[i].rotation.y= Math.radians(4*60); break; case 5: pivots[i].rotation.y= Math.radians(5*60); break; default: facettes[i].position.set(10000,10000,10000); facettes[i].rotation.y=Math.radians(-90); break; } } // create a point light var pointLight = new THREE.PointLight(0xFFFFFF, 1); // set its position pointLight.position.x = 10; pointLight.position.y = 50; pointLight.position.z = 200; // add to the scene scene.add(pointLight); //camera.position.x = 100; //camera.position.y = 100; camera.position.z = 10; camera.position.x = 0; camera.position.y = 80; camera.rotation.x = -Math.radians(90); var controls = new THREE.OrbitControls( camera, renderer.domElement ); controls.enableDamping = true; controls.dampingFactor = 0.25; controls.enableZoom = false; function render() { requestAnimationFrame( render ); //cell.rotation.y +=0.05; renderer.render( scene, camera ); controls.update(); } render();