Skip to main content
16-Pearl
July 21, 2024
Question

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

  • July 21, 2024
  • 1 reply
  • 1818 views

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.

1 reply

21-Topaz I
July 22, 2024

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)
})

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

 

 

 

21-Topaz I
July 22, 2024

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

 

 

16-Pearl
July 23, 2024

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.