@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
44 lines (43 loc) • 1.72 kB
JavaScript
;
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { JsType } from "../../poly/registers/nodes/types/Js";
import { Poly } from "../../Poly";
import { inputObject3D, floatOutputFromParam } from "./_BaseObject3D";
import { BaseTriggerAndObjectJsNode } from "./_BaseTriggerAndObject";
import { JS_CONNECTION_POINT_IN_NODE_DEF, JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class SetSoftBodyVelocityJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param multiplier */
this.mult = ParamConfig.FLOAT(1);
}
}
const ParamsConfig = new SetSoftBodyVelocityJsParamsConfig();
export class SetSoftBodyVelocityJsNode extends BaseTriggerAndObjectJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return JsType.SET_SOFT_BODY_VELOCITY;
}
_additionalOutputs() {
return [new JsConnectionPoint("mult", JsConnectionPointType.FLOAT, CONNECTION_OPTIONS)];
}
setLines(linesController) {
super.setLines(linesController);
floatOutputFromParam(this, this.p.mult, linesController);
}
setTriggerableLines(shadersCollectionController) {
const object3D = inputObject3D(this, shadersCollectionController);
const mult = this.variableForInputParam(shadersCollectionController, this.p.mult);
const func = Poly.namedFunctionsRegister.getFunction(
"softBodyMultiplyVelocity",
this,
shadersCollectionController
);
const bodyLine = func.asString(object3D, mult);
shadersCollectionController.addTriggerableLines(this, [bodyLine]);
}
}