@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
62 lines (61 loc) • 2.2 kB
JavaScript
;
import { TRIGGER_CONNECTION_NAME, TypedJsNode } from "./_Base";
import { NodeParamsConfig } from "../utils/params/ParamsConfig";
import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js";
import { JsType } from "../../poly/registers/nodes/types/Js";
import { ComputedValueJsDefinition } from "./utils/JsDefinition";
import { Poly } from "../../Poly";
export var OnTickJsNodeOuput = /* @__PURE__ */ ((OnTickJsNodeOuput2) => {
OnTickJsNodeOuput2["TIME"] = "time";
OnTickJsNodeOuput2["DELTA"] = "delta";
return OnTickJsNodeOuput2;
})(OnTickJsNodeOuput || {});
class OnTickJsParamsConfig extends NodeParamsConfig {
}
const ParamsConfig = new OnTickJsParamsConfig();
export class OnTickJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return JsType.ON_TICK;
}
isTriggering() {
return true;
}
initializeNode() {
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER),
new JsConnectionPoint("time" /* TIME */, JsConnectionPointType.FLOAT),
new JsConnectionPoint("delta" /* DELTA */, JsConnectionPointType.FLOAT)
]);
}
setTriggeringLines(linesController, triggeredMethods) {
linesController.addTriggeringLines(this, [triggeredMethods], { gatherable: true });
}
setLines(linesController) {
const timeVarName = this.jsVarName("time" /* TIME */);
const deltaVarName = this.jsVarName("delta" /* DELTA */);
const _time = Poly.namedFunctionsRegister.getFunction("globalsTime", this, linesController);
const _delta = Poly.namedFunctionsRegister.getFunction("globalsTimeDelta", this, linesController);
linesController.addDefinitions(this, [
new ComputedValueJsDefinition(
this,
linesController,
JsConnectionPointType.FLOAT,
timeVarName,
_time.asString()
)
]);
linesController.addDefinitions(this, [
new ComputedValueJsDefinition(
this,
linesController,
JsConnectionPointType.FLOAT,
deltaVarName,
_delta.asString()
)
]);
}
}