Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assignment 05 #169

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3fcae98
Update index.html
kavinraj30 Sep 11, 2024
8eb5a2d
Add files via upload
kavinraj30 Sep 11, 2024
895a2eb
Update index.html
kavinraj30 Sep 11, 2024
c40c524
Update index.html
kavinraj30 Sep 11, 2024
c38557b
Update index.html
kavinraj30 Sep 11, 2024
ccf6ff9
Update index.html
kavinraj30 Sep 11, 2024
b8e2c2d
Update index.html
kavinraj30 Sep 11, 2024
5b57baf
Add files via upload
kavinraj30 Sep 11, 2024
9c4f435
Update index.html
kavinraj30 Sep 11, 2024
a1d53c7
Add files via upload
kavinraj30 Sep 11, 2024
fdbe361
Update index.html
kavinraj30 Sep 11, 2024
f6b5396
Update index.html
kavinraj30 Sep 11, 2024
c7580f2
Update index.html
kavinraj30 Sep 11, 2024
4641724
Update index.html
kavinraj30 Sep 11, 2024
47ffa2e
Add files via upload
kavinraj30 Sep 11, 2024
098cd85
Delete 01/GLTF2Loader.js
kavinraj30 Sep 11, 2024
2119837
Delete 01/three.js
kavinraj30 Sep 11, 2024
3e53aa2
Add files via upload
kavinraj30 Sep 11, 2024
3d8a625
Update index.html
kavinraj30 Sep 11, 2024
22436f4
Update index.html
kavinraj30 Sep 11, 2024
1aea69d
Delete 01/alligator.gltf
kavinraj30 Sep 11, 2024
66fc0b3
Delete 01/birds_raven.gltf
kavinraj30 Sep 11, 2024
866682d
Delete 01/birds_vulture.gltf
kavinraj30 Sep 11, 2024
35d8110
Delete 01/goat.gltf
kavinraj30 Sep 11, 2024
90084c7
Add files via upload
kavinraj30 Sep 11, 2024
c582d17
Update index.html
kavinraj30 Sep 11, 2024
7232053
Delete 01/js directory
kavinraj30 Sep 11, 2024
2d5f267
Delete 01/models directory
kavinraj30 Sep 11, 2024
bff0b2a
Add files via upload
kavinraj30 Sep 11, 2024
61fd1e2
Merge branch 'bostongfx:main' into main
kavinraj30 Sep 18, 2024
1fe3588
Update index.html
kavinraj30 Sep 19, 2024
e896509
Add files via upload
kavinraj30 Sep 19, 2024
a812566
Create scene.json
kavinraj30 Sep 19, 2024
db790e1
Delete scene.json
kavinraj30 Sep 19, 2024
2ecdcb1
Update index.html
kavinraj30 Sep 19, 2024
92b2863
Update scene.json
kavinraj30 Sep 19, 2024
415124c
Update loader.js
kavinraj30 Sep 19, 2024
22202df
Update index.html
kavinraj30 Sep 19, 2024
c80d670
Update index.html
kavinraj30 Sep 19, 2024
1e148db
Create index.html
kavinraj30 Sep 30, 2024
0d925ed
Create index.html
kavinraj30 Oct 15, 2024
603ca33
Add files via upload
kavinraj30 Oct 15, 2024
c10a370
Add files via upload
kavinraj30 Nov 26, 2024
9644d95
Add files via upload
kavinraj30 Nov 26, 2024
5b8e0e6
Rename WhatsApp Image 2024-11-25 at 11.20.07 PM.jpeg to ar-screenshot…
kavinraj30 Nov 26, 2024
0b1b410
Rename WhatsApp Image 2024-11-25 at 11.21.11 PM.jpeg to 3DPrint-scree…
kavinraj30 Nov 26, 2024
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
Binary file added 01/ROME.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,952 changes: 2,952 additions & 0 deletions 01/files/js/GLTF2Loader.js

Large diffs are not rendered by default.

44,230 changes: 44,230 additions & 0 deletions 01/files/js/three.js

Large diffs are not rendered by default.

5,332 changes: 5,332 additions & 0 deletions 01/files/models/alligator.gltf

Large diffs are not rendered by default.

703 changes: 703 additions & 0 deletions 01/files/models/birds_raven.gltf

Large diffs are not rendered by default.

6,402 changes: 6,402 additions & 0 deletions 01/files/models/birds_vulture.gltf

Large diffs are not rendered by default.

3,658 changes: 3,658 additions & 0 deletions 01/files/models/goat.gltf

Large diffs are not rendered by default.

