init method
void
init()
Implementation
void init() {
var bones = this.bones;
var boneInverses = this.boneInverses;
// layout (1 matrix = 4 pixels)
// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)
// 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16)
// 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32)
// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
double _size = Math.sqrt(bones.length * 4); // 4 pixels needed for 1 matrix
_size = MathUtils.ceilPowerOfTwo(_size).toDouble();
_size = Math.max(_size, 4);
int size = _size.toInt();
boneTextureSize = size;
boneMatrices = Float32Array(size * size * 4);
// calculate inverse bone matrices if necessary
if (boneInverses.isEmpty) {
calculateInverses();
} else {
// handle special case
if (bones.length != boneInverses.length) {
print(
'THREE.Skeleton: Number of inverse bone matrices does not match amount of bones.');
this.boneInverses = [];
for (var i = 0, il = this.bones.length; i < il; i++) {
this.boneInverses.add(Matrix4());
}
}
}
}