-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: login page and recovery password
- Loading branch information
Showing
15 changed files
with
6,305 additions
and
251 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
/// <reference path="webgl.d.ts" /> | ||
|
||
let Hoverboard = class { | ||
constructor(gl, pos, h, w, b) { | ||
this.positionBuffer = gl.createBuffer(); | ||
gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer); | ||
|
||
this.positions = [ | ||
// Front face | ||
-w / 2, -h / 2, b / 2, | ||
w / 2, -h / 2, b / 2, | ||
w / 2, h / 2, b / 2, | ||
-w / 2, h / 2, b / 2, | ||
//Back Face | ||
-w / 2, -h / 2, -b / 2, | ||
w / 2, -h / 2, -b / 2, | ||
w / 2, h / 2, -b / 2, | ||
-w / 2, h / 2, -b / 2, | ||
//Top Face | ||
-w / 2, h / 2, -b / 2, | ||
w / 2, h / 2, -b / 2, | ||
w / 2, h / 2, b / 2, | ||
-w / 2, h / 2, b / 2, | ||
//Bottom Face | ||
-w / 2, -h / 2, -b / 2, | ||
w / 2, -h / 2, -b / 2, | ||
w / 2, -h / 2, b / 2, | ||
-w / 2, -h / 2, b / 2, | ||
//Left Face | ||
-w / 2, -h / 2, -b / 2, | ||
-w / 2, h / 2, -b / 2, | ||
-w / 2, h / 2, b / 2, | ||
-w / 2, -h / 2, b / 2, | ||
//Right Face | ||
w / 2, -h / 2, -b / 2, | ||
w / 2, h / 2, -b / 2, | ||
w / 2, h / 2, b / 2, | ||
w / 2, -h / 2, b / 2, | ||
]; | ||
|
||
this.rotation = 0.0; | ||
this.pos = pos; | ||
this.exist = true; | ||
|
||
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.positions), gl.STATIC_DRAW); | ||
|
||
const indexBuffer = gl.createBuffer(); | ||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); | ||
const indices = [ | ||
0, 1, 2, 0, 2, 3, // front | ||
4, 5, 6, 4, 6, 7, | ||
8, 9, 10, 8, 10, 11, | ||
12, 13, 14, 12, 14, 15, | ||
16, 17, 18, 16, 18, 19, | ||
20, 21, 22, 20, 22, 23, | ||
]; | ||
|
||
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW); | ||
|
||
const textureCoordBuffer = gl.createBuffer(); | ||
gl.bindBuffer(gl.ARRAY_BUFFER, textureCoordBuffer); | ||
const textureCoordinates = [ | ||
// Front | ||
0.0, 1.0, | ||
1.0, 1.0, | ||
1.0, 0.0, | ||
0.0, 0.0, | ||
// Back | ||
1.0, 1.0, | ||
1.0, 0.0, | ||
0.0, 0.0, | ||
0.0, 1.0, | ||
// Top | ||
0.0, 1.0, | ||
1.0, 1.0, | ||
1.0, 0.0, | ||
0.0, 0.0, | ||
// Bottom | ||
0.0, 1.0, | ||
1.0, 1.0, | ||
1.0, 0.0, | ||
0.0, 0.0, | ||
// Right | ||
1.0, 1.0, | ||
1.0, 0.0, | ||
0.0, 0.0, | ||
0.0, 1.0, | ||
// Left | ||
0.0, 1.0, | ||
1.0, 1.0, | ||
1.0, 0.0, | ||
0.0, 0.0, | ||
]; | ||
|
||
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(textureCoordinates), gl.STATIC_DRAW); | ||
|
||
const normalBuffer = gl.createBuffer(); | ||
gl.bindBuffer(gl.ARRAY_BUFFER, normalBuffer); | ||
const vertexNormals = [ | ||
// Front | ||
0.0, 0.0, 1.0, | ||
0.0, 0.0, 1.0, | ||
0.0, 0.0, 1.0, | ||
0.0, 0.0, 1.0, | ||
// Back | ||
0.0, 0.0, -1.0, | ||
0.0, 0.0, -1.0, | ||
0.0, 0.0, -1.0, | ||
0.0, 0.0, -1.0, | ||
// Top | ||
0.0, 1.0, 0.0, | ||
0.0, 1.0, 0.0, | ||
0.0, 1.0, 0.0, | ||
0.0, 1.0, 0.0, | ||
// Bottom | ||
0.0, -1.0, 0.0, | ||
0.0, -1.0, 0.0, | ||
0.0, -1.0, 0.0, | ||
0.0, -1.0, 0.0, | ||
// Right | ||
1.0, 0.0, 0.0, | ||
1.0, 0.0, 0.0, | ||
1.0, 0.0, 0.0, | ||
1.0, 0.0, 0.0, | ||
// Left | ||
1.0, 0.0, 0.0, | ||
1.0, 0.0, 0.0, | ||
1.0, 0.0, 0.0, | ||
1.0, 0.0, 0.0 | ||
]; | ||
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertexNormals), gl.STATIC_DRAW); | ||
|
||
this.buffer = { | ||
position: this.positionBuffer, | ||
normal: normalBuffer, | ||
textureCoord: textureCoordBuffer, | ||
indices: indexBuffer, | ||
} | ||
} | ||
|
||
drawCube(gl, projectionMatrix, programInfo, deltaTime) { | ||
const modelViewMatrix = mat4.create(); | ||
mat4.translate( | ||
modelViewMatrix, | ||
modelViewMatrix, | ||
this.pos | ||
); | ||
|
||
mat4.rotate(modelViewMatrix, | ||
modelViewMatrix, | ||
this.rotation, | ||
[0, 1, 0]); | ||
|
||
const normalMatrix = mat4.create(); | ||
mat4.invert(normalMatrix, modelViewMatrix); | ||
mat4.transpose(normalMatrix, normalMatrix); | ||
|
||
{ | ||
const numComponents = 3; | ||
const type = gl.FLOAT; | ||
const normalize = false; | ||
const stride = 0; | ||
const offset = 0; | ||
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer.position); | ||
gl.vertexAttribPointer( | ||
programInfo.attribLocations.vertexPosition, | ||
numComponents, | ||
type, | ||
normalize, | ||
stride, | ||
offset); | ||
gl.enableVertexAttribArray( | ||
programInfo.attribLocations.vertexPosition); | ||
} | ||
|
||
{ | ||
const numComponents = 2; | ||
const type = gl.FLOAT; | ||
const normalize = false; | ||
const stride = 0; | ||
const offset = 0; | ||
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer.textureCoord); | ||
gl.vertexAttribPointer( | ||
programInfo.attribLocations.textureCoord, | ||
numComponents, | ||
type, | ||
normalize, | ||
stride, | ||
offset); | ||
gl.enableVertexAttribArray( | ||
programInfo.attribLocations.textureCoord); | ||
} | ||
|
||
{ | ||
const numComponents = 3; | ||
const type = gl.FLOAT; | ||
const normalize = false; | ||
const stride = 0; | ||
const offset = 0; | ||
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer.normal); | ||
gl.vertexAttribPointer( | ||
programInfo.attribLocations.vertexNormal, | ||
numComponents, | ||
type, | ||
normalize, | ||
stride, | ||
offset); | ||
gl.enableVertexAttribArray( | ||
programInfo.attribLocations.vertexNormal); | ||
} | ||
|
||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.buffer.indices); | ||
|
||
gl.useProgram(programInfo.program); | ||
|
||
gl.uniformMatrix4fv( | ||
programInfo.uniformLocations.projectionMatrix, | ||
false, | ||
projectionMatrix); | ||
gl.uniformMatrix4fv( | ||
programInfo.uniformLocations.modelViewMatrix, | ||
false, | ||
modelViewMatrix); | ||
gl.uniformMatrix4fv( | ||
programInfo.uniformLocations.normalMatrix, | ||
false, | ||
normalMatrix); | ||
|
||
gl.activeTexture(gl.TEXTURE0); | ||
gl.bindTexture(gl.TEXTURE_2D, hoverboard_texture); | ||
gl.uniform1i(programInfo.uniformLocations.uSampler, 0); | ||
|
||
{ | ||
const vertexCount = 36; | ||
const type = gl.UNSIGNED_SHORT; | ||
const offset = 0; | ||
gl.drawElements(gl.TRIANGLES, vertexCount, type, offset); | ||
} | ||
|
||
} | ||
}; |
Oops, something went wrong.