Skip to content

Commit

Permalink
Merge pull request #14789 from f-rooom/master
Browse files Browse the repository at this point in the history
Add triangle predicates to pointer down and up events.
  • Loading branch information
sebavan committed Feb 20, 2024
2 parents 1f6d488 + 8495d45 commit 1146e16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/dev/core/src/Inputs/scene.inputManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,14 @@ export class InputManager {
const pickResult =
scene.skipPointerUpPicking || (scene._registeredActions === 0 && !this._checkForPicking() && !scene.onPointerUp)
? null
: scene.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, scene.pointerUpPredicate, scene.pointerUpFastCheck, scene.cameraToUseForPointers);
: scene.pick(
this._unTranslatedPointerX,
this._unTranslatedPointerY,
scene.pointerUpPredicate,
scene.pointerUpFastCheck,
scene.cameraToUseForPointers,
scene.pointerUpTrianglePredicate
);
this._currentPickResult = pickResult;
if (pickResult) {
act = pickResult.hit && pickResult.pickedMesh ? pickResult.pickedMesh._getActionManagerForTrigger() : null;
Expand Down Expand Up @@ -881,7 +888,8 @@ export class InputManager {
this._unTranslatedPointerY,
scene.pointerDownPredicate,
scene.pointerDownFastCheck,
scene.cameraToUseForPointers
scene.cameraToUseForPointers,
scene.pointerDownTrianglePredicate
);
}

Expand Down
10 changes: 10 additions & 0 deletions packages/dev/core/src/scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,16 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
*/
public pointerMoveTrianglePredicate: ((p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean) | undefined;

/**
* Gets or sets a predicate used to select candidate faces for a pointer down event
*/
public pointerDownTrianglePredicate: ((p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean) | undefined;

/**
* Gets or sets a predicate used to select candidate faces for a pointer up event
*/
public pointerUpTrianglePredicate: ((p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean) | undefined;

/**
* This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
* You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
Expand Down

0 comments on commit 1146e16

Please sign in to comment.