Unable to export Animation from model to Asset Item

Shashi_Yadav


The model has a custom script for animation, but when I export it to an Asset item, the animation does not export.  

This is the code for Animation:

let player = playerApi;
let start;

let startRot =  0;

let endRot = 90;

let totalRot = 90;

let maxTime = 2000; // in milliseconds

function step(timestamp) {

if (start === undefined) start = timestamp;

const elapsed = timestamp - (start);

const elapsedPercent = elapsed / maxTime;

// Adding animation percent to capture motion as defined by easing function

const animPercent = easeInOutCubic(elapsedPercent);

 
const nodeRot = player.scene.get({

   name: 'Animation',

   plug: 'Transform',

   property: 'rotation',

});

if(nodeRot.x==90) return;

 

const nodeMid = player.scene.get({

   name: 'Middle',

   plug: 'Transform',

   property: 'rotation',

});

nodeRot.x = Math.min(startRot + (totalRot * animPercent), endRot);
nodeMid.x= -1 * nodeRot.x;

player.scene.set({

   name: 'Animation',

   plug: 'Transform',

   property: 'rotation'

  },

   nodeRot    

);

player.scene.set({

   name: 'Middle',

   plug: 'Transform',

   property: 'rotation'

  },

   nodeMid

);

if (elapsed < maxTime) {

   window.requestAnimationFrame(step);

}
}
//Define easing function
function easeInOutCubic(x){
  return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
}

window.requestAnimationFrame(step);

It is working fine in the model but when exported to Asset Item  the animation doesn't work,  throws an error

Comments

3 comments

  • Comment author
    Permanently deleted user

    Hi Shashi,

    It's a bit difficult to diagnose this problem without seeing the asset you're working with, would you be able to enable support access on your org and link me the asset in question? I can take a look and see what I can figure out from there.

    Ian

    0
  • Comment author
    Shashi_Yadav

    Hi Ian,
    the support access is granted.

     

    0
  • Comment author
    Prashant

    @..... The issue is fixed now. Sandro has shared the code with us. 

    Thanks. 

    0

Please sign in to leave a comment.