Home Reference Source
public class | source

ObjLoader

This is a loader class of Obj file format.

Static Member Summary

Static Public Members
public static

Static Method Summary

Static Public Methods
public static

The static method to get singleton instance of this class.

Constructor Summary

Public Constructor
public

constructor(enforcer: Symbol)

The constructor of ObjLoader class.

Method Summary

Public Methods
public

loadObj(glBoostContext: glBoostContext, url: string, defaultShader: Shader, mtlString: string): Promise

the method to load Obj file.

Private Methods
private

_addQuadDataToArraysWithTexture(positions: *, normals: *, texcoords: *, pvCoord: *, pvNormal: *, pvTexture: *, stringToScan: *, fCount: *)

private

_addQuadDataToArraysWithoutTexture(positions: *, normals: *, texcoords: *, pvCoord: *, pvNormal: *, pvTexture: *, stringToScan: *, fCount: *)

private

_addTriangleDataToArraysWithTexture(positions: *, normals: *, texcoords: *, pvCoord: *, pvNormal: *, pvTexture: *, stringToScan: *, fCount: *)

private

_addTriangleDataToArraysWithoutTexture(positions: *, normals: *, texcoords: *, pvCoord: *, pvNormal: *, pvTexture: *, stringToScan: *, fCount: *)

private

_constructMesh(glBoostContext: *, objText: *, basePath: *, defaultShader: *, mtlString: *, resolve: *)

private

_loadMaterialsFromFile(glBoostContext: *, basePath: *, fileName: *, defaultShader: *): *

private

_loadMaterialsFromString(glBoostContext: *, mtlString: *, defaultShader: *, basePath: *, resolve: *)

private

_reductionVertices(positions: *, normals: *, texcoords: *, tmpPositions: *, tmpNormals: *, tmpTexcoords: *, vCount: *, matIndices: *, tmpIndices: *, _i: *): *

Static Public Members

public static [singleton]: * source

Static Public Methods

public static getInstance(): ObjLoader source

The static method to get singleton instance of this class.

Return:

ObjLoader

The singleton instance of ObjLoader class

Public Constructors

public constructor(enforcer: Symbol) source

The constructor of ObjLoader class. But you cannot use this constructor directly because of this class is a singleton class. Use getInstance() static method.

Params:

NameTypeAttributeDescription
enforcer Symbol

a Symbol to forbid calling this constructor directly

Public Methods

public loadObj(glBoostContext: glBoostContext, url: string, defaultShader: Shader, mtlString: string): Promise source

the method to load Obj file.

Params:

NameTypeAttributeDescription
glBoostContext glBoostContext

glBoostContext instance

url string

url of glTF file

defaultShader Shader
  • optional
  • default: undefined

a shader to assign to loaded geometries

mtlString string
  • optional
  • default: undefined

string of mtl file (optional)

Return:

Promise

a promise object

Private Methods

private _addQuadDataToArraysWithTexture(positions: *, normals: *, texcoords: *, pvCoord: *, pvNormal: *, pvTexture: *, stringToScan: *, fCount: *) source

Params:

NameTypeAttributeDescription
positions *
normals *
texcoords *
pvCoord *
pvNormal *
pvTexture *
stringToScan *
fCount *

private _addQuadDataToArraysWithoutTexture(positions: *, normals: *, texcoords: *, pvCoord: *, pvNormal: *, pvTexture: *, stringToScan: *, fCount: *) source

Params:

NameTypeAttributeDescription
positions *
normals *
texcoords *
pvCoord *
pvNormal *
pvTexture *
stringToScan *
fCount *

private _addTriangleDataToArraysWithTexture(positions: *, normals: *, texcoords: *, pvCoord: *, pvNormal: *, pvTexture: *, stringToScan: *, fCount: *) source

Params:

NameTypeAttributeDescription
positions *
normals *
texcoords *
pvCoord *
pvNormal *
pvTexture *
stringToScan *
fCount *

private _addTriangleDataToArraysWithoutTexture(positions: *, normals: *, texcoords: *, pvCoord: *, pvNormal: *, pvTexture: *, stringToScan: *, fCount: *) source

Params:

NameTypeAttributeDescription
positions *
normals *
texcoords *
pvCoord *
pvNormal *
pvTexture *
stringToScan *
fCount *

private _constructMesh(glBoostContext: *, objText: *, basePath: *, defaultShader: *, mtlString: *, resolve: *) source

Params:

NameTypeAttributeDescription
glBoostContext *
objText *
basePath *
defaultShader *
mtlString *
resolve *

private _loadMaterialsFromFile(glBoostContext: *, basePath: *, fileName: *, defaultShader: *): * source

Params:

NameTypeAttributeDescription
glBoostContext *
basePath *
fileName *
defaultShader *

Return:

*

private _loadMaterialsFromString(glBoostContext: *, mtlString: *, defaultShader: *, basePath: *, resolve: *) source

Params:

NameTypeAttributeDescription
glBoostContext *
mtlString *
defaultShader *
basePath *
  • optional
  • default: undefined
resolve *

private _reductionVertices(positions: *, normals: *, texcoords: *, tmpPositions: *, tmpNormals: *, tmpTexcoords: *, vCount: *, matIndices: *, tmpIndices: *, _i: *): * source

Params:

NameTypeAttributeDescription
positions *
normals *
texcoords *
tmpPositions *
tmpNormals *
tmpTexcoords *
vCount *
matIndices *
tmpIndices *
_i *

Return:

*