diff options
| Commit | 9dcdcfae369037ab9eb139a55c1127a79eecf553 (patch) | |
|---|---|---|
| Author | 2022-11-26 16:26:19 +0200 | |
| Committer | 2022-11-26 16:26:19 +0200 | |
| Files | 81a953157c7002d3c80dd3e5bd8a583f7fec1584 | |
| uni-projects-9dcdcfae369037ab9eb139a55c1127a79eecf553.tar uni-projects-9dcdcfae369037ab9eb139a55c1127a79eecf553.tar.gz uni-projects-9dcdcfae369037ab9eb139a55c1127a79eecf553.zip | ||
| Parent | 5e7bf3719d15769c89549d2b003178f8f64ab2d4 (diff) | |
[OKG/HW06] Solved homework
1 files changed, 126 insertions, 0 deletions
| -rw-r--r-- | Year 2/Computer Graphics Fundamentals/Practicum Homework/a06.html | 126 |
diff --git a/Year 2/Computer Graphics Fundamentals/Practicum Homework/a06.html b/Year 2/Computer Graphics Fundamentals/Practicum Homework/a06.html new file mode 100644 index 0000000..c2ba203 --- /dev/null +++ b/Year 2/Computer Graphics Fundamentals/Practicum Homework/a06.html @@ -0,0 +1,126 @@ +<html>
+ <head>
+ <style>
+ body { margin: 0; }
+ canvas { width: 100%; height: 100% }
+ </style>
+ </head>
+ <body>
+ <script src="three.min.js"></script>
+ <script src="CSG.js"></script>
+ <script>
+ var renderer = new THREE.WebGLRenderer();
+ renderer.setSize( window.innerWidth, window.innerHeight );
+ renderer.setAnimationLoop( drawFrame );
+ renderer.shadowMap.enabled = true;
+ renderer.shadowMap.type = THREE.PCFSoftShadowMap;
+ 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( 2, 1.5, 0 );
+ camera.lookAt( new THREE.Vector3(0, 0.35, 0) );
+
+ var statue = new THREE.Group();
+ var statueMaterial = new THREE.MeshPhongMaterial({ color: 0xa3a39f, flatShading: true });
+ var darkStatueMaterial = new THREE.MeshPhongMaterial({ color: 0x525456, flatShading: true });
+
+ var base = new THREE.Mesh(new THREE.BoxGeometry(0.2, 0.25, 0.2), statueMaterial);
+ base.position.y = -0.125;
+ statue.add(base);
+
+ var body = new THREE.Mesh(new THREE.BoxGeometry(0.15, 0.6, 0.09, 10), statueMaterial);
+ body.position.y = 0.3;
+ statue.add(body);
+
+ var robeFoldLong = new THREE.Mesh(new THREE.BoxGeometry(0.04, 0.45, 0.08), statueMaterial);
+ robeFoldLong.position.set(-0.03, 0.23, 0.08 - 0.05);
+ robeFoldLong.rotation.z = Math.PI / 96;
+ statue.add(robeFoldLong.clone());
+ robeFoldLong.position.x = 0.03;
+ robeFoldLong.rotation.z = -Math.PI / 96;
+ statue.add(robeFoldLong.clone());
+
+ var robeFoldShoulder = new THREE.Mesh(new THREE.BoxGeometry(0.045, 0.15, 0.09), statueMaterial);
+ robeFoldShoulder.position.set(-0.04, 0.4 + 0.13, 0.09 - 0.05);
+ robeFoldShoulder.rotation.set(-Math.PI / 32, 0 , Math.PI / 64);
+ statue.add(robeFoldShoulder.clone());
+ robeFoldShoulder.position.x *= -1;
+ robeFoldShoulder.rotation.z *= -1;
+ statue.add(robeFoldShoulder);
+
+ var arm = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.015, 0.21), statueMaterial);
+ arm.position.set(-0.1, 0.65, 0.01);
+ arm.rotation.set(-Math.PI / 100, 0, Math.PI / 8 - Math.PI);
+
+ var armRobeFold = new THREE.Mesh(new THREE.BoxGeometry(0.04, 0.18, 0.04), statueMaterial);
+ armRobeFold.position.set(0, 0, 0.02);
+ armRobeFold.rotation.x = Math.PI / 16;
+ armRobeFold.rotation.z = Math.PI / 60;
+ arm.add(armRobeFold);
+ var hand = new THREE.Mesh(new THREE.BoxGeometry(0.03, 0.03, 0.03), darkStatueMaterial);
+ hand.position.set(0, -0.115, 0);
+ var torch = new THREE.Mesh(new THREE.BoxGeometry(0.025, 0.13, 0.025), darkStatueMaterial);
+ torch.rotation.x = -Math.PI / 2;
+ torch.position.y = -0.025;
+ hand.add(torch);
+ hand.rotation.x = -Math.PI / 2.2;
+ hand.rotation.y = Math.PI / 16;
+ arm.add(hand);
+
+ statue.add(arm.clone());
+ arm.position.x *= -1;
+ arm.rotation.z *= -1;
+ armRobeFold.rotation.z *= -1;
+ hand.rotation.y *= -1;
+ statue.add(arm);
+
+ var head = new THREE.Mesh(new THREE.BoxGeometry(0.05, 0.08, 0.05), darkStatueMaterial);
+ head.position.set(0, 0.6 + 0.04, 0);
+ statue.add(head);
+
+ var foot = new THREE.Mesh(new THREE.BoxGeometry(0.04, 0.04, 0.05), darkStatueMaterial);
+ foot.rotation.y = -Math.PI / 8;
+ foot.position.set(-0.05, 0, 0.05);
+ statue.add(foot.clone());
+ foot.rotation.y *= -1;
+ foot.position.x *= -1;
+ statue.add(foot);
+
+
+
+ scene.add(statue);
+
+ var light = new THREE.PointLight(0xffffff, 0.25);
+ light.position.set(1,2,3);
+ light.castShadow = true;
+ light.target = statue;
+ scene.add(light.clone());
+ light.position.x = -1;
+ light.position.y = 0;
+ scene.add(light);
+
+
+ var ambient = new THREE.AmbientLight(0xffffff, 0.5);
+ scene.add(ambient);
+
+ var count = 0;
+ var rotationCoef = 200;
+ scene.rotation.y = Math.PI / 6;
+ function drawFrame()
+ {
+ if (count < rotationCoef)
+ scene.rotation.y += 0.009;
+ else if (count > 2 * rotationCoef)
+ count = 0;
+ else
+ scene.rotation.y -= 0.009;
+
+ count += 1;
+ renderer.render( scene, camera );
+ }
+ </script>
+ </body>
+</html>
|
