UNPKG

ts-game-engine

Version:

Simple WebGL game/render engine written in TypeScript

21 lines (20 loc) 980 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Mesh_1 = require("./Mesh"); const gl_matrix_1 = require("gl-matrix"); class TriangleMesh extends Mesh_1.Mesh { constructor(scene) { super(scene); const vertexData = new Float32Array([ //Position Color Normal UV0 +0.0, +0.5, +0.0, 1, 0, 0, 1, 0, 0, 1, 0.5, 1.0, -0.5, -0.5, +0.0, 0, 1, 0, 1, 0, 0, 1, 0.0, 0.0, +0.5, -0.5, +0.0, 0, 0, 1, 1, 0, 0, 1, 1.0, 0.0 ]); const vertexFormat = 1 /* Position */ | 2 /* Color */ | 4 /* Normal */ | 8 /* UV0 */; this.SetVertexData(vertexFormat, 4 /* Triangles */, 3, vertexData, false); this.SetBounds(gl_matrix_1.vec3.fromValues(-0.5, -0.5, 0.0), gl_matrix_1.vec3.fromValues(0.5, 0.5, 0.0)); // { center: vec3.fromValues(0, 0, 0), radius: 0.707107 } this.isLoaded = true; } } exports.TriangleMesh = TriangleMesh;