r3-legacy/src/game-lib-d3-bone-weight.js

89 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-12-23 16:07:10 +01:00
/**
* BoneWeight Superset
* @constructor
* @param graphics GameLib.D3.Graphics
* @param apiBoneWeight GameLib.D3.API.BoneWeight
*/
GameLib.D3.BoneWeight = function RuntimeBoneWeight(
graphics,
apiBoneWeight
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
GameLib.D3.API.BoneWeight.call(
this,
apiBoneWeight.boneIndex,
apiBoneWeight.weight
);
this.instance = this.createInstance();
};
GameLib.D3.BoneWeight.prototype = Object.create(GameLib.D3.API.BoneWeight.prototype);
GameLib.D3.BoneWeight.prototype.constructor = GameLib.D3.BoneWeight;
/**
* Creates an instance boneWeight
* @param update boolean
*/
GameLib.D3.BoneWeight.prototype.createInstance = function(update) {
var instance = null;
if (update) {
//TODO - update instance with boneWeight info
instance = this.instance;
} else {
//TODO - fix this
instance = new THREE.Quaternion();
}
return instance;
};
/**
* Updates the instance
*/
GameLib.D3.BoneWeight.prototype.updateInstance = function() {
this.instance = this.createInstance(true);
};
/**
* Converts a GameLib.D3.BoneWeight to GameLib.D3.API.BoneWeight
* @returns {GameLib.D3.API.BoneWeight}
*/
GameLib.D3.BoneWeight.prototype.toApiBoneWeight = function() {
var apiBoneWeight = new GameLib.D3.API.BoneWeight(
this.boneIndex,
this.weight
);
return apiBoneWeight;
};
/**
* Returns a GameLib.D3.BoneWeight from a boneWeight Object
* @param graphics GameLib.D3.Graphics
* @param objectBoneWeight Object
* @returns {GameLib.D3.BoneWeight}
* @constructor
*/
GameLib.D3.BoneWeight.FromObjectBoneWeight = function(
graphics,
objectBoneWeight
) {
var apiBoneWeight = new GameLib.D3.API.BoneWeight(
objectBoneWeight.boneIndex,
objectBoneWeight.weight
);
var boneWeight = new GameLib.D3.BoneWeight(
graphics,
apiBoneWeight
);
return boneWeight;
};