BlackMojito Posted November 29, 2017 Share Posted November 29, 2017 Hi Guys, I am doing selection by adding a pointer observer like below. But there is one thing that this can not work which is clearing the selection(s) when clicking on the "empty" place. I know that I can add an observer with POINTERDOWN(or POINTERUP), but what I wish is when I rotate the camera by left click + dragging, the "selection event" will not be triggered. Only when I click at the empty place without rotating the camera, the selection will be cleared. How can I do this though? addPickingObserver(observer: (eventData: BABYLON.PointerInfo, eventState: BABYLON.EventState) => void): void { this._scene.onPointerObservable.add(observer, BABYLON.PointerEventTypes.POINTERPICK); } private createDefaultPicker(): void { let observer = (eventData: BABYLON.PointerInfo, eventState: BABYLON.EventState) => { this._selector.clearSelections(); if (eventData.pickInfo.hit) { let renderModel = this._renderScene.getRenderModel(eventData.pickInfo.pickedMesh); let selection = new Selection(new PickingInfoEx(eventData.pickInfo, renderModel)); this._selector.addSelection(selection); } } this._renderScene.addPickingObserver(observer); } Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 29, 2017 Share Posted November 29, 2017 You can use the action mananger with OnPickDownTrigger for this: https://doc.babylonjs.com/how_to/how_to_use_actions Quote Link to comment Share on other sites More sharing options...
BlackMojito Posted November 30, 2017 Author Share Posted November 30, 2017 7 hours ago, Sebavan said: You can use the action mananger with OnPickDownTrigger for this: https://doc.babylonjs.com/how_to/how_to_use_actions But this cannot be triggered when I click on the "background" right? There is not mesh actually picked... Quote Link to comment Share on other sites More sharing options...
BlackMojito Posted November 30, 2017 Author Share Posted November 30, 2017 Is it possible to add something like BABYLON.PointerEventTypes.POINTPICKMISS ? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 30, 2017 Share Posted November 30, 2017 Won t help here as we still pick on move: you can easily do like here: https://www.babylonjs-playground.com/#IEQ92B var ok = true; scene.onPointerObservable.add(function() { ok = true; }, BABYLON.PointerEventTypes.POINTERDOWN); scene.onPointerObservable.add(function() { ok = false; }, BABYLON.PointerEventTypes.POINTERMOVE); scene.onPointerObservable.add(function() { if (ok) { alert(); } }, BABYLON.PointerEventTypes.POINTERUP); Quote Link to comment Share on other sites More sharing options...
brianzinn Posted November 30, 2017 Share Posted November 30, 2017 3 hours ago, BlackMojito said: like BABYLON.PointerEventTypes.POINTPICKMISS Isn't that the same as !if (eventData.pickInfo.hit), so just adding an else to your if statement? ie: eventData.pickInfo.hit == false. adam 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 30, 2017 Share Posted November 30, 2017 Isn't it enough to check for pointerInfo.hit on te PointerDown event? if there is a hit, something was selected, if not then no? You can set pickable meshes and non-pickable meshes, or use a different form of filtering. Or, maybe I didn't understand the problem adam 1 Quote Link to comment Share on other sites More sharing options...
adam Posted November 30, 2017 Share Posted November 30, 2017 http://playground.babylonjs.com/#XZS5CB jerome 1 Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted November 30, 2017 Share Posted November 30, 2017 Hi @BlackMojito If i understood correctly, believe you're in need of a pointer cache. This will allow you to pick with single clicks (including failed picks) and ignore picking on panning, etc, clickSensibility controls how much the pointer is allowed to move while still considdering it a picking click. http://playground.babylonjs.com/#XZS5CB#4 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.