kick.importer.ColladaImporter Class
Imports a Collada meshes into a scene
Item Index
Methods
addVertexAttributes
-
index
-
outVertexAttributes
-
outTriangleIndices
This method adds vertex attributes to the result index and
Parameters:
-
index
NumberSource index in vertex array (the p element)
-
outVertexAttributes
ObjectDestination vertex index array
-
outTriangleIndices
Array_NumberDestination vertex index array
BuildDataAccessor
-
elementChild
Create accessor object for data
Parameters:
-
elementChild
XML
Returns:
function of type function(index,paramOffset)
buildFromPolyList
-
polylist
-
destMeshData
Parameters:
-
polylist
XMLDomElement -
destMeshData
kick.mesh.MeshData
buildMeshData
()
Builds meshdata component (based on a <mesh> node)
getArrayElementById
-
id
Get data element by id
Note that the array is cached by id - this is done
to speed up performance in case of interleaved data
Parameters:
-
id
String
Returns:
data
glFunctionArgsToString
-
functionName
-
args
Converts the arguments of a WebGL function to a string. Attempts to convert enum arguments to strings.
Parameters:
-
functionName
Stringthe name of the WebGL function.
-
args
NumberThe arguments.
Returns:
The arguments as a string.
glFunctionArgToString
-
value
Gets an string version of an WebGL enum.
Parameters:
-
value
NumberValue to return an enum for
Returns:
The string version of the enum.
Example:
WebGLDebugUtil.init(ctx);
var str = WebGLDebugUtil.glEnumToString(ctx.getError());
glFunctionArgToString
-
functionName
-
argumentIndx
-
value
Converts the argument of a WebGL function to a string. Attempts to convert enum arguments to strings.
Parameters:
-
functionName
Stringthe name of the WebGL function.
-
argumentIndx
Numberthe index of the argument.
-
value
The value of the argument.
Returns:
The value as a string.
Example:
WebGLDebugUtil.init(ctx);
var str = WebGLDebugUtil.glFunctionArgToString('bindTexture', 0, gl.TEXTURE_2D);
would return 'TEXTURE_2D'
import
-
colladaDOM
-
[scene=engine.activeScene]
-
rotate90x
Parameters:
-
colladaDOM
XMLDom | String -
[scene=engine.activeScene]
kick.scene.Scene optionalIf not specified the active scene (from the engine) is used
-
rotate90x
Booleanrotate -90 degrees around x axis
Returns:
returns container object with the properties(mesh:[], gameObjects:[], materials:[])
init
-
ctx
Initializes this module. Safe to call more than once.
Parameters:
-
ctx
!WebGLRenderingContextA WebGL context. If you have more than one context it doesn't matter which one you pass in, it is only used to pull out constants.
makeDebugContext
-
ctx
-
opt_onErrorFunc
-
opt_onFunc
Given a WebGL context returns a wrapped context that calls gl.getError after every command and calls a function if the result is not NO_ERROR.
You can supply your own function if you want. For example, if you'd like an exception thrown on any GL error you could do this
Parameters:
-
ctx
!WebGLRenderingContextThe webgl context to wrap.
-
opt_onErrorFunc
!function(err, funcName, args): voidThe function to call when gl.getError returns an error. If not specified the default function calls console.log with a message.
-
opt_onFunc
!function(funcName, args): voidThe function to call when each webgl function is called. You can use this to log all calls for example.
Example:
function throwOnGLError(err, funcName, args) {
throw WebGLDebugUtils.glEnumToString(err) +
" was caused by call to " + funcName;
};
ctx = WebGLDebugUtils.makeDebugContext(
canvas.getContext("webgl"), throwOnGLError);
makeLostContextSimulatingCanvas
-
canvas
Given a canvas element returns a wrapped canvas element that will simulate lost context. The canvas returned adds the following functions.
loseContext: simulates a lost context event.
restoreContext: simulates the context being restored.
lostContextInNCalls: loses the context after N gl calls.
getNumCalls: tells you how many gl calls there have been so far.
setRestoreTimeout: sets the number of milliseconds until the context is restored after it has been lost. Defaults to 0. Pass -1 to prevent automatic restoring.
Parameters:
-
canvas
!CanvasThe canvas element to wrap.
mightBeEnum
-
value
Returns true or false if value matches any WebGL enum
Parameters:
-
value
Value to check if it might be an enum.
Returns:
True if value matches one of the WebGL defined enums
resetToInitialState
-
ctx
Resets a context to the initial state.
Parameters:
-
ctx
!WebGLRenderingContextThe webgl context to reset.
stringToArray
-
numberString
-
[type=[]]
Converts a string to an array
Parameters:
-
numberString
String -
[type=[]]
Object optionalvalid types are Array (default), and typed arrays classes