From 9063312de28be28c1ee7fdcfce6266706dcdbdba Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 22 Nov 2022 09:38:43 +0200 Subject: [OKG/HWK2] Posture A can now be taken from the mannequin itself --- .../Homework 2/mannequin.html | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html b/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html index cd529aa..5aad4d2 100644 --- a/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html +++ b/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html @@ -44,7 +44,7 @@ var aspect = window.innerWidth/window.innerHeight; var camera = new THREE.PerspectiveCamera( 30, aspect ); camera.position.set( 400, 50, 90 ); - var camLookAt = lookingDirectionVec(camera, [-1, 0, 0]); + var camLookAt = lookingDirectionVec(camera, [-10, 0, 0]); camera.lookAt( camLookAt ); function onWindowResize(event) @@ -118,7 +118,6 @@ koichi.l_arm.turn = 90; scene.add(koichi); - var middleBuilding = new THREE.Group(); var patio = new THREE.Mesh(new THREE.BoxGeometry(300, 1, 300), new THREE.MeshPhongMaterial({ color: 0x978661 })); @@ -197,10 +196,10 @@ iscamera : false, mannequin : instr[1], - A : instr[2], + A : (instr[2]) ? instr[2] : fixPostureY(instr[1].posture), B : instr[3], cpos : instr[1].position.clone(), - npos : (instr.length === 4) ? null : vecSum(instr[1].position, instr[4]), + npos : (instr.length === 4 || !instr[4]) ? null : vecSum(instr[1].position, instr[4]), }); } } @@ -212,9 +211,9 @@ var blendPer = (t - mo.start) / mo.end; if (!mo.iscamera) { - if (mo.A && mo.B) + if (mo.B) mo.mannequin.posture = Mannequin.blend(mo.A, mo.B, blendPer); - if (mo.cpos) + if (mo.npos) mo.mannequin.position.set(...vecBlend(mo.cpos, mo.npos, blendPer)); } else { @@ -223,7 +222,6 @@ } if (mo.camwatch !== null) { camLookAt = new THREE.Vector3(...vecBlend(mo.camwatold, mo.camwatch, blendPer)); - console.log(camLookAt); camera.lookAt(camLookAt); } } @@ -300,6 +298,11 @@ return [a.x, a.y, a.z]; } + function fixPostureY(p) { + p.data[0] = 0; + return p; + } + /* * За функции, генериращи обекти */ @@ -530,7 +533,6 @@ brim.position.y = -1.5; hat.add(brim); - return jotaro; } @@ -650,18 +652,26 @@ ** Анимационни действия **/ + const DEFAULT_POSTURE = {"version":6,"data":[0,[0,-90,0],[0,0,-2],[0,0,5],[6,0,0],[0],[-6,-6,-0.6],[-6,0,0],[0],[6,6,-0.6],[7,-0.6,-5],[15],[-15,0,0],[10,10],[-7,0.6,-5],[15],[15,0,0],[10,10]]}; + var animationData = { 0: [ [ - 10, jotaro, - {"version":6,"data":[3.8,[0,-90,0],[0,0,-2],[0,0,5],[6,0,0],[0],[-6,-6,-0.6],[-6,0,0],[0],[6,6,-0.6],[7,-0.6,-5],[15],[-15,0,0],[10,10],[-7,0.6,-5],[15],[15,0,0],[10,10]]}, - {"version":6,"data":[3.8,[0,-90,0],[-1.3,0,-2],[0,0,5],[6,0,0],[0],[-6,-6,-0.6],[-6,0,0],[0],[6,6,-0.6],[7,-0.6,-5],[15],[-15,0,0],[10,10],[-86.8,50.3,65.1],[15],[15,0,0],[10,10]]}, - { x: 100, y: -10, z: 0 } + 5, jotaro, + null, + {"version":6,"data":[0,[0,-90,0],[-1.3,0,-2],[0,0,5],[6,0,0],[0],[-6,-6,-0.6],[-6,0,0],[0],[6,6,-0.6],[7,-0.6,-5],[15],[-15,0,0],[10,10],[-86.8,50.3,65.1],[15],[15,0,0],[10,10]]}, ], [ - 10, [50, 0, 0], [0, -10, 0], false + 3, [50, 0, 0], [0, -10, 0], false + ] + ], + 5.01: [ + [ + 3, jotaro, + null, + {"version":6,"data":[0,[0,-90,0],[0,0,-2],[0,0,5],[6,0,0],[0],[-6,-6,-0.6],[-6,0,0],[0],[6,6,-0.6],[-38.1,-66.6,-62],[15],[-15,0,0],[10,10],[89.2,85,-124.8],[15],[15,0,0],[10,10]]} ] - ] + ], }; -- cgit v1.3.1-23-gd82d