OBJ Class
OBJ class gives easy access to some calculations specific to OBJs. It is used to load an external .obj model file.
Item Index
Methods
Methods
encode64
-
inputStr
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
Extract the MimeType from the URL string of image files. Used internally for texture loading
Parameters:
-
url
String -
mimeType
Stringfrom the url
getOrCreate
-
object
-
key
-
cls
-
[args]
Method to retreive a value from an object if available, or instantiate a class with optional arguments Used in class constructors
Parameters:
-
object
ObjectThe object to retreive the value from if available
-
key
StringThe object's key from which the value should be looked up
-
cls
ClassThe class to instantiate if no value was found
-
[args]
Mixed optional multipleOptional arguments to send to the class's constructor
Returns:
The retreived a value or the new class instance
getOrDefault
-
object
-
key
-
defaultValue
Method to retreive a value from an object if available, or a default value Used in class constructors
Parameters:
-
object
ObjectThe object to retreive the value from if available
-
key
StringThe object's key from which the value should be looked up
-
defaultValue
MixedThe default value to return if the object does not contain the given key, or if the value accociated with the key is undefined
Returns:
The retreived a value or the default one
getOrExec
-
object
-
key
-
fn
-
[args]
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
ObjectThe object to retreive the value from if available
-
key
StringThe object's key from which the value should be looked up
-
fn
FunctionThe function to call if no value was found
-
[args]
Mixed optional multipleOptional arguments to send with the function
Returns:
The retreived a value or the function's return one
getUrlParameter
-
sParam
function to get the parameters of the url
Parameters:
-
sParam
Objectthe string of the parameter to get from the url
Returns:
the parameter if found, undefined elsewhere
noop
()
Null
A function that return null as a value
Returns:
null
parseMTL
-
loader
-
model
-
data
parse the MTL file associated to the obj file
Parameters:
-
loader
Loader -
model
ObjectThe model to attach a texture to
-
data
ObjectThe data to parse
parseOBJ
-
data
parse the OBJ file
Parameters:
-
data
ObjectThe data to parse
Returns:
singletonize
-
def
Method to force a class to have only one instance
Parameters:
-
def
ClassThe definition of the class
stringToArrayBuffer
-
str
Converts a DOMString to an ArrayBuffer (raw data binary).
Parameters:
-
str
DOMStringa string returned by a XMLHTTPRequest (responseText)
Returns:
the resulting ArrayBuffer
throttle
-
fn
-
threshhold
-
scope
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
FunctionThe function to throttle
-
threshhold
NumberThe threshhold in milliseconds
-
scope
ObjectThe scope in which the original function will be called
Returns:
The throttled function