Skip to main content
19-Tanzanite
December 9, 2019
Solved

How to load 3D model in runtime from Thingworx File Repository

  • December 9, 2019
  • 1 reply
  • 2485 views

Hello all,

 

I have some 3D model files stored in Thingworx Repository. Is it possible to load 3D model dynamically in Runtime ?

 

Thanks in advance

 

/VR

Best answer by Velkumar

Hi @RolandRaytchev 

 

Thanks for your response. I have mapped 3D model resource location dynamically using Thingworx repository service in External Data. It working fine.

 

/VR

1 reply

21-Topaz I
December 9, 2019

Hi @Velkumar ,

 

I think this this could be done possibly by javaScript for small objects /models. For large models   this, may be, will not make a sense.

The problem there is that  you cannot download the object to the download resource folder of the project – at least not possible from the Vuforia studio preview /view app.  Ok , in same cases if the thingworx server has access of the experience service folder – it is theoretical  possible that you can use a service which could start a OS to copy of a file … not sure how the implementation should looks like

You can use the Thingworx service LoadBinary to load a binary file (any file format also CAD file)  from an Thingworx repository to  a javaScript variable and try to set it to the source property  of the model widget. May be this could work. I did not test it actually for models but I think that it could work. I did in the code below download a video file and set it to a video widget and played it afterword’s.  To work it required some test /trial and error/ :

 

////////////////////Issue with read video from repository
$scope.GetVideoFromTwxRepository = function(path, play) {

 $scope.$applyAsync(function() {
 
 $rootScope.$broadcast('app.mdl.CAD-Files-Repository.svc.LoadBinary',
 {"path":path}
 );} ,500 );
 
 console.log("after calling GetVideoFromTwx");
 
};

////////////////////////////////////////////////////////////////

// register the modelLoad event - when loading of 3d complete
$rootScope.$on('modelLoaded', function() {
// when load binary event complete
$scope.$root.$on('LoadBinary-complete', function(event, args) { 
 
console.log("name="+event.name)
// set the loaded video to the sorce of the video widget
var ret_str='data:video/mp4;base64,'+args.data[0].Content;
 $scope.view.wdg['video-1']['videosrc']=ret_str; 
 console.warn($scope.view.wdg['video-1']['videosrc'])
 //now play the video 
 $timeout(function () { $scope.$root.$broadcast('app.view["Home"].wdg["video-1"].svc.play'); }, 500);
 
 });

};

 

Velkumar19-TanzaniteAuthorAnswer
19-Tanzanite
December 10, 2019

Hi @RolandRaytchev 

 

Thanks for your response. I have mapped 3D model resource location dynamically using Thingworx repository service in External Data. It working fine.

 

/VR