35 changes: 25 additions & 10 deletions 01/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,39 @@ <h1>RO.ME "3 DREAMS OF BLACK"</h1>
<div class='demo'>

<!-- TODO: REPLACE WITH A SCREENSHOT OF RO.ME -->
<img id='screenshot' src='https://placehold.co/300x300'>
<p id='description'>
<img id='screenshot' src='ROME.png' alt='Screenshot of RO.ME'>
<p id='description' style="text-align: justify;">
<!-- TODO: FILL IN YOUR DESCRIPTION -->
RO.ME is a very cool webgl demo!
The "3 DREAMS OF BLACK" demo, created in 2010 and launched in 2011 by Danger Mouse, Luppi, White, and Jones, is a pioneering WebGL project that merges 2D and 3D graphics with video.This is like the coolest website I have ever seen! The 3D graphics really resemble that of some modern-day video games! This innovative work showcases real-time rendering capabilities, effectively turning web browsers into interactive gaming platforms. By pushing the boundaries of web content beyond simple text and images, WebGL enables immersive experiences. The demo has profoundly influenced web development by demonstrating WebGL's potential to revolutionize online 3D graphics, leading to greater adoption of immersive technologies in sectors such as gaming, education, and virtual tours. Its impact is rooted in showing how advanced storytelling and graphics can be seamlessly delivered through the web.
</p>
<p id='technology'>
Technology: TODO! <!-- TODO: FILL IN THE TECHNOLOGIES USED -->
Technology used in 3 Dreams of Black include:

1. WebGL - for rendering hardware-accelerated 3D graphics in the browser.
2. GLSL - for real-time shaders and visual effects.
3. Three.js - a JavaScript library that simplifies WebGL usage.
4. Marching Cubes Algorithm - for generating complex geometries like metaballs.
5. Normal Mapping - for simulating detailed textures.
6. Audio API - for integrating sound in real-time.
.<!-- TODO: FILL IN THE TECHNOLOGIES USED -->
</p>
<p id='comparison'>
Comparison: TODO! <!-- TODO: FILL IN THE COMPARISON -->
Comparison: In my view, the Air Force website focuses on recruiting and engaging visitors with high-quality visuals and interactive elements, while the RO.ME demo highlights how to integrate and animate 3D models on websites, emphasizing technical functionality. <!-- TODO: FILL IN THE COMPARISON -->
<p>Visit the <a href="https://www.airforce.com/intothestorm/" target="_blank">Air Force's "Into the Storm"</a> website to experience their engaging and immersive recruitment content featuring high-quality visuals and interactive elements.</p>
<p>In contrast, the <a href="https://bostongfx.github.io/tech/" target="_blank">RO.ME demo</a> highlights the technical integration of 3D models into web pages, focusing on showcasing interactive and animated features rather than engagement.</p>
</div>
</p>


<div id='bonus'>
<!-- TODO: BONUS TASK GOES HERE -->
</div>

</div>
<div id="bonus">
<h2>Bonus: Animated Models</h2>
<iframe class="viewer" src="viewer.html?files/models/alligator.gltf"></iframe>
<iframe class="viewer" src="viewer.html?files/models/birds_raven.gltf"></iframe>
<iframe class="viewer" src="viewer.html?files/models/birds_vulture.gltf"></iframe>
</div>
</div>

</body>
</html>


104 changes: 104 additions & 0 deletions 01/viewer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>ROME GLTF</title>
<style>
body {
margin: 0;
}
</style>
</head>
<body>
<script src="files/js/three.js"></script>
<script src="files/js/GLTF2Loader.js"></script>
<script>
var renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.animate( render );
document.body.appendChild( renderer.domElement );

var scene = new THREE.Scene();
scene.background = new THREE.Color( 0xdddddd );

var light = new THREE.DirectionalLight( 0xffffff, 1.25 );
light.position.set( 1, 1, 1 );
scene.add( light );

var light = new THREE.HemisphereLight();
scene.add( light );

var camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight );

var mixer, sphere;

var loader = new THREE.GLTF2Loader();
loader.load( location.search.substr( 1 ), function ( gltf ) {

// TODO Implement Double side in exporter

gltf.scene.traverse( function ( child ) {

if ( 'material' in child ) {

child.material.side = THREE.DoubleSide;

}

} );

sphere = new THREE.Box3()
.expandByObject( gltf.scene )
.getBoundingSphere();

//

var animations = gltf.animations;

if ( animations && animations.length ) {

mixer = new THREE.AnimationMixer( gltf.scene );

for ( var i = 0; i < animations.length; i ++ ) {

var animation = animations[ i ];
mixer.clipAction( animation ).play();

}

}

scene.add( gltf.scene );

} );

