UNPKG

@polygonjs/polygonjs

Version:

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

50 lines (49 loc) 2.17 kB
"use strict"; 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 } from "./_BaseObject3D"; import { Poly } from "../../Poly"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; class PhysicsRBDAddForceAtPointJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param force */ this.force = ParamConfig.VECTOR3([0, 0, 0]); /** @param point */ this.point = ParamConfig.VECTOR3([0, 0, 0]); } } const ParamsConfig = new PhysicsRBDAddForceAtPointJsParamsConfig(); export class PhysicsRBDAddForceAtPointJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "physicsRBDAddForceAtPoint"; } 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) ]); } setTriggerableLines(shadersCollectionController) { const object3D = inputObject3D(this, shadersCollectionController); const force = this.variableForInputParam(shadersCollectionController, this.p.force); const point = this.variableForInputParam(shadersCollectionController, this.p.point); const func = Poly.namedFunctionsRegister.getFunction( "physicsRBDAddForceAtPoint", this, shadersCollectionController ); const bodyLine = func.asString(object3D, force, point); shadersCollectionController.addTriggerableLines(this, [bodyLine]); } }