webgl-obj-loader
Advanced tools
Comparing version 2.0.5 to 2.0.6
export declare enum TYPES { | ||
"BYTE" = 1, | ||
"UNSIGNED_BYTE" = 1, | ||
"SHORT" = 2, | ||
"UNSIGNED_SHORT" = 2, | ||
"FLOAT" = 4 | ||
"BYTE" = "BYTE", | ||
"UNSIGNED_BYTE" = "UNSIGNED_BYTE", | ||
"SHORT" = "SHORT", | ||
"UNSIGNED_SHORT" = "UNSIGNED_SHORT", | ||
"FLOAT" = "FLOAT" | ||
} | ||
@@ -8,0 +8,0 @@ export interface AttributeInfo { |
@@ -79,3 +79,4 @@ import { Layout } from "./layout"; | ||
makeIndexBufferData(): Uint16ArrayWithItemSize; | ||
makeIndexBufferDataForMaterials(...materialIndices: Array<number>): Uint16ArrayWithItemSize; | ||
addMaterialLibrary(mtl: MaterialLibrary): void; | ||
} |
{ | ||
"name": "webgl-obj-loader", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "A simple OBJ model loader to help facilitate the learning of WebGL", | ||
@@ -56,4 +56,2 @@ "main": "dist/webgl-obj-loader.min.js", | ||
"chai": "^4.1.2", | ||
"eslint": "^6.6.0", | ||
"eslint-config-google": "^0.14.0", | ||
"mocha": "6.2.2", | ||
@@ -60,0 +58,0 @@ "nyc": "^14.1.1", |
export enum TYPES { | ||
"BYTE" = 1, | ||
"UNSIGNED_BYTE" = 1, | ||
"SHORT" = 2, | ||
"UNSIGNED_SHORT" = 2, | ||
"FLOAT" = 4, | ||
"BYTE" = "BYTE", | ||
"UNSIGNED_BYTE" = "UNSIGNED_BYTE", | ||
"SHORT" = "SHORT", | ||
"UNSIGNED_SHORT" = "UNSIGNED_SHORT", | ||
"FLOAT" = "FLOAT", | ||
} | ||
@@ -66,3 +66,17 @@ | ||
constructor(public key: string, public size: number, public type: TYPES, public normalized: boolean = false) { | ||
this.sizeOfType = this.type; | ||
switch (type) { | ||
case "BYTE": | ||
case "UNSIGNED_BYTE": | ||
this.sizeOfType = 1; | ||
break; | ||
case "SHORT": | ||
case "UNSIGNED_SHORT": | ||
this.sizeOfType = 2; | ||
break; | ||
case "FLOAT": | ||
this.sizeOfType = 4; | ||
break; | ||
default: | ||
throw new Error(`Unknown gl type: ${type}`); | ||
} | ||
this.sizeInBytes = this.sizeOfType * size; | ||
@@ -69,0 +83,0 @@ } |
@@ -270,3 +270,3 @@ import { Layout } from "./layout"; | ||
*/ | ||
const vertex = elements[j].split("/"); | ||
const vertex = triangle[j].split("/"); | ||
// it's possible for faces to only specify the vertex | ||
@@ -742,2 +742,11 @@ // and the normal. In this case, vertex will only have | ||
makeIndexBufferDataForMaterials(...materialIndices: Array<number>): Uint16ArrayWithItemSize { | ||
const indices: number[] = new Array<number>().concat( | ||
...materialIndices.map(mtlIdx => this.indicesPerMaterial[mtlIdx]), | ||
); | ||
const buffer: Uint16ArrayWithItemSize = new Uint16Array(indices); | ||
buffer.numItems = indices.length; | ||
return buffer; | ||
} | ||
addMaterialLibrary(mtl: MaterialLibrary) { | ||
@@ -744,0 +753,0 @@ for (const name in mtl.materials) { |
@@ -28,6 +28,5 @@ import Mesh from "./mesh"; | ||
const mapData = (material as any)[attr] as TextureMapData; | ||
if (!mapData) { | ||
if (!mapData || !mapData.filename) { | ||
continue; | ||
} | ||
const url = root + mapData.filename; | ||
@@ -34,0 +33,0 @@ textures.push( |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
739148
18
31
5800