Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_GLTFUtilities._GetRightHandedQuaternionArrayFromRef(basePositionRotationOrScale);
if (!babylonTransformNode.parent) {
basePositionRotationOrScale = Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(basePositionRotationOrScale)).asArray();
}
}
}
else {
basePositionRotationOrScale = Quaternion.Identity().asArray();
}
}
else {
basePositionRotationOrScale = babylonTransformNode.rotation.asArray();
_GLTFUtilities._GetRightHandedNormalArray3FromRef(basePositionRotationOrScale);
}
}
else if (animationChannelTargetPath === AnimationChannelTargetPath.TRANSLATION) {
basePositionRotationOrScale = babylonTransformNode.position.asArray();
if (convertToRightHandedSystem) {
_GLTFUtilities._GetRightHandedPositionArray3FromRef(basePositionRotationOrScale);
}
}
else { // scale
basePositionRotationOrScale = babylonTransformNode.scaling.asArray();
}
return basePositionRotationOrScale;
}
}
else if (animationType === Animation.ANIMATIONTYPE_FLOAT) { // handles single component x, y, z or w component animation by using a base property and animating over a component.
newPositionRotationOrScale = this._ConvertFactorToVector3OrQuaternion(keyFrame.value as number, babylonTransformNode, animation, animationType, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
if (newPositionRotationOrScale) {
if (animationChannelTargetPath === AnimationChannelTargetPath.ROTATION) {
let posRotScale = useQuaternion ? newPositionRotationOrScale as Quaternion : Quaternion.RotationYawPitchRoll(newPositionRotationOrScale.y, newPositionRotationOrScale.x, newPositionRotationOrScale.z).normalize();
if (convertToRightHandedSystem) {
_GLTFUtilities._GetRightHandedQuaternionFromRef(posRotScale);
if (!babylonTransformNode.parent) {
posRotScale = Quaternion.FromArray([0, 1, 0, 0]).multiply(posRotScale);
}
}
outputs.push(posRotScale.asArray());
}
else if (animationChannelTargetPath === AnimationChannelTargetPath.TRANSLATION) {
if (convertToRightHandedSystem) {
_GLTFUtilities._GetRightHandedNormalVector3FromRef(newPositionRotationOrScale as Vector3);
if (!babylonTransformNode.parent) {
newPositionRotationOrScale.x *= -1;
newPositionRotationOrScale.z *= -1;
}
}
}
outputs.push(newPositionRotationOrScale.asArray());
}
}
else if (animationType === Animation.ANIMATIONTYPE_QUATERNION) {
value = (keyFrame.value as Quaternion).normalize().asArray();
if (convertToRightHandedSystem) {
private static _DeduceAnimationInfo(animation: Animation): Nullable<_IAnimationInfo> {
let animationChannelTargetPath: Nullable = null;
let dataAccessorType = AccessorType.VEC3;
let useQuaternion: boolean = false;
let property = animation.targetProperty.split('.');
switch (property[0]) {
case 'scaling': {
animationChannelTargetPath = AnimationChannelTargetPath.SCALE;
break;
}
case 'position': {
animationChannelTargetPath = AnimationChannelTargetPath.TRANSLATION;
break;
}
case 'rotation': {
dataAccessorType = AccessorType.VEC4;
animationChannelTargetPath = AnimationChannelTargetPath.ROTATION;
break;
}
case 'rotationQuaternion': {
dataAccessorType = AccessorType.VEC4;
useQuaternion = true;
animationChannelTargetPath = AnimationChannelTargetPath.ROTATION;
break;
}
default: {
Tools.Error(`Unsupported animatable property ${property[0]}`);
}
private static _DeduceAnimationInfo(animation: Animation): Nullable<_IAnimationInfo> {
let animationChannelTargetPath: Nullable = null;
let dataAccessorType = AccessorType.VEC3;
let useQuaternion: boolean = false;
let property = animation.targetProperty.split('.');
switch (property[0]) {
case 'scaling': {
animationChannelTargetPath = AnimationChannelTargetPath.SCALE;
break;
}
case 'position': {
animationChannelTargetPath = AnimationChannelTargetPath.TRANSLATION;
break;
}
case 'rotation': {
dataAccessorType = AccessorType.VEC4;
animationChannelTargetPath = AnimationChannelTargetPath.ROTATION;
break;
}
case 'rotationQuaternion': {
dataAccessorType = AccessorType.VEC4;
useQuaternion = true;
animationChannelTargetPath = AnimationChannelTargetPath.ROTATION;
break;
}
default: {
Tools.Error(`Unsupported animatable property ${property[0]}`);
}
return this._loadAnimationSamplerAsync(`${animationContext}/samplers/${channel.sampler}`, sampler).then((data) => {
let targetPath: string;
let animationType: number;
switch (channel.target.path) {
case AnimationChannelTargetPath.TRANSLATION: {
targetPath = "position";
animationType = Animation.ANIMATIONTYPE_VECTOR3;
break;
}
case AnimationChannelTargetPath.ROTATION: {
targetPath = "rotationQuaternion";
animationType = Animation.ANIMATIONTYPE_QUATERNION;
break;
}
case AnimationChannelTargetPath.SCALE: {
targetPath = "scaling";
animationType = Animation.ANIMATIONTYPE_VECTOR3;
break;
}
case AnimationChannelTargetPath.WEIGHTS: {
targetPath = "influence";
return this._loadAnimationSamplerAsync(`${animationContext}/samplers/${channel.sampler}`, sampler).then((data) => {
let targetPath: string;
let animationType: number;
switch (channel.target.path) {
case AnimationChannelTargetPath.TRANSLATION: {
targetPath = "position";
animationType = Animation.ANIMATIONTYPE_VECTOR3;
break;
}
case AnimationChannelTargetPath.ROTATION: {
targetPath = "rotationQuaternion";
animationType = Animation.ANIMATIONTYPE_QUATERNION;
break;
}
case AnimationChannelTargetPath.SCALE: {
targetPath = "scaling";
animationType = Animation.ANIMATIONTYPE_VECTOR3;
break;
}
case AnimationChannelTargetPath.WEIGHTS: {
targetPath = "influence";