本文整理汇总了TypeScript中babylonjs/Misc/tools.Tools.Error方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Tools.Error方法的具体用法?TypeScript Tools.Error怎么用?TypeScript Tools.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类babylonjs/Misc/tools.Tools
的用法示例。
在下文中一共展示了Tools.Error方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _ConvertFactorToVector3OrQuaternion
private static _ConvertFactorToVector3OrQuaternion(factor: number, babylonTransformNode: TransformNode, animation: Animation, animationType: number, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean): Nullable<Vector3 | Quaternion> {
let property: string[];
let componentName: string;
let value: Nullable<Quaternion | Vector3> = null;
const basePositionRotationOrScale = _GLTFAnimation._GetBasePositionRotationOrScale(babylonTransformNode, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
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.
property = animation.targetProperty.split('.');
componentName = property ? property[1] : ''; // x, y, or z component
value = useQuaternion ? Quaternion.FromArray(basePositionRotationOrScale).normalize() : Vector3.FromArray(basePositionRotationOrScale);
switch (componentName) {
case 'x': {
value[componentName] = (convertToRightHandedSystem && useQuaternion && (animationChannelTargetPath !== AnimationChannelTargetPath.SCALE)) ? -factor : factor;
break;
}
case 'y': {
value[componentName] = (convertToRightHandedSystem && useQuaternion && (animationChannelTargetPath !== AnimationChannelTargetPath.SCALE)) ? -factor : factor;
break;
}
case 'z': {
value[componentName] = (convertToRightHandedSystem && !useQuaternion && (animationChannelTargetPath !== AnimationChannelTargetPath.SCALE)) ? -factor : factor;
break;
}
case 'w': {
(value as Quaternion).w = factor;
break;
}
default: {
Tools.Error(`glTFAnimation: Unsupported component type "${componentName}" for scale animation!`);
}
}
}
return value;
}
示例2: _DeduceAnimationInfo
private static _DeduceAnimationInfo(animation: Animation): Nullable<_IAnimationInfo> {
let animationChannelTargetPath: Nullable<AnimationChannelTargetPath> = 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]}`);
}
}
if (animationChannelTargetPath) {
return { animationChannelTargetPath: animationChannelTargetPath, dataAccessorType: dataAccessorType, useQuaternion: useQuaternion };
}
else {
Tools.Error('animation channel target path and data accessor type could be deduced');
}
return null;
}
示例3: _AddKeyframeValue
/**
* Adds a key frame value
* @param keyFrame
* @param animation
* @param outputs
* @param animationChannelTargetPath
* @param basePositionRotationOrScale
* @param convertToRightHandedSystem
* @param useQuaternion
*/
private static _AddKeyframeValue(keyFrame: IAnimationKey, animation: Animation, outputs: number[][], animationChannelTargetPath: AnimationChannelTargetPath, babylonTransformNode: TransformNode, convertToRightHandedSystem: boolean, useQuaternion: boolean) {
let value: number[];
let newPositionRotationOrScale: Nullable<Vector3 | Quaternion>;
const animationType = animation.dataType;
if (animationType === Animation.ANIMATIONTYPE_VECTOR3) {
value = keyFrame.value.asArray();
if (animationChannelTargetPath === AnimationChannelTargetPath.ROTATION) {
const array = Vector3.FromArray(value);
let rotationQuaternion = Quaternion.RotationYawPitchRoll(array.y, array.x, array.z);
if (convertToRightHandedSystem) {
_GLTFUtilities._GetRightHandedQuaternionFromRef(rotationQuaternion);
if (!babylonTransformNode.parent) {
rotationQuaternion = Quaternion.FromArray([0, 1, 0, 0]).multiply(rotationQuaternion);
}
}
value = rotationQuaternion.asArray();
}
else if (animationChannelTargetPath === AnimationChannelTargetPath.TRANSLATION) {
if (convertToRightHandedSystem) {
_GLTFUtilities._GetRightHandedNormalArray3FromRef(value);
if (!babylonTransformNode.parent) {
value[0] *= -1;
value[2] *= -1;
}
}
}
outputs.push(value); // scale vector.
}
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) {
_GLTFUtilities._GetRightHandedQuaternionArrayFromRef(value);
if (!babylonTransformNode.parent) {
value = Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(value)).asArray();
}
}
outputs.push(value);
}
else {
Tools.Error('glTFAnimation: Unsupported key frame values for animation!');
}
}