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

Colour of model item is changes only after double cllicking the model item

manojpandey
13-Aquamarine

Colour of model item is changes only after double cllicking the model item

Hello everyone

I wanted that when any model item gets clicked it's colour should change and as well as some labels and image should be displayed. But I am going through some problems.

 Problem 1: In preview when I single click model Item only labels and image gets displayed but when i double click it, colour of model item changes and label and image gets displayed. I want to convert this double click into single click mechanism.

 

Problem 2: During experience after double clicking on model item, labels and image gets dissapear but colour does not get back to normal. I want colour should also get back to normal.

 

 I have attached my project. Also I don't know much of coding. 

 

 

ACCEPTED SOLUTION

Accepted Solutions

Hi @manojpandey,

first I want to mention  2 things which will make more easy to receive an answer in the community

  • when you report an issue, it will be better to provide only the info relevant to the problem. And if you upload a project – it will be better if it contains only code which is only  relevant to current   Because I see that there is the code is growing after your last question and it make more difficult to identify the code which is related to the reported issue. So therefore, please , try always to simplified the attached project , that when somebody  is trying to help and review the project  not to lose too much time to understand first where the problem code is
  • the second point is – if you have more than one questions – in this case is better to ask an additional post to for each problem – so may be different people in the community could help.

So to your question problem  1.)

The modelitem widget supports only the click (one click9event. The behavior what you mention with the double click it is a general behavior of the UI / here the preview mode.

So OOTB (out of the box) we can use only click event but with JavaScript we define also a double click

The simples approach is following: So let say you have a particular function for each modelItem widget. The function is used in the click envet. You want now that this function will akt only for double click . E.g. for the widget modelItem-1:

…
$scope.TimeIntervalForDoubleClickMS =500
$scope.modelItem1ClickAktive=false;
…
//call back function for the click event of the widget: modelItem-1
$scope.modelItem1Click= function()
{
//is this a DoubleClick?
If($scope.modelItem1ClickAktive)
{ // it was inside the double click time interval
$scope.modelItem1ClickAktive=false;
//… do here the code for the doubleclick event
}
else {
// it is the first click after some time
$scope.modelItem1ClickAktive=true;
// call function with a Time Interval delay to reset the variable
$timeout($scope.resetFmodelItem1()  , $scope.TimeIntervalForDoubleClickMS)
}
}
///////////// reset the variable for modelItem1
$scope.resetFmodelItem1 = function(){$scope.modelItem1ClickAktive=false;};

A disadvantage of this approach is that you need this definition for each modelItem widget where you want to handle the click /DoubleClick event

The another point what you mention is that double click in UI calling some kind of zoom ALL in the preview. "I want to convert this double click into single click mechanism."  

I think possibly we can  manage this using the click event …

document.addEventListener('click', function(event) {console.log("click() 1 called");
  $scope.lastClick = {
    x: event.pageX, y: event.pageY};
});

 

But the question is about the sense, because on mobile device this will do not make really  sense. Please, pay attention that the preview UI only simulate the display for mobile device, so that developer could get idea about the behavior of his AR application. For example the preview mode display some zoom , pan factors and here the zoom All (on double click) but this is only a rough simulation of the change of the device camera position. On the real device the zoom , pan  factors follow always the camera position – means if you move away  or go closer to the real object with  your camera /your device so this will  have the effect of zoom. So the zoom and pan are only result of the  current camera position. Therefore, the zoom an pan make no sense

About your Question 2.). Is this behavior only in preview mode or you can reproduce it on mobile device? Because as I already mentioned  above the double click behavior in Preview  is only an auxiliary functionality for testing during development. To be sure if this effect is available on the end device you need to test it there

View solution in original post

3 REPLIES 3

Hi @manojpandey,

first I want to mention  2 things which will make more easy to receive an answer in the community

  • when you report an issue, it will be better to provide only the info relevant to the problem. And if you upload a project – it will be better if it contains only code which is only  relevant to current   Because I see that there is the code is growing after your last question and it make more difficult to identify the code which is related to the reported issue. So therefore, please , try always to simplified the attached project , that when somebody  is trying to help and review the project  not to lose too much time to understand first where the problem code is
  • the second point is – if you have more than one questions – in this case is better to ask an additional post to for each problem – so may be different people in the community could help.

So to your question problem  1.)

The modelitem widget supports only the click (one click9event. The behavior what you mention with the double click it is a general behavior of the UI / here the preview mode.

So OOTB (out of the box) we can use only click event but with JavaScript we define also a double click

The simples approach is following: So let say you have a particular function for each modelItem widget. The function is used in the click envet. You want now that this function will akt only for double click . E.g. for the widget modelItem-1:

…
$scope.TimeIntervalForDoubleClickMS =500
$scope.modelItem1ClickAktive=false;
…
//call back function for the click event of the widget: modelItem-1
$scope.modelItem1Click= function()
{
//is this a DoubleClick?
If($scope.modelItem1ClickAktive)
{ // it was inside the double click time interval
$scope.modelItem1ClickAktive=false;
//… do here the code for the doubleclick event
}
else {
// it is the first click after some time
$scope.modelItem1ClickAktive=true;
// call function with a Time Interval delay to reset the variable
$timeout($scope.resetFmodelItem1()  , $scope.TimeIntervalForDoubleClickMS)
}
}
///////////// reset the variable for modelItem1
$scope.resetFmodelItem1 = function(){$scope.modelItem1ClickAktive=false;};

A disadvantage of this approach is that you need this definition for each modelItem widget where you want to handle the click /DoubleClick event

The another point what you mention is that double click in UI calling some kind of zoom ALL in the preview. "I want to convert this double click into single click mechanism."  

I think possibly we can  manage this using the click event …

document.addEventListener('click', function(event) {console.log("click() 1 called");
  $scope.lastClick = {
    x: event.pageX, y: event.pageY};
});

 

But the question is about the sense, because on mobile device this will do not make really  sense. Please, pay attention that the preview UI only simulate the display for mobile device, so that developer could get idea about the behavior of his AR application. For example the preview mode display some zoom , pan factors and here the zoom All (on double click) but this is only a rough simulation of the change of the device camera position. On the real device the zoom , pan  factors follow always the camera position – means if you move away  or go closer to the real object with  your camera /your device so this will  have the effect of zoom. So the zoom and pan are only result of the  current camera position. Therefore, the zoom an pan make no sense

About your Question 2.). Is this behavior only in preview mode or you can reproduce it on mobile device? Because as I already mentioned  above the double click behavior in Preview  is only an auxiliary functionality for testing during development. To be sure if this effect is available on the end device you need to test it there

Thanks man..

'problem 2' is in both preview as well as in experience

Announcements

Top Tags