diff options
| Commit | 11b566156c77121cd42428617e92d084f517de7f (patch) | |
|---|---|---|
| Author | 2022-11-28 17:09:52 +0200 | |
| Committer | 2022-11-28 17:09:52 +0200 | |
| Files | ffd10a2eb57abdbe80598b102ab0fdd098d94b4b | |
| uni-projects-11b566156c77121cd42428617e92d084f517de7f.tar uni-projects-11b566156c77121cd42428617e92d084f517de7f.tar.gz uni-projects-11b566156c77121cd42428617e92d084f517de7f.zip | ||
| Parent | f74c1bf3f775c6d149195e8865778c1fc84fd217 (diff) | |
[OKG/HWK2] Camera instruction can now have null values
1 files changed, 8 insertions, 5 deletions
| -rw-r--r-- | Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html | 13 |
diff --git a/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html b/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html index ef6327a..da7f70c 100644 --- a/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html +++ b/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html @@ -179,15 +179,15 @@ function fillBacklog() {
for (var time in animationData) {
for (var instruction of animationData[time]) {
- if (instruction[1].constructor === Array) {
+ if (typeof instruction[3] == "boolean") {
executeBacklog.push({
start : Number(time),
end : Number(time) + instruction[0],
iscamera : true,
- camposold : vecToArr(camera.position),
+ camposold : null,
campos : (instruction[3] || !instruction[1]) ? instruction[1] : arrSum(vecToArr(camera.position), instruction[1]),
- camwatold : camLookAt.clone(),
+ camwatold : null,
camwatch : arrToVec(((instruction[3] || !instruction[2]) ? instruction[2] : arrSum(vecToArr(camLookAt), instruction[2]))),
isabsol : instruction[3],
});
@@ -234,10 +234,12 @@ mo.mannequin.rotation.set(...vecBlend(mo.crot, mo.nrot, blendPer));
}
else {
- if (mo.campos !== null) {
+ if (!mo.camposold) mo.camposold = vecToArr(camera.position);
+ if (!mo.camwatold) mo.camwatold = camLookAt.clone();
+ if (mo.campos) {
camera.position.set(...arrBlend(mo.camposold, mo.campos, blendPer));
}
- if (mo.camwatch !== null) {
+ if (mo.camwatch) {
camLookAt = new THREE.Vector3(...vecBlend(mo.camwatold, mo.camwatch, blendPer));
camera.lookAt(camLookAt);
}
@@ -319,6 +321,7 @@ }
function arrToVec(a) {
+ if (!a) return a;
return {
x: a[0],
y: a[1],
|