//

var prevTime = performance.now() / 1000;

function render() {

var time = performance.now() / 1000;

if ( sphere ) {

camera.position.set( Math.cos( time ), 1.5, Math.sin( time ) ).multiplyScalar( sphere.radius );
camera.lookAt( sphere.center );

}

if ( mixer ) {

mixer.update( time - prevTime );

}

renderer.render( scene, camera );

prevTime = time;

}

</script>
</body>
</html>
148 changes: 134 additions & 14 deletions 02/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,136 @@
<html>
<head>
<title>CS460.org Assignment 2</title>
<style>
body {
background-color:#000;
margin: 0;
padding: 0;
height: 100%;
overflow: hidden !important;
}
</style>
</head>
<body>
</body>

<head>
<title>CS460.org Assignment 2</title>
<style>
body {
background-color: #000;
margin: 0;
padding: 0;
height: 100%;
overflow: hidden !important;
}
</style>
<script type="text/javascript" src="https://get.goXTK.com/xtk_edge.js"></script>
<script src="loader.js"></script>
</head>

<body>
<script type="text/javascript">
var r = new X.renderer3D();
var isRotationOn = true;
var stopCameraSwitch = true;
var cameraViewPosition = 0;
var CAMERAS = []
let interval;

let CUBE_SIDELENGTH = 10;
let GAP = 2;

window.onload = function () {
r.init();

var cube = new X.cube();
cube.lengthX = cube.lengthY = cube.lengthZ = CUBE_SIDELENGTH;
// add the object
r.add(cube);

window.onkeypress = function (e) {
var cube = r.Ha[r.Ha.length - 1];
if (e.code == 'KeyD') {
cube.transform.translateX(-CUBE_SIDELENGTH - GAP);
} else if (e.code == 'KeyA') {
cube.transform.translateX(CUBE_SIDELENGTH + GAP);
} else if (e.code == 'KeyW') {
cube.transform.translateZ(CUBE_SIDELENGTH + GAP);
} else if (e.code == 'KeyS') {
cube.transform.translateZ(-CUBE_SIDELENGTH - GAP);
} else if (e.code == 'KeyQ') {
cube.transform.translateY(CUBE_SIDELENGTH + GAP);
} else if (e.code == 'KeyE') {
cube.transform.translateY(-CUBE_SIDELENGTH - GAP);
} else if (e.code == 'Digit1') {
// white
cube.color = [1, 1, 1];
} else if (e.code == 'Digit2') {
// red
cube.color = [1, 0, 0];
} else if (e.code == 'Digit3') {
// green
cube.color = [0, 1, 0];
} else if (e.code == 'Digit4') {
// blue
cube.color = [0, 0, 1];
} else if (e.code == 'Digit5') {
// yellow
cube.color = [1, 1, 0];
} else if (e.code == 'Digit6') {
// pink
cube.color = [1, 0, 1];
} else if (e.code == 'Digit7') {
// cyan
cube.color = [0, 1, 1];
} else if (e.code == 'Digit0') {
// black
cube.color = [0, 0, 0];
} else if (e.code == 'Space') {
// add a new cube
var newCube = new X.cube();
newCube.transform.matrix = new Float32Array(cube.transform.matrix)
newCube.transform.translateX(CUBE_SIDELENGTH + GAP);
newCube.lengthX = newCube.lengthY = newCube.lengthZ = CUBE_SIDELENGTH;
r.add(newCube);
} else if (e.code == 'KeyO') {
// download the scene as a JSON file
download();
} else if (e.code == 'KeyL') {
// upload a JSON file
upload('scene.json');
} else if (e.code == "KeyB") {
// toggle rotation
console.log(isRotationOn);
console.log(r.camera);
if (isRotationOn) {
r.onRender = function () {
r.camera.rotate([0, 0]);
}

isRotationOn = !isRotationOn;
} else {
r.onRender = function () {
r.camera.rotate([1, 0]);
}
isRotationOn = !isRotationOn;
}
} else if (e.code == "KeyC") {
CAMERAS.push(new Float32Array(r.camera.view));
} else if (e.code == "KeyV") {
if (stopCameraSwitch) {
stopCameraSwitch = false;
interval = setInterval(() => {
r.camera.view = CAMERAS[cameraViewPosition];
cameraViewPosition = (cameraViewPosition + 1) % CAMERAS.length;
}, 1000);

} else {
stopCameraSwitch = true;
clearInterval(interval);
}

}

};

r.onRender = function () {
r.camera.rotate([1, 0]);
};

// .. and render it
r.render();
};


