UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

47 lines (46 loc) 2.08 kB
"use strict"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { JsType } from "../../poly/registers/nodes/types/Js"; import { Poly } from "../../Poly"; import { inputObject3D, vector3OutputFromParam, 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 SetSoftBodyPositionJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param target position */ this.position = ParamConfig.VECTOR3([0, 0, 0]); /** @param lerp factor */ this.lerp = ParamConfig.FLOAT(1); } } const ParamsConfig = new SetSoftBodyPositionJsParamsConfig(); export class SetSoftBodyPositionJsNode extends BaseTriggerAndObjectJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return JsType.SET_SOFT_BODY_POSITION; } _additionalOutputs() { return [ new JsConnectionPoint("position", JsConnectionPointType.VECTOR3, CONNECTION_OPTIONS), new JsConnectionPoint("lerp", JsConnectionPointType.FLOAT, CONNECTION_OPTIONS) ]; } setLines(linesController) { super.setLines(linesController); vector3OutputFromParam(this, this.p.position, linesController); floatOutputFromParam(this, this.p.lerp, linesController); } setTriggerableLines(shadersCollectionController) { const object3D = inputObject3D(this, shadersCollectionController); const position = this.variableForInputParam(shadersCollectionController, this.p.position); const lerp = this.variableForInputParam(shadersCollectionController, this.p.lerp); const func = Poly.namedFunctionsRegister.getFunction("softBodySetPosition", this, shadersCollectionController); const bodyLine = func.asString(object3D, position, lerp); shadersCollectionController.addTriggerableLines(this, [bodyLine]); } }