pathogen Posted December 24, 2016 Share Posted December 24, 2016 When the pointer is locked the OnPick* Actions are very awkward because the cursor is hidden and thus accurate picking is not an option. It is possible to achieve accurate picking using the scene.onPointerObservable and any of the picking methods which allow for an X and Y coordinate to be supplied (I just use the screen center X and Y and a visible 'cross hair'). However it seems like this would be better to incorporate directly into the OnPick* Actions when optional X and Y arguments are supplied. Thoughts? Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted December 25, 2016 Share Posted December 25, 2016 babylon js is a framework which supports a wide range of different types of games, so some features, like game logic & behaivior, is left to the developer :), you could do something like this; var screenWidth = canvas.offsetWidth, screenHeight = canvas.offsetHeight; //on pointerDown or up //supply your own PointerLock variable(s) if(mouseLock) var pick = scene.pick(screenWidth / 2, screenHeight / 2); else var pick = scene.pick(scene.pointerX, scene.pointerY); if (pick.hit) { // ... } Quote Link to comment Share on other sites More sharing options...
pathogen Posted January 12, 2017 Author Share Posted January 12, 2017 Oh yes, this is exactly what I have been doing. I just noticed that it seems everything is moving towards using the Actions and when I attempted to move some of my code to the Actions I noticed this discrepancy. Upon checking the Babylon source on Github I am reasonably sure that no matter which type of picking, they all eventually use the same function, and that function does have x and y parameters. Quote Link to comment Share on other sites More sharing options...
pathogen Posted January 13, 2017 Author Share Posted January 13, 2017 @Deltakosh perhaps? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 13, 2017 Share Posted January 13, 2017 I think this is a good idea. Fancy adding the test code there with a PR? https://github.com/BabylonJS/Babylon.js/blob/master/src/babylon.scene.ts#L898 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.