Formatting

This commit is contained in:
Julian Brammer 2023-11-30 22:37:29 +01:00
parent 7502ab9cdb
commit 27408aeed3
3 changed files with 9 additions and 50 deletions

View File

@ -1,10 +1,6 @@
class Object3D {
// DONE: Füge Default-Materialkoeffizienten hinzu
constructor(
ka = [0.5, 0.5, 0.5],
kd = [0.5, 0.5, 0.5],
ks = [0.5, 0.5, 0.5]
) {
constructor(ka = [0.5, 0.5, 0.5], kd = [0.5, 0.5, 0.5], ks = [0.5, 0.5, 0.5]) {
this.posVBO = gl.createBuffer();
// DONE: Kein colorVBO mehr! (Farben werden über Materialkoeffizienten bestimmt)
this.indexVBO = gl.createBuffer();
@ -27,25 +23,13 @@ class Object3D {
InitBuffers() {
gl.bindBuffer(gl.ARRAY_BUFFER, this.posVBO);
gl.bufferData(
gl.ARRAY_BUFFER,
new Float32Array(this.positions),
gl.STATIC_DRAW
);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.positions), gl.STATIC_DRAW);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexVBO);
gl.bufferData(
gl.ELEMENT_ARRAY_BUFFER,
new Uint16Array(this.indices),
gl.STATIC_DRAW
);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), gl.STATIC_DRAW);
}
SetModelMatrix(
position = this.position,
orientation = this.orientation,
scale = this.scale
) {
SetModelMatrix(position = this.position, orientation = this.orientation, scale = this.scale) {
this.position = position;
this.orientation = [
(orientation[0] * Math.PI) / 180,
@ -56,24 +40,9 @@ class Object3D {
this.modelMatrix = mat4.create();
mat4.translate(this.modelMatrix, this.modelMatrix, position);
mat4.rotate(
this.modelMatrix,
this.modelMatrix,
this.orientation[0],
[1, 0, 0]
);
mat4.rotate(
this.modelMatrix,
this.modelMatrix,
this.orientation[1],
[0, 1, 0]
);
mat4.rotate(
this.modelMatrix,
this.modelMatrix,
this.orientation[2],
[0, 0, 1]
);
mat4.rotate(this.modelMatrix, this.modelMatrix, this.orientation[0], [1, 0, 0]);
mat4.rotate(this.modelMatrix, this.modelMatrix, this.orientation[1], [0, 1, 0]);
mat4.rotate(this.modelMatrix, this.modelMatrix, this.orientation[2], [0, 0, 1]);
mat4.scale(this.modelMatrix, this.modelMatrix, scale);
}

View File

@ -82,9 +82,7 @@
<body>
<h1>Lorem Ipsum</h1>
<canvas id="gl-canvas" width="1024" height="512">
If you see this, your browser doesn't support WebGL.
</canvas>
<canvas id="gl-canvas" width="1024" height="512"> If you see this, your browser doesn't support WebGL. </canvas>
<script src="main.js" type="text/javascript"></script>
</body>

View File

@ -6,15 +6,7 @@ let objects = [];
let posLoc;
// DONE: Deklariere benötigte Locations von Shadervariablen als globale Variablen
let normalLoc,
lightPositionLoc,
IaLoc,
IdLoc,
IsLoc,
kaLoc,
kdLoc,
ksLoc,
specularExponentLoc;
let normalLoc, lightPositionLoc, IaLoc, IdLoc, IsLoc, kaLoc, kdLoc, ksLoc, specularExponentLoc;
let modelMatrixLoc;