Vousk-prod. Posted July 8, 2014 Share Posted July 8, 2014 Hi, In babylon.scene.js file we can seeScene.prototype.pick = function (x, y, predicate, fastCheck, camera) { var _this = this; /// <summary>Launch a ray to try to pick a mesh in the scene</summary> /// <param name="x">X position on screen</param> /// <param name="y">Y position on screen</param> /// <param name="predicate">Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true</param> /// <param name="fastCheck">Launch a fast check only using the bounding boxes. Can be set to null.</param> /// <param name="camera">camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used</param> return this._internalPick(function (world) { return _this.createPickingRay(x, y, world, camera); }, predicate, fastCheck); };"a mesh must be enabled, visible and with isPickable set to true" But sometimes we need to be able to pick a mesh even if it is invisible (as long as it is enabled - and pickable, of course -). Yes I know, it seems strange at first, but in some cases meshes could be used as invisible handlers / dummies, to trigger things, to move parenting objects, etc. Could it be possible to change these conditions to only check enabled and pickable params before determining if it is actually picked or not ?Then it's up to the dev who use bjs framework to decide if the pick info is relevant or not, and thus to deactive the object or to make it not pickable if needed... Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 8, 2014 Share Posted July 8, 2014 This is why you can use a predicate var predicate = function(mesh) { return mesh.isPickable && mesh.isEnabled()} Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted July 8, 2014 Author Share Posted July 8, 2014 Aaaaah... Now I understand what this predicate param is for.What a smart piece of code ! GameMonetize 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.