@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.
63 lines • 2.47 kB
JavaScript
import { FlowGraphConnection } from "./flowGraphConnection.js";
import { RegisterClass } from "../Misc/typeStore.js";
/**
* Represents a connection point for a signal.
* When an output point is activated, it will activate the connected input point.
* When an input point is activated, it will execute the block it belongs to.
*/
export class FlowGraphSignalConnection extends FlowGraphConnection {
constructor() {
super(...arguments);
/**
* The priority of the signal. Signals with higher priority will be executed first.
* Set priority before adding the connection as sorting happens only when the connection is added.
*/
this.priority = 0;
/**
* Timestamp of the last activation (set on output signals when they fire).
* @internal
*/
this._lastActivationTime = -1;
}
_isSingularConnection() {
return false;
}
connectTo(point) {
super.connectTo(point);
// sort according to priority to handle execution order
this._connectedPoint.sort((a, b) => b.priority - a.priority);
}
/**
* @internal
*/
_activateSignal(context) {
this._lastActivationTime = performance.now();
context.logger?.addLogItem({
action: "ActivateSignal" /* FlowGraphAction.ActivateSignal */,
className: this._ownerBlock.getClassName(),
uniqueId: this._ownerBlock.uniqueId,
payload: {
connectionType: this.connectionType,
name: this.name,
},
});
if (this.connectionType === 0 /* FlowGraphConnectionType.Input */) {
// Check breakpoint before executing
if (context._shouldBreak(this._ownerBlock, this)) {
return; // Execution paused — stored as pending activation
}
context._notifyExecuteNode(this._ownerBlock);
const startTime = performance.now();
this._ownerBlock._execute(context, this);
this._ownerBlock._lastExecutionTime = performance.now() - startTime;
context._increaseExecutionId();
}
else {
for (const connectedPoint of this._connectedPoint) {
connectedPoint._activateSignal(context);
}
}
}
}
RegisterClass("FlowGraphSignalConnection", FlowGraphSignalConnection);
//# sourceMappingURL=flowGraphSignalConnection.js.map