@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
54 lines • 2.35 kB
JavaScript
import { FlowGraphEventBlock } from "../../flowGraphEventBlock.js";
import { RegisterClass } from "../../../Misc/typeStore.js";
import { _IsDescendantOf } from "../../utils.js";
import { RichTypeAny, RichTypeNumber } from "../../flowGraphRichTypes.js";
/**
* A pointer down event block.
* This block fires when a pointer is pressed (mouse button down / touch start).
* Optionally filters to a specific mesh via the `targetMesh` input.
*/
export class FlowGraphPointerDownEventBlock extends FlowGraphEventBlock {
/**
* Creates a new FlowGraphPointerDownEventBlock.
* @param config optional configuration
*/
constructor(config) {
super(config);
/** @internal */
this.type = "PointerDown" /* FlowGraphEventType.PointerDown */;
this.targetMesh = this.registerDataInput("targetMesh", RichTypeAny, config?.targetMesh);
this.pointerId = this.registerDataOutput("pointerId", RichTypeNumber);
this.pickedMesh = this.registerDataOutput("pickedMesh", RichTypeAny);
this.pickedPoint = this.registerDataOutput("pickedPoint", RichTypeAny);
}
/** @internal */
_executeEvent(context, pointerInfo) {
const mesh = this.targetMesh.getValue(context);
const pickedMesh = pointerInfo.pickInfo?.pickedMesh;
// If a target mesh is set, only fire when that mesh (or a descendant) is picked.
if (mesh && !(pickedMesh === mesh || (pickedMesh && _IsDescendantOf(pickedMesh, mesh)))) {
return true;
}
this.pointerId.setValue(pointerInfo.event.pointerId, context);
this.pickedMesh.setValue(pickedMesh ?? null, context);
this.pickedPoint.setValue(pointerInfo.pickInfo?.pickedPoint ?? null, context);
this._execute(context);
return !this.config?.stopPropagation;
}
/** @internal */
_preparePendingTasks(_context) {
// no-op
}
/** @internal */
_cancelPendingTasks(_context) {
// no-op
}
/**
* @returns the class name of the block.
*/
getClassName() {
return "FlowGraphPointerDownEventBlock" /* FlowGraphBlockNames.PointerDownEvent */;
}
}
RegisterClass("FlowGraphPointerDownEventBlock" /* FlowGraphBlockNames.PointerDownEvent */, FlowGraphPointerDownEventBlock);
//# sourceMappingURL=flowGraphPointerDownEventBlock.js.map