import { Mesh } from '../core/Mesh.js' export class Cube { constructor() { this.data = [ -1.0, 1.0, -1.0, 0.5, 0.5, 0.5, -1.0, 1.0, 1.0, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5, 1.0, 1.0, -1.0, 0.5, 0.5, 0.5, -1.0, 1.0, 1.0, 0.75, 0.25, 0.5, -1.0, -1.0, 1.0, 0.75, 0.25, 0.5, -1.0, -1.0, -1.0, 0.75, 0.25, 0.5, -1.0, 1.0, -1.0, 0.75, 0.25, 0.5, 1.0, 1.0, 1.0, 0.25, 0.25, 0.75, 1.0, -1.0, 1.0, 0.25, 0.25, 0.75, 1.0, -1.0, -1.0, 0.25, 0.25, 0.75, 1.0, 1.0, -1.0, 0.25, 0.25, 0.75, 1.0, 1.0, 1.0, 1.0, 0.0, 0.15, 1.0, -1.0, 1.0, 1.0, 0.0, 0.15, -1.0, -1.0, 1.0, 1.0, 0.0, 0.15, -1.0, 1.0, 1.0, 1.0, 0.0, 0.15, 1.0, 1.0, -1.0, 0.0, 1.0, 0.15, 1.0, -1.0, -1.0, 0.0, 1.0, 0.15, -1.0, -1.0, -1.0, 0.0, 1.0, 0.15, -1.0, 1.0, -1.0, 0.0, 1.0, 0.15, -1.0, -1.0, -1.0, 0.5, 0.5, 1.0, -1.0, -1.0, 1.0, 0.5, 0.5, 1.0, 1.0, -1.0, 1.0, 0.5, 0.5, 1.0, 1.0, -1.0, -1.0, 0.5, 0.5, 1.0, ]; this.indicies = [ 0, 1, 2, 0, 2, 3, 5, 4, 6, 6, 4, 7, 8, 9, 10, 8, 10, 11, 13, 12, 14, 15, 14, 12, 16, 17, 18, 16, 18, 19, 21, 20, 22, 22, 20, 23 ]; this.verticies = [] this.colors = [] for (let x = 0; x < this.indicies.length; x++) { var i = this.indicies[x] this.verticies.push(this.data[i * 6 + 2]) this.verticies.push(this.data[i * 6 + 1]) this.verticies.push(this.data[i * 6 + 0]) this.colors.push(this.data[i * 6 + 3]) this.colors.push(this.data[i * 6 + 4]) this.colors.push(this.data[i * 6 + 5]) } this.mesh = new Mesh(this.indicies.length) .store(this.verticies, 3) .store(this.colors, 3) .finish() } }