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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Flush/Clean/Reinitialize tml3dRenderer?

HectorAtLmco
7-Bedrock

Flush/Clean/Reinitialize tml3dRenderer?

Hello Vuforia aficionados!

Let's get to it...I have an assembly with hundreds of small objects (fasteners mainly) that need to be gathered and colored according to their properties/names. For obvious reasons, I do not want to assign individual modelItems to each one of these. It  seems then, we must use the tml3dRenderer object to change properties, such as color, etc. To gather the component ids, I use the async PTC.Metadata.fromId method for gathering my part ids and part names (this works very well, no complaints so far). I store all my ids in an array which I use later.

 

The Experience has a 'landing' view which allows you to select an area to inspect. After you click on the right image, it opens a different view with the proper models and target.

 

Here's the rub: My experience works well only the FIRST time I load it! If I use the back button to select a different area, the SECOND time, the components do NOT change color! I don't know why. I have painstakingly checked the sequence of events, and things are happening EXACTLY as the first time the View was loaded, there is no difference between the first and second times! (broken on both Preview and iPad)

 

Finally, the question: Is there a way to re-initialize the tml3dRenderer object? Does anybody have a clue as to what may be causing this? 

 

I am also open to other suggestions.

 

Thank you!

 

1 REPLY 1

Hi @HectorAtLmco ,

I was faced with a similar experience but only in preview mode when I used userpick and also changed between pvz files. Currently I am not able to reproduce this problem on IOS or Android but realized that the IOS has a problem when I use a color where color.a is not 1.0. So in this case my solution was to check the mobile type and to use for ios value of 1.0. Possibly this could cause some problems of the render engine.

....
....
//======================================
$scope.app.isIOS=function() { 
    if(!window.twx.app.isPreview()) // is not in Preview
       if(ionic.Platform.isIOS()) //and is NOT called on IOS = means Android mode detected
         return true;
   return false; }
//======================================
...
   angular.element(value).scope().$on('userpick',function(event,target,parent,edata) {
      if (edata) {
    
    if ($scope.currentSelection) {
       tml3dRenderer.setColor($scope.currentSelection, undefined);

    } 
    $scope.currentSelection = target + '-' + JSON.parse(edata).occurrence;
        let r =parseInt(Math.random()*255);
    	let g =parseInt(Math.random()*255);
    	let b =parseInt(Math.random()*255);
    	let a = ($scope.app.isIOS)? 1.0:parseInt(Math.random()*0.8)+0.2;//ios should have 1.0
    $scope.blinkSelection($scope.currentSelection,'rgba('+r+','+g+','+b+','+a+')',200,10);
      }    })                              
                   })},500)              
////////////////////////////////////////////////////////
....
....

the whole example project could be find there....

Top Tags