// Задача: конструирайте ... мистериозния обект // с трите различни профила var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setAnimationLoop( drawFrame ); document.body.appendChild( renderer.domElement ); var scene = new THREE.Scene(); scene.background = new THREE.Color( 'lightgray' ); var aspect = window.innerWidth/window.innerHeight; camera = new THREE.PerspectiveCamera( 30, aspect ); camera.position.set( 0, 0, 60 ); camera.lookAt( new THREE.Vector3( 0, -2, 0 ) ); // цилиндър var material = new THREE.MeshPhongMaterial({ color: 'dimgray', shininess: 100, specular: 'dimgray' }); var cylinder = new THREE.Mesh(new THREE.CylinderGeometry( 10, 10, 15, 160 ), material); var hole = new THREE.Mesh(new THREE.CylinderGeometry(6, 6, 15, 160)); var frontRec1 = new THREE.Mesh(new THREE.BoxGeometry(20, 5, 20)); frontRec1.position.y = 5; frontRec1.position.z = 4; var frontRec2 = new THREE.Mesh(new THREE.BoxGeometry(5, 5, 20)); frontRec2.position.y = 5; frontRec2.position.x = 6; var frontRec3 = new THREE.Mesh(new THREE.BoxGeometry(5, 5, 20)); frontRec3.position.y = 5; frontRec3.position.x = -6; var backRec1 = new THREE.Mesh(new THREE.BoxGeometry(20, 5, 20)); backRec1.position.y = -5; backRec1.position.z = -4; var backRec2 = new THREE.Mesh(new THREE.BoxGeometry(5, 5, 20)); backRec2.position.y = -5; backRec2.position.x = 6; var backRec3 = new THREE.Mesh(new THREE.BoxGeometry(5, 5, 20)); backRec3.position.y = -5; backRec3.position.x = -6; var csg = new CSG(); csg.subtract([cylinder, hole, frontRec1, frontRec2, frontRec3, backRec1, backRec2, backRec3]); var mystery = csg.toMesh(); mystery.material = material; scene.add( mystery ); // светлини light1 = new THREE.PointLight( 'white', 0.5 ); light1.position.set( 0, 100, 50 ); scene.add( light1 ); light2 = new THREE.PointLight(' white', 0.5 ); light2.position.set( 0, 0, 0 ); scene.add( light2 ); light3 = new THREE.PointLight( 'white', 0.5); light3.position.set( 0, -100, 50 ); scene.add( light3 ); light4 = new THREE.PointLight(' white', 0.5 ); light4.position.set( 0, 0, 100 ); scene.add( light4 ); // стига толкова светлини function drawFrame() { // въртим мистериозния обект mystery.rotation.x += 0.005; mystery.rotation.y += 0.004; mystery.rotation.z += 0.003; renderer.render( scene, camera ); }