From c012b272f5532386c7b887a526798454ed899062 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 21 Nov 2022 19:23:10 +0200 Subject: [OKG/HWK2] Added bushpots to tailor shop --- .../Homework 2/mannequin.html | 34 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html b/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html index 25e81e1..553dbe3 100644 --- a/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html +++ b/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html @@ -43,8 +43,8 @@ var aspect = window.innerWidth/window.innerHeight; var camera = new THREE.PerspectiveCamera( 30, aspect ); - camera.position.set( 0, 100, -200 ); - camera.lookAt( new THREE.Vector3(60, 50, 225) ); + camera.position.set( -200, 80, -100 ); + camera.lookAt( new THREE.Vector3(300, 50, 200) ); function onWindowResize(event) { @@ -122,7 +122,10 @@ patio.position.set(0, 1, -125 -150); scene.add(patio); - var tailorShop = newTailorShop(); + var tailorShop = new THREE.Group(); + tailorShop.add(newTailorShop()); + tailorShop.add(newBushPot(0xb29858, 30, 7, 10, 0, 55,-90-5)); + tailorShop.add(newBushPot(0xb29858, 30, 7, 10, 0, -55,-90-5)); tailorShop.position.set(60, 0, 225); scene.add(tailorShop); @@ -176,6 +179,31 @@ * Функции, генериращи обекти */ + function newBushPot(color, length, height, width, orientation, x, z) { + const density = 6; + const bushColor = 0x4d3573; + + var bushes = new THREE.Group(); + var bush = new THREE.Mesh(new THREE.SphereGeometry(width / 1.5), + new THREE.MeshPhongMaterial({ color: bushColor, flatShading: true })); + bush.position.y = height + width / 2 * 0.7; + for (var i = -length / 2 + width / 2; i <= length / 2 - width / 2; i += length / density) { + bush.position.x = i; + bushes.add(bush.clone()); + } + + var pot = new THREE.Mesh(new THREE.BoxGeometry(length, height, width), + new THREE.MeshPhongMaterial({ color: color })); + pot.position.y = height / 2; + + var bushPot = new THREE.Group(); + bushPot.add(bushes, pot); + bushPot.position.set(x, 0, z); + bushPot.rotation.y = orientation * Math.PI / 2; + + return bushPot; + } + function newTailorShop() { const size = 180; const bottomHeight = 25; -- cgit v1.3.1-26-gb76a