Jump to content

Combine OnPointerOverTrigger with Drag n drop


hit2501
 Share

Recommended Posts

Uhm.. just use both code snippets? :P How did you implement drag and drop?

 

http://www.babylonjs-playground.com/#GOCIX (hover over donut, then drag donut)

 

Edit: after re-reading your question I think I misunderstood what you meant. So not sure what you mean. Can you show the problem in a playground? I cant really imagine what's not working.

Link to comment
Share on other sites

Thanks for your replies, this is the code I´m using to drag and drop an html image over a mesh to change the texture (and other actions):

var file = document.getElementById('file');var startdrag = function(evt){    evt.dataTransfer.setData("text/plain", evt.target.src);}file.addEventListener('dragstart', startdrag, false);                    var canvas = document.getElementById('renderCanvas');var dragover = function(evt){    evt.preventDefault();}var drop = function(evt){    evt.preventDefault();    var src = evt.dataTransfer.getData("text/plain");    var pickResult = scene.pick(evt.offsetX, evt.offsetY);    var ImageNameIndex = src.lastIndexOf("/") + 1;    var Imagename = src.substr(ImageNameIndex);    console.log(evt.offsetX, evt.offsetY, pickResult);    if(pickResult.hit){        //HERE SOME CODE TO CHANGE TEXTURE OR OTHER STUFF...               }    canvas.addEventListener('dragover', dragover, false);    canvas.addEventListener('drop', drop, false);})

What I need is when I drag the html image over the mesh, the mesh must be highlighted (any emissiveColor) before I drop the image over the mesh to change the texture. 

 

once more thank you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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