Start a new topic

3D-Object: Start an animation in onloaded-event only works with delay

3D-Object: Start an animation in onloaded-event only works with delay
1 Comment


Hello,

i have a little problem. I'm loading an animated 3d-object after the image is triggered. (We have multiple erperiences in this world and i want to save memory: only load an experience if it is needed). If the 3d-object is receiving the onLoaded-event i want to start the animation.

But the animation only starts if i put a delay of some milliseconds after the onLoaded-event is received. Why I have to do this?

Thanks for your help.

 

See my source:

this.trackableSmarteEnergie = new AR.Trackable2DObject(this.tracker, Track_ID_SmarteEnergie, {

  onEnterFieldOfVision: this.smarteEnergieAppear

});

smarteEnergieAppear: function smarteEnergieAppearFn() {


  World.modelFlagEnergie = new AR.Model("assets/smarte_energie/s13_smarte_energie.wt3", {

    onClick: function() { AR.context.startVideoPlayer("assets/smarte_energie/smarteEnergie_video.mp4"); },

    // !!!! not working ->

    // onLoaded: function() {

    // var anim = new AR.ModelAnimation(World.modelFlagEnergie, "s_smarte_energie_animation");

    // anim.start();

    // },

    // working ->

    onLoaded: function() {

      setTimeout(function() {

        var anim = new AR.ModelAnimation(World.modelFlagEnergie, "s_smarte_energie_animation");

        anim.start();

      }, 500);

    },

    scale: {

      x: 0.0013,

      y: 0.0013,

      z: 0.0013

    },

    translate: {

      x: -0.12,

      y: -0.18,

      z: 0.0

    }

    });

  World.trackableSmarteEnergie.drawables.addCamDrawable(, 0);

}

 


 
Login or Signup to post a comment