jschwuch Posted February 22, 2017 Share Posted February 22, 2017 I just found out that picking with fastcheck set to true doesn't work as expected. It won't give you the closest mesh but the one added to the scene first! The problem is inside _internalPick function. I added a comment where it literally breaks the search for the closest hit. private _internalPick(rayFunction: (world: Matrix) => Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): PickingInfo { var pickingInfo = null; for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) { var mesh = this.meshes[meshIndex]; if (predicate) { if (!predicate(mesh)) { continue; } } else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) { continue; } var world = mesh.getWorldMatrix(); var ray = rayFunction(world); var result = mesh.intersects(ray, fastCheck); if (!result || !result.hit) continue; if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) continue; pickingInfo = result; // This breaks the search for the closest hit when anything is hit. if (fastCheck) { break; } } Or is this actually intended @Deltakosh? Quote Link to comment Share on other sites More sharing options...
Temechon Posted February 22, 2017 Share Posted February 22, 2017 Hi, fastcheck is supposed to return the first result encountered, so i guess it works as announced Quote Link to comment Share on other sites More sharing options...
jschwuch Posted February 22, 2017 Author Share Posted February 22, 2017 @Temechon ok, if that's what it should do than that's ok, thought I read somewhere that it should use bounding boxes instead of actual meshs when using fastcheck but nothing about it returning the first mesh. Maybe I should file a feature request for a check against only the bounding box but with filtering the closest mesh then, as this is what I'd like to have. Quote Link to comment Share on other sites More sharing options...
Temechon Posted February 22, 2017 Share Posted February 22, 2017 Is it me you're looking for ? ♫ Pryme8 1 Quote Link to comment Share on other sites More sharing options...
jschwuch Posted February 22, 2017 Author Share Posted February 22, 2017 @Temechon sry the board trolled me, I wanted to select you by hitting return, that posted an almost empty message only containing your name 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.