Skip to main content
Feb 13, 2020 7:32 AM UTC
Question

How to drag model item with JS in an experience?

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

11 replies

Feb 17, 2020 1:57 PM UTC

Hello  Burhanuddin,

 

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

Thank you.

 

Kind regards,

Lorena Gherman

Feb 18, 2020 4:46 AM UTC

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

Feb 20, 2020 4:35 PM UTC

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

Feb 21, 2020 2:52 PM UTC

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

Feb 24, 2020 5:34 AM UTC

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