API Documentation

for 0.0.1
Show:

OBJ Class

OBJ class gives easy access to some calculations specific to OBJs. It is used to load an external .obj model file.

Methods

encode64

(
  • inputStr
)
private

Method to convert a string to Base64. Used internally to convert loaded raw data to img. Wrote by phil@philten.com - http://www.philten.com

Parameters:

  • inputStr String

getMimeType

(
  • url
  • mimeType
)
private

Extract the MimeType from the URL string of image files. Used internally for texture loading

Parameters:

  • url String
  • mimeType String

    from the url

getOrCreate

(
  • object
  • key
  • cls
  • [args]
)
Mixed

Method to retreive a value from an object if available, or instantiate a class with optional arguments Used in class constructors

Parameters:

  • object Object

    The object to retreive the value from if available

  • key String

    The object's key from which the value should be looked up

  • cls Class

    The class to instantiate if no value was found

  • [args] Mixed optional multiple

    Optional arguments to send to the class's constructor

Returns:

Mixed:

The retreived a value or the new class instance

getOrDefault

(
  • object
  • key
  • defaultValue
)
Mixed

Method to retreive a value from an object if available, or a default value Used in class constructors

Parameters:

  • object Object

    The object to retreive the value from if available

  • key String

    The object's key from which the value should be looked up

  • defaultValue Mixed

    The default value to return if the object does not contain the given key, or if the value accociated with the key is undefined

Returns:

Mixed:

The retreived a value or the default one

getOrExec

(
  • object
  • key
  • fn
  • [args]
)
Mixed

Method to retreive a value from an object if available, or the return value of a function with optional arguments Used in class constructors

Parameters:

  • object Object

    The object to retreive the value from if available

  • key String

    The object's key from which the value should be looked up

  • fn Function

    The function to call if no value was found

  • [args] Mixed optional multiple

    Optional arguments to send with the function

Returns:

Mixed:

The retreived a value or the function's return one

parseMTL

(
  • loader
  • model
  • data
)
static

parse the MTL file associated to the obj file

Parameters:

  • loader Loader
  • model Object

    The model to attach a texture to

  • data Object

    The data to parse

parseOBJ

(
  • data
)
Mesh static

parse the OBJ file

Parameters:

  • data Object

    The data to parse

Returns:

Mesh:

singletonize

(
  • def
)

Method to force a class to have only one instance

Parameters:

  • def Class

    The definition of the class

stringToArrayBuffer

(
  • str
)
ArrayBuffer

Converts a DOMString to an ArrayBuffer (raw data binary).

Parameters:

  • str DOMString

    a string returned by a XMLHTTPRequest (responseText)

Returns:

ArrayBuffer:

the resulting ArrayBuffer

throttle

(
  • fn
  • threshhold
  • scope
)
Function

Returns a throttled version of a function The returned function will only call the original function at most once per the specified threshhold

Parameters:

  • fn Function

    The function to throttle

  • threshhold Number

    The threshhold in milliseconds

  • scope Object

    The scope in which the original function will be called

Returns:

Function:

The throttled function