Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics with WebGL / Project / Project.html
diff options
context:
space:
mode:
Commit866b2608dfbc53dcd968bdf3261005a9e0be8b36 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-08-25 21:26:38 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-08-25 21:26:38 +0300
Files1f7f965553173ba41cb4f343d872ef3d1ed3c311 /Year 2/Computer Graphics with WebGL/Project/Project.html
uni-projects-866b2608dfbc53dcd968bdf3261005a9e0be8b36.tar
uni-projects-866b2608dfbc53dcd968bdf3261005a9e0be8b36.tar.gz
uni-projects-866b2608dfbc53dcd968bdf3261005a9e0be8b36.zip
Parent6dd51a351bebd3347c1c4d9d8caf4d7b2f2a4338 (diff)
[WGL/P] Added most proper shader code, now have two roadblocks
1 files changed, 20 insertions, 13 deletions
-rw-r--r--Year 2/Computer Graphics with WebGL/Project/Project.html33
diff --git a/Year 2/Computer Graphics with WebGL/Project/Project.html b/Year 2/Computer Graphics with WebGL/Project/Project.html
index 23e3759..a97f94e 100644
--- a/Year 2/Computer Graphics with WebGL/Project/Project.html
+++ b/Year 2/Computer Graphics with WebGL/Project/Project.html
@@ -61,6 +61,7 @@ h2 {
<script src="spaceship.js"></script>
<script src="skybox.js"></script>
+ <script src="star.js"></script>
<script src="blackhole.js"></script>
<script>
/*
@@ -97,14 +98,21 @@ h2 {
gl.uniform3f(uDiffuseColor,1,1,1);
gl.uniform3f(uLightDir,0,0,-1);
- skybox = new Skybox(10000, [0.1,0.1,0.1], undefined);
- planets = [new Sphere([1000,0,1000], 50),
- new Sphere([1000,0,-1000], 50),
- new Sphere([950,0,1100], 40),
- new Sphere([0,0,0], 100),
- new Sphere([1000, 0, -30], 20)];
+ skybox = new Skybox(10000, [0,0,0], undefined);
+
+ star = new Star([1000,0,1000], 50)
+ // new Star([1000,0,-1000], 50)
+ // new Star([950,0,1100], 40)
+ // new Star([0,0,0], 100)
+ // new Star([1000, 0, -30], 20);
+ for (var i = 0; i < starsBuf.length; i++) {
+ gl.uniform4fv(gl.getUniformLocation(glprog, "uStars[" + i + "]"), starsBuf[i]);
+ }
blackHole = new BlackHole([1000,0,900], 30);
+ for (var i = 0; i < blackHolesBuf.length; i++) {
+ gl.uniform4fv(gl.getUniformLocation(glprog, "uBH[" + i + "]"), blackHolesBuf[i]);
+ }
resizeglcanvas();
}
@@ -114,8 +122,7 @@ h2 {
gl.canvas.height = gl.canvas.offsetHeight;
gl.viewport(0,0,gl.canvas.width,gl.canvas.height);
- // var proj=orthoMatrix(gl.canvas.width,gl.canvas.height,-1000,1000);
- // gl.uniformMatrix4fv(uProjectionMatrix,false,proj);
+ // gl.uniform2f(uViewPort, gl.canvas.width, gl.canvas.height);
drawFrame();
}
@@ -126,13 +133,13 @@ h2 {
gl.clear(gl.COLOR_BUFFER_BIT+gl.DEPTH_BUFFER_BIT);
lookUpdate();
- gl.uniform3f(uEye, pos[0], pos[1], pos[2]);
- gl.uniform3f(uEyeForward, forward.toCartesian()[0], forward.toCartesian()[1], forward.toCartesian()[2]);
- gl.vertexAttrib4fv(aSphere, [pos[0], pos[1], pos[2], 0]);
+ gl.uniform3fv(uEye, pos);
+ gl.uniform3fv(uEyeForward, forward.toCartesian());
+ gl.uniform3fv(uEyeUp, up.toCartesian());
+ gl.uniform3fv(uEyeLeft, left.toCartesian());
skybox.draw();
- planets.forEach((p) => p.draw());
- blackHole.draw();
+ star.draw();
requestAnimationFrame(drawFrame);
}