Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride: Nullable = null): Promise {
if (channel.target.node == undefined) {
return Promise.resolve();
}
const targetNode = ArrayItem.Get(`${context}/target/node`, this._gltf.nodes, channel.target.node);
// Ignore animations that have no animation targets.
if ((channel.target.path === AnimationChannelTargetPath.WEIGHTS && !targetNode._numMorphTargets) ||
(channel.target.path !== AnimationChannelTargetPath.WEIGHTS && !targetNode._babylonTransformNode)) {
return Promise.resolve();
}
const sampler = ArrayItem.Get(`${context}/sampler`, animation.samplers, channel.sampler);
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;
public _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride: Nullable = null): Promise {
if (channel.target.node == undefined) {
return Promise.resolve();
}
const targetNode = ArrayItem.Get(`${context}/target/node`, this._gltf.nodes, channel.target.node);
// Ignore animations that have no animation targets.
if ((channel.target.path === AnimationChannelTargetPath.WEIGHTS && !targetNode._numMorphTargets) ||
(channel.target.path !== AnimationChannelTargetPath.WEIGHTS && !targetNode._babylonTransformNode)) {
return Promise.resolve();
}
const sampler = ArrayItem.Get(`${context}/sampler`, animation.samplers, channel.sampler);
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";
private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup): Promise {
if (channel.target.node == undefined) {
return Promise.resolve();
}
const targetNode = ArrayItem.Get(`${context}/target/node`, this._gltf.nodes, channel.target.node);
// Ignore animations that have no animation targets.
if ((channel.target.path === AnimationChannelTargetPath.WEIGHTS && !targetNode._numMorphTargets) ||
(channel.target.path !== AnimationChannelTargetPath.WEIGHTS && !targetNode._babylonTransformNode)) {
return Promise.resolve();
}
const sampler = ArrayItem.Get(`${context}/sampler`, animation.samplers, channel.sampler);
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";
private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup): Promise {
if (channel.target.node == undefined) {
return Promise.resolve();
}
const targetNode = ArrayItem.Get(`${context}/target/node`, this._gltf.nodes, channel.target.node);
// Ignore animations that have no animation targets.
if ((channel.target.path === AnimationChannelTargetPath.WEIGHTS && !targetNode._numMorphTargets) ||
(channel.target.path !== AnimationChannelTargetPath.WEIGHTS && !targetNode._babylonTransformNode)) {
return Promise.resolve();
}
const sampler = ArrayItem.Get(`${context}/sampler`, animation.samplers, channel.sampler);
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;
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";
animationType = Animation.ANIMATIONTYPE_FLOAT;
break;
}
default: {
throw new Error(`${context}/target/path: Invalid value (${channel.target.path})`);
}
}
let outputBufferOffset = 0;
let getNextOutputValue: () => Vector3 | Quaternion | Array;
switch (targetPath) {
case "position": {
getNextOutputValue = () => {
const value = Vector3.FromArray(data.output, outputBufferOffset);
outputBufferOffset += 3;
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";
animationType = Animation.ANIMATIONTYPE_FLOAT;
break;
}
default: {
throw new Error(`${context}/target/path: Invalid value (${channel.target.path})`);
}
}
let outputBufferOffset = 0;
let getNextOutputValue: () => Vector3 | Quaternion | Array;
switch (targetPath) {
case "position": {
getNextOutputValue = () => {
const value = Vector3.FromArray(data.output, outputBufferOffset);
outputBufferOffset += 3;