@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
62 lines (61 loc) • 2.75 kB
JavaScript
"use strict";
import { TRIGGER_CONNECTION_NAME, TypedJsNode } from "./_Base";
import { inputObject3D, setObject3DOutputLine } from "./_BaseObject3D";
import { Poly } from "../../Poly";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class SoftBodySolverStepSimulationJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.stepsCount = ParamConfig.INTEGER(10, {
range: [1, 100],
rangeLocked: [true, false]
});
/** @param edgeCompliance */
this.edgeCompliance = ParamConfig.FLOAT(0, {
range: [0, 100],
rangeLocked: [true, false]
});
/** @param volumeCompliance */
this.volumeCompliance = ParamConfig.FLOAT(0, {
range: [0, 1],
rangeLocked: [true, false]
});
/** @param preciseCollisions */
this.preciseCollisions = ParamConfig.BOOLEAN(0);
}
}
const ParamsConfig = new SoftBodySolverStepSimulationJsParamsConfig();
export class SoftBodySolverStepSimulationJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "softBodySolverStepSimulation";
}
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)
]);
}
setLines(linesController) {
setObject3DOutputLine(this, linesController);
}
setTriggerableLines(linesController) {
const object3D = inputObject3D(this, linesController);
const stepsCount = this.variableForInputParam(linesController, this.p.stepsCount);
const edgeCompliance = this.variableForInputParam(linesController, this.p.edgeCompliance);
const volumeCompliance = this.variableForInputParam(linesController, this.p.volumeCompliance);
const preciseCollisions = this.variableForInputParam(linesController, this.p.preciseCollisions);
const func = Poly.namedFunctionsRegister.getFunction("softBodySolverStepSimulation", this, linesController);
const bodyLine = func.asString(object3D, stepsCount, edgeCompliance, volumeCompliance, preciseCollisions);
linesController.addTriggerableLines(this, [bodyLine]);
}
}