Your Browser doesn't support canvas :(

Loading...

Click and drag to rotate the object

Click a button to draw a different model








In order to get larger OBJ files to work, with indices greater than the max of unsigned shorts (0xFFFF), we need to be able to use gl.UNSIGNED_INT as element index types. This type is natively available in WebGL 2. To enable webgl2, I added "webgl2" as a getContext argument option in ../lib/webgl-utils.js:

var names = ["webgl2", "webgl", "experimental-webgl", "webkit-3d", "moz-webgl"];

When creating the webgl index buffer, use a Uint32Array:

var indexArr = new Uint32Array(this.vertexIndices); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indexArr, gl.STATIC_DRAW);

When drawing via indices, use: (in OBJModel.js)

gl.drawElements(gl.TRIANGLES, this.n, gl.UNSIGNED_INT, 0);

Most OBJ models from https://www.prinmath.com/csci5229/OBJ/index.html

Woman GLTF model from https://github.com/PacktPublishing/Hands-On-Game-Animation-Programming/tree/master/Chapter11/Sample03/Assets

For GLTF parsing, the format is described here, while I found how to convert the base64 buffer data string to a Float32Array() here