ozRocker Posted July 16, 2015 Share Posted July 16, 2015 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? Quote Link to comment Share on other sites More sharing options...
Temechon Posted July 16, 2015 Share Posted July 16, 2015 There is ActionManager.OnPickUpTrigger that exists if you need it. Quote Link to comment Share on other sites More sharing options...
ozRocker Posted July 17, 2015 Author Share Posted July 17, 2015 That's perfect! I checked all the doco and didn't see any mention of that trigger. Quote Link to comment Share on other sites More sharing options...
ozRocker Posted July 17, 2015 Author Share Posted July 17, 2015 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"; }); Temechon 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.