-
By now you have followed the link to create your assignment repository. The repository name should lool like
a1-githubusername. -
As part of this process you will also receive an invitation from GitHub to join the class organization which is where all of your class assignments and term project will live.
- You should also be sure to setup your local git environment and ssh keys to work with GitHub.
-
Once your repository is created, you will have a copy of the assignment template in your github repository. Now you can clone the repository onto your local computer using the following command. Be sure do execute this command from the directory you wish to locate your work.
$ git clone git@github.com:intro-graphics/a1-githubusername.git- You can now follow the remaining steps of the assignment.
-
Go to your folder. The easiest way is to right click the popup that downloaded it, then choose
Show in Folder. -
You should see the file index.html in your folder. You can already try clicking that open to see the code run on your machine... mostly. This is a start; you'll see an animation. But this isn't good enough. Your animation is still unable to load local files (texture images, sounds, models) out of your own file-system, due to its safety protections against your web browser.
-
Run a fake server. which lacks those security protections. Do this by opening the file we gave you called
host-host.batif you're Windows,host.commandif your Mac. On Windows you can just double click the file open.- On Mac, you might get a security warning instead if you double-click. Instead, right click the files, then choose Open, or you can go into System Preferences/Security & Prinvacy/General and click 'Open Anyway'. You may possibly need to check the file permissions and set them to 744.
-
Look in the resulting console window. If you can't find a message starting with
Serving HTTP on ..., your operating system might not have come with Python; go download and install that first -- use Google for help on that, then try our files again. -
Now you're hosting. Keep that window open.
-
Open a new window of Google Chrome. Download it first if needed.
-
Navigate Chrome to the url http://localhost:8000/ That assumes that step 5's message said port 8000 - otherwise change the number in the URL to match.
-
Observe that your project shows up at this new URL. That's where you'll access it from now on.
Unfortunately, web developers in practice have to do that fake server thing pretty often to be able to work on their files locally. Keep the .bat or .command program open while you work.
-
Although any text editor will work on our files, for this class you'll need to use the editor inside of Chrome, because of its debugging tools.
-
Resume with the open Chrome window from the previous step 8.
-
Press F12 (Windows) or Cmd+Option+i (Mac) to open the Chrome developer tools panel (DevTools).
-
You want DevTools to be able to take up the whole screen. Undock it from your web page window. Do this by clicking the ellipsis at the upper right corner, and selecting the first choice under
Dock Side. -
Maximize both your web page window and DevTools windows. Use the keyboard shortcut Alt+tab (Windows) or three finger swipe (Mac) to switch between them quickly.
-
Click the
Sourcestab of the DevTools panel, towards the top of the screen. -
Without leaving the
Sourcesouter tab, look at the navigator panel on the left. This might be collapsed in the upper corner. Regardless open thePageinner tab underneath it. -
You should see all the files you downloaded from GitHub here. Click them open to make sure you can see the code. Now you can read it all here.
These steps and the following ones, may seem like a lot of work, but they are part of becoming a real web developer with a good workflow, as opposed to someone who just knows the language. The biggest key of all to becoming a good developer is actually going be mastering the debugger feature, but first for this assignment let's just take it slow and set up our editor.
-
Change from the
Pageinner tab to theFilesysteminner tab, which might be collapsed behind the arrow. This one should be empty. -
Drag and drop your local file folder from your computer's folder navigator straight into the middle of the DevTools window. If you can't figure out how to drag between maximized windows (you can), just use the manual
add folder to workspacebutton and choose your folder. Either way this will complete the mapping between your real local files and the fake ones over the network. -
Observe the little green dots next to each file in the
Filesystemsubtab. These green dots verify that your Chrome has matched your fake server to your local files. -
Sometimes a green dot is missing -- especially on index.html. That is dangerous; the file is not mapped right and any changes you make to it will be lost. When green dots are missing, hit ctrl+F5 (Windows) or cmd+F5 (Mac) to do a hard refresh. This re-loads them from your local files and re-maps them again.
Be aware that for as long as you have DevTools open, back at browser window you have unlocked some new ways to refresh: Right-click the refresh button to see them.
-
If the green dots still don't show up, delete what's in the workspace area and try again until they appear.
-
Now you can edit the files directly inside Chrome, in the DevTools
Sourcestab.- As long as you make changes under
Sourcesand notElements, your changes will now persist in your own local files even after page refreshes. - You should avoid ever accidentally typing in the
Elementstab. That's only for temporary HTML stuff your code generates.
- As long as you make changes under
Editing directly in Chrome like this is the workflow we will use. One reason is that your code immediately changes its behavior as you type. Even when it's in the middle of running, or as soon as you un-pause it in the debugger. Elements will move around on the page immediately when you make changes. This allows you to you dynamically test new code without re-starting your whole animation and losing your place -- without having to wait for your timed scenes to progress to that point again -- or without having to enter the right inputs again.
-
If you've never learned your way around an IDE for editing code, now is the time to. Chrome's code editor is kind of in-between in terms of quality: Better than Windows Notepad or TextEdit, but not quite as good as Notepad++ or Microsoft VSCode. In order for it to be better than crudely opening your code in notepad, you need to know what basic features to expect from a text editor. Let's learn them.
-
Find and try each of the following code editing commands once. They're found in that DevTools Sources tab.
-
Block indent / unindent (Tab and Shift+Tab)
-
Block comment / uncomment (Ctrl+/ or Cmd+/) ** For both of the above bullet points, try it on multiple highlighted lines at once.
-
Zoom in/out while reading ** Hold down Ctrl (Windows) or Cmd (Mac) and then press plus, minus, or zero to adjust. ** Use this fit a comfortable amount of code on-screen for you to read at once.
-
find (Ctrl+f or Cmd+f)
-
find-and-replace
** For both of the above bullet points, note that you don't have to find specific or exact strings; Chrome supports matching regular expressions, for finding all text of a more general pattern. That's the .* button.
-
-
With our animation running in Chrome, with DevTools still open to the Sources tab. Open the file
assignment1.js. This is under theFilesystemtab of the navigator panel, which might be collapsed in the upper corner. -
If there's no green dot next to
assignment1.js, fix it as described above. -
On line 16, add the following three items to the JavaScript array, which is all the text enclosed by square brackets [ ]. Add a comma to separate from previous items in the array.
vec3(1, 1, 0), vec3(1, 0, 0), vec3(0, 1, 0)
-
On line 19, add the following three items to the JavaScript array:
color(1, 1, 0, 1), color(0, 1, 0, 1), color(0, 0, 1, 1)
-
Save the file, and reload the page (using Ctrl+Shift+r for Windows, Cmd+Shift+r for Mac). Switch back to look at your web page window. The triangle should be a square now, because you just attached a second triangle to it. If so, your edit worked and your file is saved. If not, check for green dots and fix it as per above.
-
If you typed the wrong thing, you could get console errors, a blank web page, or missing triangles. Later on we'll show you how to use the debugger and the console together to approach errors in a smart way. For now, just type it right.
-
Your files should be ready to turn in now, including your trivial change.
-
Once you are finished working it is time to 'commit' your work to your remote respository on GitHub. You will want to do this periodically while you are working to make a backup of your work and to make your final submission. We will keep the process very simple by simply 'committing' the master branch of your local repository into the remote repository on GitHub.
-
The first step is to add any new files into the respository so they can be tracked.
$ git add *- Then we commit any new and or changed files to the repository. The text after the -m is for you to describe what is included in this commit to the respository.
$ git commit -m "Description of what I did"- Finally, we need to push these changes up to our remote repository on GitHub. This is a very important step! Without it you are not copying your work back to GitHub and we will not be able to see it if you forget.
$ git push- You can repeat these commands as often as you feel the need as your work on your assignment. However, again, you must always make a final push to GitHub when you are finished in order to submit your work. We will make a copy of all assignments at the assignment deadline. That implies two things. First, make your final push to GitHub ahead of time and second, any pushes you make after the deadline will not be seen by us.














