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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Read the coordinates of the model

Giuseppe_Fiore
15-Moonstone

Read the coordinates of the model

Hi ,

It's possible to read the coordinates of a model or widget using javascript ?


Thanks in advance.

Giuseppe

ACCEPTED SOLUTION

Accepted Solutions

Hi Giuseppe. I was able to get the model coordinates to show on a label within the experience doing the following:

  1. Set up App parameters xpos, ypos, zpos

    2. Create 3 2D or 3D labels within your experience to display the coordinate values

    3. Create a button with title 'show coordinates'

    4. Bind xpos, ypos, & zpos to each corresponding label 'text' property.

    5. Add code to Home.js

      $scope.showCoords = function(){

                           var Xpos = document.querySelector('#model-1').getAttribute("x");

                           $scope.app.params.xpos = Xpos;

                           var Ypos = document.querySelector('#model-1').getAttribute("y");

                           $scope.app.params.ypos = Ypos;

                           var Zpos = document.querySelector('#model-1').getAttribute("z");

                           $scope.app.params.zpos = Zpos;

                         };

    6. Call showCoords(); on button click

    7. Save & publish.

Here is what my preview looks like

View solution in original post

2 REPLIES 2

Hi Giuseppe. I was able to get the model coordinates to show on a label within the experience doing the following:

  1. Set up App parameters xpos, ypos, zpos

    2. Create 3 2D or 3D labels within your experience to display the coordinate values

    3. Create a button with title 'show coordinates'

    4. Bind xpos, ypos, & zpos to each corresponding label 'text' property.

    5. Add code to Home.js

      $scope.showCoords = function(){

                           var Xpos = document.querySelector('#model-1').getAttribute("x");

                           $scope.app.params.xpos = Xpos;

                           var Ypos = document.querySelector('#model-1').getAttribute("y");

                           $scope.app.params.ypos = Ypos;

                           var Zpos = document.querySelector('#model-1').getAttribute("z");

                           $scope.app.params.zpos = Zpos;

                         };

    6. Call showCoords(); on button click

    7. Save & publish.

Here is what my preview looks like

Great Tara,

works perfectly, thank you for the precious help.



Announcements

Top Tags