r3-legacy/src/game-lib-d3-api-skeleton.js

80 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-12-23 16:07:10 +01:00
/**
* API Skeleton
* @param id
* @param name
* @param bones GameLib.D3.API.Bone[]
* @param boneInverses GameLib.API.Matrix4[]
* @param useVertexTexture boolean
* @param boneTextureWidth Number
* @param boneTextureHeight Number
* @param boneMatrices GameLib.API.Matrix4[]
* @param boneTexture null (not implemented)
* @constructor
*/
GameLib.D3.API.Skeleton = function (
id,
name,
bones,
boneInverses,
useVertexTexture,
boneTextureWidth,
boneTextureHeight,
boneMatrices,
boneTexture
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Skeleton';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(bones)) {
bones = [];
}
this.bones = bones;
/**
* An array of Matrix4s that represent the inverse of the matrixWorld of the individual bones.
*/
if (GameLib.Utils.UndefinedOrNull(boneInverses)) {
boneInverses = [];
}
this.boneInverses = boneInverses;
/**
* Use a vertex texture in the shader - allows for more than 4 bones per vertex, not supported by all devices
*/
if (GameLib.Utils.UndefinedOrNull(useVertexTexture)) {
useVertexTexture = false;
}
this.useVertexTexture = useVertexTexture;
if (useVertexTexture) {
console.warn('support for vertex texture bones is not supported yet - something could break somewhere');
}
if (GameLib.Utils.UndefinedOrNull(boneTextureWidth)) {
boneTextureWidth = 0;
}
this.boneTextureWidth = boneTextureWidth;
if (GameLib.Utils.UndefinedOrNull(boneTextureHeight)) {
boneTextureHeight = 0;
}
this.boneTextureHeight = boneTextureHeight;
if (GameLib.Utils.UndefinedOrNull(boneMatrices)) {
boneMatrices = [];
}
this.boneMatrices = boneMatrices;
if (GameLib.Utils.UndefinedOrNull(boneTexture)) {
boneTexture = null;
}
this.boneTexture = boneTexture;
};