@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
59 lines (58 loc) • 2.69 kB
JavaScript
;
import { ParamConfig } from "../utils/params/ParamsConfig";
import { TRIGGER_CONNECTION_NAME, TypedJsNode } from "./_Base";
import { NodeParamsConfig } from "../utils/params/ParamsConfig";
import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js";
import { inputObject3D, setObject3DOutputLine } from "./_BaseObject3D";
import { Poly } from "../../Poly";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class SetPhysicsRBDCuboidPropertyJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param target sizes */
this.sizes = ParamConfig.VECTOR3([1, 1, 1]);
/** @param target size */
this.size = ParamConfig.FLOAT(1);
/** @param lerp factor */
this.lerp = ParamConfig.FLOAT(1);
/** @param sets if the matrix should be updated as the animation progresses */
this.updateMatrix = ParamConfig.BOOLEAN(1);
}
}
const ParamsConfig = new SetPhysicsRBDCuboidPropertyJsParamsConfig();
export class SetPhysicsRBDCuboidPropertyJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "setPhysicsRBDCuboidProperty";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER, CONNECTION_OPTIONS),
new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS)
]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER),
new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS)
]);
}
setLines(linesController) {
setObject3DOutputLine(this, linesController);
}
setTriggerableLines(shadersCollectionController) {
const object3D = inputObject3D(this, shadersCollectionController);
const sizes = this.variableForInputParam(shadersCollectionController, this.p.sizes);
const size = this.variableForInputParam(shadersCollectionController, this.p.size);
const lerp = this.variableForInputParam(shadersCollectionController, this.p.lerp);
const updateMatrix = this.variableForInputParam(shadersCollectionController, this.p.updateMatrix);
const func = Poly.namedFunctionsRegister.getFunction(
"setPhysicsRBDCuboidProperty",
this,
shadersCollectionController
);
const bodyLine = func.asString(object3D, sizes, size, lerp, updateMatrix);
shadersCollectionController.addTriggerableLines(this, [bodyLine]);
}
}