Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputManager: Fix Picking on PointerUp and add bool to skip pointerup picking #12524

Merged
merged 9 commits into from
May 27, 2022
9 changes: 6 additions & 3 deletions packages/dev/core/src/Inputs/scene.inputManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export class InputManager {

private _processPointerUp(pickResult: Nullable<PickingInfo>, evt: IPointerEvent, clickInfo: _ClickInfo): void {
const scene = this._scene;
if (pickResult && pickResult && pickResult.pickedMesh) {
if (pickResult && pickResult.hit && pickResult.pickedMesh) {
this._pickedUpMesh = pickResult.pickedMesh;
if (this._pickedDownMesh === this._pickedUpMesh) {
if (scene.onPointerPick) {
Expand Down Expand Up @@ -463,7 +463,6 @@ export class InputManager {

if (!clickInfo.ignore) {
type = PointerEventTypes.POINTERUP;

const pi = new PointerInfo(type, evt, pickResult);
this._setRayOnPointerInfo(pi);
scene.onPointerObservable.notifyObservers(pi, type);
Expand Down Expand Up @@ -824,8 +823,12 @@ export class InputManager {
if (!this._meshPickProceed && ((AbstractActionManager && AbstractActionManager.HasTriggers) || scene.onPointerObservable.hasObservers())) {
this._initActionManager(null, clickInfo);
}
if (!pickResult) {

if (scene.skipPointerUpPicking) {
sebavan marked this conversation as resolved.
Show resolved Hide resolved
pickResult = this._currentPickResult;
} else {
pickResult = scene.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, scene.pointerUpPredicate, false, scene.cameraToUseForPointers);
bghgary marked this conversation as resolved.
Show resolved Hide resolved
this._currentPickResult = pickResult;
}

this._processPointerUp(pickResult, evt, clickInfo);
Expand Down
6 changes: 6 additions & 0 deletions packages/dev/core/src/scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
* Gets or sets a predicate used to select candidate meshes for a pointer up event
*/
public pointerUpPredicate: (Mesh: AbstractMesh) => boolean;

/**
* Gets or sets a predicate used to select candidate meshes for a pointer move event
*/
Expand All @@ -712,6 +713,11 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
*/
public skipPointerDownPicking = false;

/**
* Gets or sets a boolean indicating if the user want to entirely skip the picking phase when a pointer up event occurs. Off by default.
*/
public skipPointerUpPicking = true;

/** Callback called when a pointer move is detected */
public onPointerMove: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
/** Callback called when a pointer down is detected */
Expand Down