Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 5 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,8 @@
Assignment 4 - Creative Coding: Interactive Multimedia Experiences
===
# Movable Cube in Space
http://a4-kpanneton.glitch.me

Due: October 4th, by 11:59 AM.
I have created a small-scale visual experience using the Three.js library. My application is a rotating cube that can be moved in four directions across the screen using WASD, along with using the up and down arrow keys to bring it forward and backwards in the plane, allowing the user to adjust the perspective. Additinoally, to reset the cube in the scene the user can hit space, such that it won't get lost in the infinite plane. Additionally, I added some basic CSS to remove the scrollbar from the webpage and removed the margins to allow the scene to fill the browser.

For this assignment we will focus on client-side development using popular audio/graphics/visualization technologies. The goal of this assignment is to refine our JavaScript knowledge while exploring the multimedia capabilities of the browser.
Some challenges I faced were defintely scoping this project to be completable in the time given, I ended up having to change directions after realizing what I had planned would not be completed by the deadline. Instead, I opted to do something more simple that still demostrated my knowledge of what I learned using Three.js. An additional challenge was using tweakpane to create a better user interface where the user can customize the cube and how fast it is moving across the scene, however I ran into challegnges getting tweakpane to run on my html page. It is currently implemented in the code, but unknown errors are preventing it from being seen. If I had more time to work on this, my goal would be to have a slider for the color of the cube (in RGB values), a slider for speed of the cube's rotation, and sliders to change to cube's speed in the 6 different directions (left, right, up, down, forward, backward).

[WebAudio + Canvas Tutorial](https://github.com/cs4241-22a/cs4241-22a.github.io/blob/main/using_webaudio_canvas.md)
[SVG + D3 tutorial](https://github.com/cs4241-21a/cs4241-21a.github.io/blob/main/using_svg_and_d3.md)

Baseline Requirements
---

Your application is required to implement the following functionalities:

- A server created using Express. This server can be as simple as needed.
- A client-side interactive experience using at least one of the following web technologies frameworks.
- [Three.js](https://threejs.org/): A library for 3D graphics / VR experiences
- [D3.js](https://d3js.org): A library that is primarily used for interactive data visualizations
- [Canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D raster drawing API included in all modern browsers
- [SVG](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D vector drawing framework that enables shapes to be defined via XML.
- [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API): An API for audio synthesis, analysis, processing, and file playback.
- A user interface for interaction with your project, which must expose at least four parameters for user control. [tweakpane](https://cocopon.github.io/tweakpane/) is highly recommended for this, but you can also use regular HTML `<input>` tags (the `range` type is useful to create sliders). You might also explore interaction by tracking mouse movement via the `window.onmousemove` event handler in tandem with the `event.clientX` and `event.clientY` properties. Consider using the [Pointer Events API](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events) to ensure that that both mouse and touch events will both be supported in your app.
- Your application should display basic documentation for the user interface when the application first loads.

The interactive experience should possess a reasonable level of complexity. Some examples:
### Three.js
- A generative algorithm creates simple agents that move through a virtual world. Your interface controls the behavior / appearance of these agents.
- A simple 3D game... you really want this to be a simple as possible or it will be outside the scope of this assignment.
- An 3D audio visualization of a song of your choosing. User interaction should control aspects of the visualization.
### Canvas
- Implement a generative algorithm such as [Conway's Game of Life](https://bitstorm.org/gameoflife/) (or 1D cellular automata) and provide interactive controls. Note that the Game of Life has been created by 100s of people using <canvas>; we'll be checking to ensure that your implementation is not a copy of these.
- Design a 2D audio visualizer of a song of your choosing. User interaction should control visual aspects of the experience.
### Web Audio API
- Create a screen-based musical instrument using the Web Audio API. You can use projects such as [Interface.js](http://charlie-roberts.com/interface/) or [Nexus UI](https://nexus-js.github.io/ui/api/#Piano) to provide common musical interface elements, or use dat.GUI in combination with mouse/touch events (use the Pointer Events API). Your GUI should enable users to control aspects of sound synthesis. If you want to use higher-level instruments instead of the raw WebAudio API sounds, consider trying the instruments provided by [Tone.js]() or [Gibber](https://github.com/charlieroberts/gibber.audio.lib).
### D3.js
- Create visualizations using the datasets found at [Awesome JSON Datasets](https://github.com/jdorfman/Awesome-JSON-Datasets). Experiment with providing different visualizations of the same data set, and providing users interactive control over visualization parameters and/or data filtering. Alternatively, create a single visualization with using one of the more complicated techniques shown at [d3js.org](d3js.org) and provide meaningful points of interaction for users.

Deliverables
---

Do the following to complete this assignment:

1. Implement your project with the above requirements.
3. Test your project to make sure that when someone goes to your main page on Glitch/Heroku/etc., it displays correctly.
4. Ensure that your project has the proper naming scheme `a4-firstname-lastname` so we can find it.
5. Fork this repository and modify the README to the specifications below. *NOTE: If you don't use Glitch for hosting (where we can see the files) then you must include all project files that you author in your repo for this assignment*.
6. Create and submit a Pull Request to the original repo. Name the pull request using the following template: `a4-firstname-lastname`.

Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions)
---

## Your Web Application Title

your hosting link e.g. http://a4-charlieroberts.glitch.me

Include a very brief summary of your project here. Images are encouraged when needed, along with concise, high-level text. Be sure to include:

- the goal of the application
- challenges you faced in realizing the application
- the instructions you present in the website should be clear enough to use the application, but if you feel any need to provide additional instructions please do so here.
The simple instructions for my website are you can use WASD for movement in the x and y plane, along with the up and down arrow keys for movement in the z plane. These are included in the top of the website using HTML and CSS for styling.
25 changes: 25 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Assignment 4</title>
<link rel="stylesheet" href="style.css" />
<style>
body { margin: 0; }
</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="path/to/tweakpane-3.1.0.min.js"></script>
<script src="js/main.js"></script>
<script src="js/tweakpane.js"></script>

<div style="background: ghostwhite;
font-size: 20px;
padding: 10px;
border: 1px solid lightgray;
margin: 10px;">
Instructions: Use WASD to move the cube in the x and y directions. Use the up and down arrow to move the cube in the z direction.
</div>
</body>
</html>
72 changes: 72 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );

const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );

const geometry = new THREE.BoxGeometry( 0.5, 0.5, 0.5 );
const material = new THREE.MeshBasicMaterial( { color: 0xFFFF00 } );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );

camera.position.z = 5;

function animate() {
requestAnimationFrame( animate );

cube.rotation.x += 0.01;
cube.rotation.y += 0.01;

renderer.render( scene, camera );
};

animate();

//Load background texture
const loader = new THREE.TextureLoader();
loader.load('space.jpg', function(texture)
{
scene.background = texture;
});

document.onkeydown = function (press) {
//press A to move left
if (press.keyCode === 65) {
cube.position.x -=0.5;
}

//press D to move right
else if (press.keyCode === 87) {
cube.position.y +=0.5;
}

//press W to move up
else if (press.keyCode === 68) {
cube.position.x +=0.5;
}

//press S to move down
else if (press.keyCode === 83) {
cube.position.y -=0.5;
}

//press up arrow to move forward
else if (press.keyCode === 38) {
cube.position.z +=0.5;
}

//press down arrow to move backward
else if (press.keyCode === 40) {
cube.position.z -=0.5;
}

//press Space to reset to (0,0,0)
else if (press.keyCode === 32) {
cube.position.x = 0;
cube.position.y = 0;
cube.position.z = 0;

}

}
Loading