</script>
</body>

</html>
16 changes: 10 additions & 6 deletions 02/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function download() {
// get all cubes
ALL_CUBES = [];

for (var i = 0; i<r.Ha.length; i++) {
for (var i = 0; i < r.Ha.length; i++) {
// note: r.Ha are all objects in the scene

var color = r.Ha[i].color;
Expand All @@ -16,13 +16,13 @@ function download() {
// create JSON object
var out = {};
out['cubes'] = ALL_CUBES;
out['camera'] = r.camera.view;
out['camera'] = CAMERAS;

// from https://stackoverflow.com/a/30800715
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(out));

var downloadAnchorNode = document.createElement('a');
downloadAnchorNode.setAttribute("href", dataStr);
downloadAnchorNode.setAttribute("href", dataStr);
downloadAnchorNode.setAttribute("download", "scene.json");
document.body.appendChild(downloadAnchorNode); // required for firefox
downloadAnchorNode.click();
Expand All @@ -35,7 +35,7 @@ function upload(scene) {
var req = new XMLHttpRequest();
req.responseType = 'json';
req.open('GET', scene, true);
req.onload = function() {
req.onload = function() {
loaded = req.response;

// parse cubes
Expand All @@ -55,12 +55,16 @@ function upload(scene) {

}

for (var cameraView in loaded['camera']) {
CAMERAS.push(new Float32Array(Object.values(loaded['camera'][cameraView])));
}

// restore camera
r.camera.view = new Float32Array(Object.values(loaded['camera']));
r.camera.view = new Float32Array(Object.values(loaded['camera'][0]));


};
req.send(null);

}

1 change: 1 addition & 0 deletions 02/scene.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"cubes":[[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":0,"14":0,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":12,"13":0,"14":0,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":24,"13":0,"14":0,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":24,"13":0,"14":12,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":24,"13":0,"14":24,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":12,"13":0,"14":24,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":0,"14":24,"15":1}],[[1,1,1],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":12,"13":0,"14":12,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":0,"14":12,"15":1}],[[1,1,1],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":12,"13":0,"14":12,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":-12,"14":24,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":-24,"14":24,"15":1}],[[1,1,1],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":12,"13":-12,"14":24,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":24,"13":-12,"14":24,"15":1}],[[1,1,1],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":24,"13":-12,"14":12,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":24,"13":-12,"14":0,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":24,"13":-24,"14":0,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":24,"13":-24,"14":12,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":24,"13":-24,"14":24,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":12,"13":-24,"14":24,"15":1}],[[1,1,1],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":24,"13":-24,"14":24,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":24,"13":-24,"14":24,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":12,"13":-24,"14":12,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":-24,"14":12,"15":1}],[[1,1,1],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":12,"13":-24,"14":12,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":12,"13":-24,"14":0,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":-24,"14":0,"15":1}],[[1,0,0],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":-12,"14":0,"15":1}],[[1,1,1],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":12,"13":-12,"14":0,"15":1}],[[1,1,1],{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":-12,"14":12,"15":1}]],"camera":[{"0":-0.5088146328926086,"1":-0.6418372988700867,"2":-0.5737183690071106,"3":0,"4":-0.8565045595169067,"5":0.4445054531097412,"6":0.26232656836509705,"7":0,"8":0.08665025979280472,"9":0.6248681545257568,"10":-0.7759062647819519,"11":0,"12":0,"13":0,"14":-100,"15":1},{"0":-0.8355745077133179,"1":-0.4902653992176056,"2":0.2479022592306137,"3":0,"4":0.5382307767868042,"5":-0.6401002407073975,"6":0.5482506155967712,"7":0,"8":-0.11010605841875076,"9":0.5915336608886719,"10":0.7987264394760132,"11":0,"12":0,"13":0,"14":-100,"15":1},{"0":0.33220964670181274,"1":0.4374502897262573,"2":-0.8356270790100098,"3":0,"4":0.6274079084396362,"5":-0.7640038132667542,"6":-0.1505248248577118,"7":0,"8":-0.7042701840400696,"9":-0.47427406907081604,"10":-0.5282685160636902,"11":0,"12":0,"13":0,"14":-100,"15":1},{"0":-0.34018585085868835,"1":0.8802840709686279,"2":0.33071693778038025,"3":0,"4":-0.7393782734870911,"5":-0.033087704330682755,"6":-0.6724761128425598,"7":0,"8":-0.5810281038284302,"9":-0.47329220175743103,"10":0.6621178984642029,"11":0,"12":0,"13":0,"14":-100,"15":1}]}
Loading