@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
83 lines (82 loc) • 3.78 kB
JavaScript
"use strict";
import { TRIGGER_CONNECTION_NAME, TypedJsNode } from "./_Base";
import { inputObject3DMaterial } 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";
import { ClothSolverUniformName } from "../../../core/cloth/ClothAttribute";
import { ClothSolverStepSimulationOutput } from "./ClothSolverStepSimulation";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class ClothSolverUpdateMaterialJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.tSizeName = ParamConfig.STRING(ClothSolverUniformName.SIZE);
this.tPosition0Name = ParamConfig.STRING(ClothSolverUniformName.POSITION0);
this.tPosition1Name = ParamConfig.STRING(ClothSolverUniformName.POSITION1);
this.tNormalName = ParamConfig.STRING(ClothSolverUniformName.NORMAL);
}
}
const ParamsConfig = new ClothSolverUpdateMaterialJsParamsConfig();
export class ClothSolverUpdateMaterialJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "clothSolverUpdateMaterial";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER, CONNECTION_OPTIONS),
new JsConnectionPoint(JsConnectionPointType.MATERIAL, JsConnectionPointType.MATERIAL, CONNECTION_OPTIONS),
new JsConnectionPoint(
ClothSolverStepSimulationOutput.TEXTURE_SIZE,
JsConnectionPointType.VECTOR2,
CONNECTION_OPTIONS
),
new JsConnectionPoint(
ClothSolverStepSimulationOutput.TEXTURE_POSITION0,
JsConnectionPointType.TEXTURE,
CONNECTION_OPTIONS
),
new JsConnectionPoint(
ClothSolverStepSimulationOutput.TEXTURE_POSITION1,
JsConnectionPointType.TEXTURE,
CONNECTION_OPTIONS
),
new JsConnectionPoint(
ClothSolverStepSimulationOutput.TEXTURE_NORMAL,
JsConnectionPointType.TEXTURE,
CONNECTION_OPTIONS
)
]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER),
new JsConnectionPoint(JsConnectionPointType.MATERIAL, JsConnectionPointType.MATERIAL, CONNECTION_OPTIONS)
]);
}
setTriggerableLines(linesController) {
const material = inputObject3DMaterial(this, linesController);
const tSizeName = this.variableForInputParam(linesController, this.p.tSizeName);
const tPosition0Name = this.variableForInputParam(linesController, this.p.tPosition0Name);
const tPosition1Name = this.variableForInputParam(linesController, this.p.tPosition1Name);
const tNormalName = this.variableForInputParam(linesController, this.p.tNormalName);
const tSize = this.variableForInput(linesController, ClothSolverStepSimulationOutput.TEXTURE_SIZE);
const tPosition0 = this.variableForInput(linesController, ClothSolverStepSimulationOutput.TEXTURE_POSITION0);
const tPosition1 = this.variableForInput(linesController, ClothSolverStepSimulationOutput.TEXTURE_POSITION1);
const tNormal = this.variableForInput(linesController, ClothSolverStepSimulationOutput.TEXTURE_NORMAL);
const func = Poly.namedFunctionsRegister.getFunction("clothSolverUpdateMaterial", this, linesController);
const bodyLine = func.asString(
material,
tSizeName,
tPosition0Name,
tPosition1Name,
tNormalName,
tSize,
tPosition0,
tPosition1,
tNormal
);
linesController.addTriggerableLines(this, [bodyLine]);
}
}