e.g
mesh.actionManager = new BABYLON.ActionManager(scene)
mesh.actionManager.registerAction(
new BABYLON.ExecuteCodeAction(
{
trigger: BABYLON.ActionManager.OnLongPressTrigger,
},
()=>{}
)
)
It runs well on most touchscreen devices , but a small number of devices cannot be triggered.
I wanted to know how this is monitored, so I found some source code
private _processPointerDown(pickResult: Nullable<PickingInfo>, evt: IPointerEvent): void {
const scene = this._scene;
if (pickResult?.pickedMesh) {
this._pickedDownMesh = pickResult.pickedMesh;
const actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
if (actionManager) {
......
if (actionManager.hasSpecificTrigger(Constants.ACTION_OnLongPressTrigger)) {
window.setTimeout(() => {
const pickResult = scene.pick(
this._unTranslatedPointerX,
this._unTranslatedPointerY,
(mesh: AbstractMesh): boolean =>
<boolean>(
(mesh.isPickable &&
mesh.isVisible &&
mesh.isReady() &&
mesh.actionManager &&
mesh.actionManager.hasSpecificTrigger(Constants.ACTION_OnLongPressTrigger) &&
mesh === this._pickedDownMesh)
),
false,
scene.cameraToUseForPointers
);
if (pickResult?.pickedMesh && actionManager) {
if (this._totalPointersPressed !== 0 && Date.now() - this._startingPointerTime > InputManager.LongPressDelay && !this._isPointerSwiping()) {
this._startingPointerTime = 0;
actionManager.processTrigger(Constants.ACTION_OnLongPressTrigger, ActionEvent.CreateNew(pickResult.pickedMesh, evt));
}
}
}, InputManager.LongPressDelay);
}
}
}
......
}
So I thought it was using pointerDown to monitor long-press behavior
And then I test on the ipad
As you can see from the video, the pointerDown event never fired when I clicked on the screen.
Events fired when clicked on the screen | |
---|---|
most touchscreen devices | pointerMoveăpointerTapăpointerUp |
small number of devices | pointerMoveăpointerTapăpointerUp |
So,two questions:
When i use actionManager,whitch event is used for test longPressďźpointerDown or Otherďź
Why do both devices trigger the same event when touched, but only one of them triggers ActionManagerâs longpress
thanks !