FINALLY i have the fucking ball

This commit is contained in:
Evert Prants 2019-02-26 17:50:41 +02:00
parent a79ba6f606
commit 37fb3b1868
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 9 additions and 5 deletions

View File

@ -21,9 +21,6 @@ class CubeFace {
this.position = pos
this.transform = mat4.create()
mat4.fromTranslation(this.transform, this.position)
// Center the face
this.position = subv3(this.position, mulv3(this.left, this.radius / 2))
this.position = subv3(this.position, mulv3(this.forward, this.radius / 2))
@ -35,7 +32,7 @@ class CubeFace {
if (this.generated) return
let VERTICES = this.resolution
let count = (VERTICES - 1) * (VERTICES - 1)
let count = VERTICES * VERTICES
let vertices = new Array(count * 3)
// let normals = new Array(count * 3)
let textureCoords = new Array(count * 2)
@ -103,6 +100,9 @@ class CubePlanet {
this.resolution = resolution
this.radius = radius
this.transform = mat4.create()
mat4.fromTranslation(this.transform, origin)
let hs = radius / 2
this.faces = [
@ -115,6 +115,10 @@ class CubePlanet {
new CubeFace(this, 0, [0, hs, 0], [0, 1, 0], resolution, radius, generator), // top
new CubeFace(this, 0, [0, -hs, 0], [0, -1, 0], resolution, radius, generator) // bottom
]
for (let i in this.faces) {
this.faces[i].transform = this.transform
}
}
draw (gl, shader) {

View File

@ -38,7 +38,7 @@ async function pipeline () {
cam.updateProjection(game.gl)
// Planet test
let planet = new CubePlanet([0.0, 0.0, 0.0], 16, 36)
let planet = new CubePlanet([0.0, 0.0, 0.0], 16, 128)
// Update function for camera
game.addUpdateFunction(function (dt) {