Jump to content
Search Community

Three.js object draggable

xleooow test
Moderator Tag

Go to solution Solved by OSUblake,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello,

 

A few weeks ago I started with GSAP and now I also learned some basic skills in Three.js

I have made a object and I am able to rotate it with GSAP, but I would like to make it draggable with the mouse. Can anyone help me making this happen?

When I create a drag for the mesh ( the object). The object dissapears. 

This is my Codepen:


Any help is appreciated.

 

See the Pen YGvjNA by xleooow (@xleooow) on CodePen

Link to comment
Share on other sites

  • Solution

Draggable is only for DOM elements, but you can create a dummy element to use as the target, and then update those changes to your mesh.

 

The coordinate space doesn't seem to match up that well, so I'm scaling the values down. And the x and y axes seem crossed, so I'm setting them opposite, dragY => meshX, dragX => meshY.

See the Pen kkAGpv?editors=0010 by osublake (@osublake) on CodePen

 

.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...