boneTransform method

Vector3 boneTransform(
  1. int index,
  2. Vector3 target
)

Implementation

Vector3 boneTransform(int index, Vector3 target) {
  var skeleton = this.skeleton;
  var geometry = this.geometry!;

  _skinIndex.fromBufferAttribute(geometry.attributes["skinIndex"], index);
  _skinWeight.fromBufferAttribute(geometry.attributes["skinWeight"], index);

  _basePosition.copy(target).applyMatrix4(bindMatrix!);

  target.set(0, 0, 0);

  for (var i = 0; i < 4; i++) {
    var weight = _skinWeight.getComponent(i);

    if (weight != 0) {
      var boneIndex = _skinIndex.getComponent(i).toInt();

      _matrix.multiplyMatrices(skeleton!.bones[boneIndex].matrixWorld,
          skeleton.boneInverses[boneIndex]);

      target.addScaledVector(
          _vector.copy(_basePosition).applyMatrix4(_matrix), weight);
    }
  }

  return target.applyMatrix4(bindMatrixInverse);
}