diff options
[OKG] Solved practice 02 exercises
1 files changed, 50 insertions, 0 deletions
| -rw-r--r-- | Year 2/Computer Graphics Fundamentals/02-Practice-10.10.2022/06.js | 50 |
diff --git a/Year 2/Computer Graphics Fundamentals/02-Practice-10.10.2022/06.js b/Year 2/Computer Graphics Fundamentals/02-Practice-10.10.2022/06.js new file mode 100644 index 0000000..2cf5d8f --- /dev/null +++ b/Year 2/Computer Graphics Fundamentals/02-Practice-10.10.2022/06.js @@ -0,0 +1,50 @@ +// Задача: направете конструкция, която изглежда +// като голям куб, от върховете на който са +// изрязани кубчета във вътрешните върхове на +// които пък са добавени още по-малки кубчета. +// Броят геометрични обекти да е под 10. + +var renderer = new THREE.WebGLRenderer(); +renderer.setSize( window.innerWidth, window.innerHeight ); +renderer.setAnimationLoop( drawFrame ); +document.body.appendChild( renderer.domElement ); + +var scene = new THREE.Scene(); + +var aspect = window.innerWidth/window.innerHeight; +var camera = new THREE.PerspectiveCamera( 30, aspect ); +camera.position.set( 12, 14, 28 ); +camera.lookAt( new THREE.Vector3() ); + + + +var material = new THREE.MeshPhongMaterial( ); + +function newBox(w, h, d) { + var geometry = new THREE.BoxGeometry( w, h, d ); + var obj = new THREE.Mesh( geometry, material ); + scene.add( obj ); +} + +newBox(9, 9, 9); +newBox(10, 10, 8); +newBox(8, 10, 10); +newBox(10, 8, 10); + + + +var light = new THREE.PointLight( ); +light.position.set( 17, 14, 11 ); +scene.add( light ); + +light = new THREE.PointLight( ); +light.position.set( -17, -14, -11 ); +scene.add( light ); + + +function drawFrame() +{ + scene.rotation.x += 0.005; + scene.rotation.y += 0.005; + renderer.render( scene, camera ); +} |
