diff --git a/year4/semester1/CT404: Graphics & Image Processing/materials/week3/24_03_Animation_Interaction_Shading_Materials.pdf b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/24_03_Animation_Interaction_Shading_Materials.pdf new file mode 100644 index 00000000..d72d0148 Binary files /dev/null and b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/24_03_Animation_Interaction_Shading_Materials.pdf differ diff --git a/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/Threejs-22-lights-examples.html b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/Threejs-22-lights-examples.html new file mode 100644 index 00000000..35dda3b4 --- /dev/null +++ b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/Threejs-22-lights-examples.html @@ -0,0 +1,141 @@ + + + + + + + + + + +
+ + + + +
+ + diff --git a/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/Threejs-23-materials-examples.html b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/Threejs-23-materials-examples.html new file mode 100644 index 00000000..42e45ca1 --- /dev/null +++ b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/Threejs-23-materials-examples.html @@ -0,0 +1,115 @@ + + + + + + + + + + + + diff --git a/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/Threejs-25-lights-and-shadows.html b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/Threejs-25-lights-and-shadows.html new file mode 100644 index 00000000..0dba7c88 --- /dev/null +++ b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/Threejs-25-lights-and-shadows.html @@ -0,0 +1,153 @@ + + + + + + + + + + +
+ + + + +
+ + diff --git a/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasAnimationExample1.html b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasAnimationExample1.html new file mode 100644 index 00000000..1150cd66 --- /dev/null +++ b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasAnimationExample1.html @@ -0,0 +1,44 @@ + + + + + + + + + diff --git a/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasAnimationExample1_withSmootherAnimation.html b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasAnimationExample1_withSmootherAnimation.html new file mode 100644 index 00000000..310190c1 --- /dev/null +++ b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasAnimationExample1_withSmootherAnimation.html @@ -0,0 +1,47 @@ + + + + + + + + + diff --git a/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasAnimationExample2.html b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasAnimationExample2.html new file mode 100644 index 00000000..f680348f --- /dev/null +++ b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasAnimationExample2.html @@ -0,0 +1,59 @@ + + + + + + + + + diff --git a/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasWithKeyboardExample.html b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasWithKeyboardExample.html new file mode 100644 index 00000000..bf508024 --- /dev/null +++ b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasWithKeyboardExample.html @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasWithMouseExample.html b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasWithMouseExample.html new file mode 100644 index 00000000..5bc1aa3b --- /dev/null +++ b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/canvasWithMouseExample.html @@ -0,0 +1,45 @@ + + + + + + + hello
+
+ + + diff --git a/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/orientation-interpolator.js b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/orientation-interpolator.js new file mode 100644 index 00000000..7eaee433 --- /dev/null +++ b/year4/semester1/CT404: Graphics & Image Processing/materials/week3/examples/orientation-interpolator.js @@ -0,0 +1,41 @@ + +'use strict' + +// class constructor +function orientationInterpolator(data) { + this.startTime = Date.now(); // milliseconds since Jan 1st 1970 + this.data = data; + this.keyframe1 = 0; + this.keyframe2 = 1; +} + +orientationInterpolator.prototype.getEulerAngles = function() { + var now = Date.now(); + var elapsed = now-this.startTime; + while (elapsed>=this.data.times[this.keyframe2]) { + this.keyframe1++; + this.keyframe2++; + if (this.keyframe2>=this.data.times.length) { // loop back to keyframe 0 + var timeSinceLastFrame = elapsed - this.data.times[this.keyframe1]; + this.startTime = now - timeSinceLastFrame; + this.keyframe1 = 0; + this.keyframe2 = 1; + elapsed = now-this.startTime; + } + } + + var timeBetweenKeyFrames = this.data.times[this.keyframe2] - this.data.times[this.keyframe1]; + var timeSinceKeyframe1 = elapsed - this.data.times[this.keyframe1]; + var fractionBetweenFrames = timeSinceKeyframe1/timeBetweenKeyFrames; + var frame1rot = this.data.angles[this.keyframe1]; + var frame2rot = this.data.angles[this.keyframe2]; + + var rot = { + x: frame1rot.x*(1-fractionBetweenFrames) + frame2rot.x*fractionBetweenFrames, + y: frame1rot.y*(1-fractionBetweenFrames) + frame2rot.y*fractionBetweenFrames, + z: frame1rot.z*(1-fractionBetweenFrames) + frame2rot.z*fractionBetweenFrames + }; + + return rot; +}; +