Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Hello!
We need to be able to dynamically load a model target using Java Script. This will reduce the number of experiences we have to create significantly. I was given a sample by PTC that shows how to do this, but I keep getting a message that reads 'Error loading tracker data' and it never actually loads. Just FYI, I am trying to load this from a THINGWORX REPOSITORY located in the same server as Vuforia. This is the sample:
1. I added a TML Text widget to the Experience, and I added this text, as suggested by PTC:
<twx-dt-target id="variabletarget"
guide-src="{{app.params.targetGuideSrc}}"
src="{{app.params.targetSrc}}"
x="{{app.params.targetXOrigin}}"
y="{{app.params.targetYOrigin}}"
z="{{app.params.targetZOrigin}}"
rx="{{app.params.targetRXOrigin}}"
ry="{{app.params.targetRYOrigin}}"
rz="{{app.params.targetRZOrigin}}"
enablescalegesture="{{app.params.gestures}}"
enablerotategesture="{{app.params.gestures}}"
enabletranslategesture="{{app.params.gestures}}"
istracked="false">
</twx-dt-target>
You can clearly see that several of these properties are set by Application Parameters. Suffice to say that I properly added those parameters previously.
I then assign variables and set the parameter values before calling the view with the TML:
var areaName = 'LWR_3';
var targetFilePath = "/Thingworx/FileRepositories/FwBracketInspectionFileRepo_hhenry/Targets/CTOL/"
var targetPvzFileName = targetFilePath + areaName + '/' + areaName + '.pvz';
var targetUUIDname = 'd6e488db-56f0-4e2e-8c32-29f8cbe1a19a';
//Target
$scope.app.params.targetsrc='vuforia-model:///' + targetPvzFileName;
$scope.app.params.targetGuidesrc=targetFilePath + areaName + '/' + targetUUIDname + '.png';
$scope.app.params.gestures = 'false';
$scope.app.fn.navigate('Main');
So... if anyone has a clear example of how to load and use a model target programmatically, that would be great!
Thank you so much!
Hi @HectorAtLmco ,
here is a sample project on the github which is related to your quesiton and possibly could be helpful:
https://github.com/steveghee/partAI-experience
but ...
https://library.vuforia.com/articles/Solution/trained-model-target-datasets.html
https://library.vuforia.com/articles/Solution/model-target-guide-view.html