Jump to content

is there a trigger that detects mouse / touch up?


ozRocker
 Share

Recommended Posts

I know of onPickTrigger and the other pick triggers that detect when mouse / touch is down.  I'm treating objects like URL links so I'd like them to work like web links, which get activated on touch up.   So my plan is to detect if the user has touched down, not moved much, then released.  Basically comparing distance between touch down and touch up.  If they moved a lot I'd like to consider it a swipe or accidental touch, otherwise proceed to the link.  Is this possible to do?

Link to comment
Share on other sites

Here's some code if someone wants to do the same thing as me which is basically treat objects like links.  Basically it will call an action only if the user has mouse down followed by mouse up on the same object.  This will help to prevent accidental clicking on objects.

 

I added a method to the Scene class here:

BABYLON.Scene.prototype.addTarget = function(meshName, actionFunc) {    var mesh = this.getMeshByName(meshName);    mesh.actionManager = new BABYLON.ActionManager(this);    mesh.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, function(evt) {        //Action for touch down        window.targetTouched = meshName;    }));    mesh.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickUpTrigger, function(evt) {        //Action for touch up        if (window.targetTouched == meshName) {            actionFunc();        }    }));}

and then you can use it like this:

        newScene.addTarget("FB",function() {            document.location = "http://facebook.com/punkoffice3d";        });        newScene.addTarget("YouTube",function() {            document.location = "http://youtube.com/PunkOffice1/videos";        });        newScene.addTarget("Sketchfab",function() {            document.location = "http://sketchfab.com/punkoffice/models";        });
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...