diff --git a/src/engine/components/planet/index.js b/src/engine/components/planet/index.js index 483733b..0111222 100644 --- a/src/engine/components/planet/index.js +++ b/src/engine/components/planet/index.js @@ -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) { diff --git a/src/index.js b/src/index.js index e472639..5663d26 100644 --- a/src/index.js +++ b/src/index.js @@ -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) {