cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

How to set sequence in Hololens 2(3D Eye Wear) Experience on Model Loaded event

Aditya1702
15-Moonstone

How to set sequence in Hololens 2(3D Eye Wear) Experience on Model Loaded event

Hi,

I have multiple sequence in a pvz file out of which I want to set a particular sequence as soon as the experience is started.

 

I tried setting the sequence as shown in the attached image but it is not working and the Hololens still loads the default sequence when the experience is triggered.

 

Also tried the below code to set the sequence and called it on model loaded event still it doe not set the sequence.

Code:

$scope.setSequence = function(){
$scope.app.view['Home'].wdg['model-1']['sequence'] = 'app/resources/Uploaded/l-Creo 3D - gtg1250.pvi';
}

 

Please help as soon as possible.

 

Thanks in advance.

 

Regards,

Aditya Gupta.

5 REPLIES 5

Hi @Aditya1702 ,

let say you can use the following funcitons to play your sequence and to check when it is loaded:

 

 

let $scope.mySeqName="Firgure1"

$scope.setSequence = function() {
  $scope.setWidgetProp('model-1','sequence',"app/resources/Uploaded/l-Creo 3D - "+$scope.mySeqName+ ".pvi");
$scope.$applyAsync();
}

$scope.$on('sequenceloaded', function(evt, model, type, sequence) {
  $scope.setWidgetProp('3DLabel-1','text',sequence); //set some text when loaded
});

 

 

The question how to load it when the view is playing one option is to call it with some delay - that is not the best option so you need depending on the size to estimate the time neccessarly for that:

 

 

let delay=3000 //3000 miliseconds
$timeout(()=>{$scope.setSequence},delay)

 

 

but much better is to use one of the event which are started when : modelLoad, ViewLoad or  angular ready events

 

 

angular.element(document).ready(async () => {
   let delay= 500 //3000 miliseconds
$timeout(()=>{$scope.setSequence();},delay)
});
//still some delay  but it could be also 0

 

 

ready:

 

 

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$scope.$on('$ionicView.afterEnter', function() {
 console.warn('$ionicView.afterEnter event called')
$timeout(()=>{$scope.setSequence();},300)
})

//+++++++++++++++++++++++++++++++++++++++++++++++++++

 

 

 

Here also an examle when you call it in modelLoad:

 

 

 

$rootScope.$on("modelLoaded", function() {
 
 for (var  i= 0; i < arguments.length; i++) 
   { //here only printing of the arguments to event
    console.warn('Argument ['+i+']='+arguments[i]);
    console.warn(">>Argument ["+i+"]=");
    console.warn(arguments[i]);
      
   }

  if (arguments.length >1){ 
    //================== if args >1 ==
    var modelWidgetId=arguments[1]; //that is the model loaded to the widget
        let model_wdg= $scope.view.wdg[modelWidgetId];   
	console.warn('console.warn(model_wdg);');
        let mdlsrc=$scope.getWidgetProp(modelWidgetId,'src');
        console.warn( "mdlsrc="+mdlSrc); 
  
        let mdlNameExt= mdlSrc.replace(/^.*[\\\/]/, ''); 
	console.warn( "mdlNameExt="+mdlNameExt); 
        var mdlName=mdlNameExt.replace(/\.[^/.]+$/, ""); 
	console.warn( "Model Name="+mdlName); 
     if(mdlName.indexOf("mydesired Name")
      {
        /// then call the action what you want to do when that model is loaded e.g.
           $timeout(()=>{$scope.setSequence();},50)

        }
   

  }
});

 

 

I think is that the best way because you can check which model was loaded and then load the appropirate sequence

 

 

Hi @RolandRaytchev ,

 

Do I need to paste this whole code?

 

$rootScope.$on("modelLoaded", function() {
 
 for (var  i= 0; i < arguments.length; i++) 
   { //here only printing of the arguments to event
    console.warn('Argument ['+i+']='+arguments[i]);
    console.warn(">>Argument ["+i+"]=");
    console.warn(arguments[i]);
      
   }

  if (arguments.length >1){ 
    //================== if args >1 ==
    var modelWidgetId=arguments[1]; //that is the model loaded to the widget
        let model_wdg= $scope.view.wdg[modelWidgetId];   
	console.warn('console.warn(model_wdg);');
        let mdlsrc=$scope.getWidgetProp(modelWidgetId,'src');
        console.warn( "mdlsrc="+mdlSrc); 
  
        let mdlNameExt= mdlSrc.replace(/^.*[\\\/]/, ''); 
	console.warn( "mdlNameExt="+mdlNameExt); 
        var mdlName=mdlNameExt.replace(/\.[^/.]+$/, ""); 
	console.warn( "Model Name="+mdlName); 
     if(mdlName.indexOf("mydesired Name")
      {
        /// then call the action what you want to do when that model is loaded e.g.
           $timeout(()=>{$scope.setSequence();},50)

        }
   

  }
});

 

 

I also tried setting sequence as shown in the attached image but it is still not working.

 

 

 

 

 

Hi @RolandRaytchev ,

 

If we set the sequence from Model-details panel for 3D Eyewear experience it is still not working.

Why is it so?

I am using Vuforia Studio 9.16.1.0.

 

Please reply asap.

 

Regards,

Aditya Gupta

Hi @Aditya1702 ,

the code I provided was from project what I tested in the past on HL2, I believe it was tested with 9.16 or 9.17.

So one question is what is the reason not to update. Here is relevant the verison the HoloLens2 device , e.g. Hey View , version

what is the code+build give

I think the version here is possibly not the most relevant point but it is better when we could clarify what is not working and where is not working/where is working.

- code what you used currently - is that what you pasted in your last post ---- because e.g.

if(mdlName.indexOf("mydesired Name")

need to be addapted to your modelName e.g.

The code was general example what needs to be udapted. If you require a help for that , please let me know more details.: modelWidget name, pvz name, sequence name etc.

-regarding working/not working ->  where? preview and HoloLens2 , or both. Do you see any errors in preview Cntrl+Shift+I so something printed then in the console windows   /when the issue occurs in Vuforia Studio preview mode/

Thanks

Announcements

Top Tags