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: Modify Picking to only happen with necessary scenarios #13145

Merged
merged 11 commits into from
Nov 10, 2022
Prev Previous commit
Next Next commit
Some PR Feedback
  • Loading branch information
PolygonalSun committed Oct 31, 2022
commit a668064a04f25aa30e61be812d53d196bb34ea65
8 changes: 4 additions & 4 deletions packages/dev/core/src/Inputs/scene.inputManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class InputManager {

if (scene.onPointerMove) {
// Because of lazy picking, we need to force a pick to update the pickResult
pickResult = pickResult ? pickResult : this._pick(evt.pointerId, type);
pickResult = pickResult || this._pick(evt.pointerId, type);
scene.onPointerMove(evt, pickResult, type);
}

Expand Down Expand Up @@ -279,7 +279,7 @@ export class InputManager {
case PointerEventTypes.POINTERDOWN:
pickResult = scene.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, scene.pointerDownPredicate, false, scene.cameraToUseForPointers);
if (pickResult?.pickedMesh) {
this._pickedDownMesh = pickResult?.pickedMesh;
this._pickedDownMesh = pickResult.pickedMesh;
}
break;
case PointerEventTypes.POINTERMOVE:
Expand All @@ -296,6 +296,7 @@ export class InputManager {
break;
default:
pickResult = new PickingInfo();
break;
}

return pickResult;
Expand Down Expand Up @@ -410,8 +411,7 @@ export class InputManager {
const type = PointerEventTypes.POINTERDOWN;

if (scene.onPointerDown) {
pickResult = pickResult ? pickResult : this._pick(evt.pointerId, type);
// We know that _pick will return a PickingInfo because _internalPick always returns a PickingInfo
pickResult = pickResult || this._pick(evt.pointerId, type);
scene.onPointerDown(evt, pickResult, type);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/dev/core/src/scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,11 +775,11 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
public skipPointerUpPicking = false;

/** Callback called when a pointer move is detected */
public onPointerMove: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
public onPointerMove?: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
/** Callback called when a pointer down is detected */
public onPointerDown: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
public onPointerDown?: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
/** Callback called when a pointer up is detected */
public onPointerUp: (evt: IPointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
public onPointerUp?: (evt: IPointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
/** Callback called when a pointer pick is detected */
public onPointerPick?: (evt: IPointerEvent, pickInfo: PickingInfo) => void;

Expand Down