Skip to main content
1-Visitor
February 13, 2020
Question

How to drag model item with JS in an experience?

  • February 13, 2020
  • 2 replies
  • 4448 views

I want to drag model item by touch gesture with JS.

2 replies

14-Alexandrite
February 17, 2020

Hello  Burhanuddin,

 

What is the use case you are trying to achieve? Could you please elaborate on that?

Thank you.

 

Kind regards,

Lorena Gherman

1-Visitor
February 18, 2020

The use case i am trying to achieve is that to Disassemble a model with dragging out the model item in any direction  with touch gesture in an experience .

 

 

 

 

 

Thank you

Burhanuddin

1-Visitor
February 20, 2020

Hi,
i have the same problem, have you found a solution?

14-Alexandrite
February 21, 2020

Hello Burhanuddin, mvavassori,

 

You can achieve this behavior by using touch events such as touchend (http://www.javascriptkit.com/javatutors/touchevents.shtml)

document.body.addEventListener('touchend', function(e) {
	/* Move the model item */ 	
 }, false) 

In order to move the model item you can either:

1) start an (pre-defined) animation of the model in which the model item is being dragged outside the model

or

2) move the model item programmatically by changing the x,y,z coordinates accordingly to the desired result.

Next, just add in the Javascript box of each model item a function call that sets what animation needs to start (or what model item to move).

modelItemMove.PNG

 

 

Kind regards,

Lorena

1-Visitor
February 24, 2020

Hello Lorena

I have tried out the js which you have given, but i can't move the model item. Can you please send me a zip file on any model by applying this js.

 

 

 

Thank you,

Burhanuddin