Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit21122fa3f283ff000967b57fdb3bc4bd0358e241 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-11-14 23:00:51 +0200
Committer
 Syndamia <kamen@syndamia.com>
2022-11-14 23:00:51 +0200
Filesc9de11f8b10ed5ffafe58954d2e342bfb65fb78a
uni-projects-21122fa3f283ff000967b57fdb3bc4bd0358e241.tar
uni-projects-21122fa3f283ff000967b57fdb3bc4bd0358e241.tar.gz
uni-projects-21122fa3f283ff000967b57fdb3bc4bd0358e241.zip
Parent994ab130cdfc579ce04ce880ebd73bf06174070e (diff)
[OKG/HWK1] Added table and started work on mini telescope
1 files changed, 66 insertions, 2 deletions
-rw-r--r--Year 2/Computer Graphics Fundamentals/Homework 1/moidom-6.html68
diff --git a/Year 2/Computer Graphics Fundamentals/Homework 1/moidom-6.html b/Year 2/Computer Graphics Fundamentals/Homework 1/moidom-6.html
index 2e3c08a..0d985e3 100644
--- a/Year 2/Computer Graphics Fundamentals/Homework 1/moidom-6.html
+++ b/Year 2/Computer Graphics Fundamentals/Homework 1/moidom-6.html
@@ -71,10 +71,11 @@
function wall(length, rotation, holes, position) {
const height = 3.10;
const width = 0.20;
- const color = 'darkgray';
+ const color = 0xf0fff0;
var wall = new THREE.Mesh(new THREE.BoxGeometry(length, height, width),
new THREE.MeshPhongMaterial({ color: color }));
+
if (holes !== undefined && holes.length >= 0) {
var wallCSG = new CSG();
wallCSG.subtract([wall]);
@@ -92,6 +93,66 @@
return wall;
}
+ function table(width, depth, height, position) {
+ const thickness = 0.25;
+ const legWidth = 0.10;
+ const tableLip = 0.08;
+ const color = 0x55342b;
+
+ var material = new THREE.MeshPhongMaterial({ color: color });
+ var tableTop = new THREE.Mesh(new THREE.BoxGeometry(width, thickness, depth), material);
+ tableTop.position.y = height - thickness / 2;
+
+ var tableCSG = new CSG();
+
+ var tableLeg = new THREE.Mesh(new THREE.BoxGeometry(legWidth, height - thickness, legWidth), material);
+ tableLeg.position.set(width / 2 - legWidth / 2 - tableLip, (height - thickness) / 2, depth / 2 - legWidth / 2 - tableLip);
+ tableCSG.union([tableTop, tableLeg]);
+ tableLeg.position.set(-width / 2 + legWidth / 2 + tableLip, (height - thickness) / 2, depth / 2 - legWidth / 2 - tableLip);
+ tableCSG.union([tableLeg]);
+ tableLeg.position.set(-width / 2 + legWidth / 2 + tableLip, (height - thickness) / 2, -depth / 2 + legWidth / 2 + tableLip);
+ tableCSG.union([tableLeg]);
+ tableLeg.position.set(width / 2 - legWidth / 2 - tableLip, (height - thickness) / 2, -depth / 2 + legWidth / 2 + tableLip);
+ tableCSG.union([tableLeg]);
+
+ var table = tableCSG.toMesh();
+ if (position !== undefined)
+ table.position.set(...position);
+ return table;
+ }
+
+ function miniTelescope(position) {
+ const scopeEyeWidth = 0.10;
+ const scopeEndWidth = 0.15;
+ const scopeLength = 1.0;
+ const scopeColor = 0xD1DBDD;
+ const scopeHeight = 0.15;
+ const legWidth = 0.05;
+ const legAngle = 7/4 * Math.PI / 2;;
+ const legColor = 'black';
+
+ var teleBody = new THREE.Mesh(new THREE.CylinderGeometry(scopeEyeWidth, scopeEndWidth, scopeLength),
+ new THREE.MeshPhongMaterial({ color: scopeColor }));
+ teleBody.position.y = scopeHeight + scopeEyeWidth / 2;
+ teleBody.rotation.x = 5/4 * Math.PI / 2;
+
+ var teleLeg = new THREE.Mesh(new THREE.CylinderGeometry(legWidth, legWidth, scopeHeight / Math.sin(legAngle)),
+ new THREE.MeshPhongMaterial({ color: legColor }));
+ teleLeg.rotation.x = legAngle;
+
+ var telescope = new THREE.Group();
+ telescope.add(teleBody);
+ telescope.add(teleLeg.clone());
+ teleLeg.rotation.y += 1/3 * 2 * Math.PI;
+ telescope.add(teleLeg.clone());
+ teleLeg.rotation.y += 1/3 * 2 * Math.PI;
+ telescope.add(teleLeg.clone());
+
+ if (position !== undefined)
+ telescope.position.set(...position);
+ return telescope;
+ }
+
/*
* Сцена
*/
@@ -147,8 +208,11 @@
wall(5, -1, [doorHole([1,0,0])]),
], [5, 0, -0.5]);
+ /* Стаи */
-
+ var livingRoom = hNewGroup([
+ table(1, 1.5, 1, [-3.3,0,1.5]), miniTelescope([0,1,0]),
+ ], [-2,0,4]);