In this MP you will
This MP is core, with no elective components. It assumes you have already completed the Logo MP.
You will submit a webpage that has
Submit an HTML file and any number of js, css, glsl, and json files. No image files are permitted for this assignment. Do not include spaces in file names as the submission server does not process them well.
You are welcome to use a JavaScript math library, such as the one used in in-class examples or others you might know.
As with the Logo MP, there should be one HTML
file with one canvas element, scripts only in the head,
requestAnimation
animation, wrapWebGL2.js not producing any
warnings, motion via matrices, etc.
Make the canvas resize to fill the screen, and correct the aspect
ratio of the projection matrix to maintain an undistorted view. See the 3D example code for examples of how to
do this (notably in the fillScreen
function).
3D with depth and perspective
Enable depth tests. Render the scene such that the models are in view and seen from perspective.
Use exactly two models:
[[1,1,1], [-1,-1,1], [-1,1,-1], [1,-1,-1]]
[[1,1,1], [0,0,1], [0,1,0], [1,0,0]]
[[0,1,2], [0,2,3], [0,3,1], [1,2,3]]
[[1,0,0],[0,1,0],[0,0,1],[0,-1,0],[0,0,-1],[-1,0,0]]
[[1,0.5,0.5],[0.5,1,0.5],[0.5,0.5,1],[0.5,0,0.5],[0.5,0.5,0],[0,0.5,0.5]]
[[0,1,2], [0,2,3], [0,3,4], [0,4,1], [5,1,4], [5,4,3], [5,3,2], [5,2,1]]
Send each of these models to the GPU only once, drawing the same GPU copy multiple times per frame.
Orbiting and spinning bodies
Create a scene with the following:
the Sun)
the Earth)
Mars) a little smaller than the Earth
the Moon) smaller than the Earth
Phobos) smaller than Mars
Deimos) half the size of Phobos
Handle all of the motion described above by computing a model matrix for each body each frame in JavaScript and sending that single model matrix (possibly combined with a view and/or projection marix) to the GPU as a uniform.
Assembling Matrices
When multiplying matrices, put the most local motion on the right and the most global on the left. For example, for the moon I might use a matrix R_{eo} T_{e} R_{mo} T_{m} S_{m} where
As an exercise: if the Moon spun relative to the earth (it doesn’t, but Earth does spin relative to the Sun), where would you add that matrix?
Do not attempt to match true astronomical scale and speeds; doing so will make the animation almost impossible to see. You may add axial tilt if you wish, but doing so is not required.
On both your development machine and when submitted to the submission server and then viewed by clicking the HTML link, the resulting animation should show orbiting bodies. One example motion (this one with the optional axial tilt added) might be the following: