UNPKG

@polygonjs/polygonjs

Version:

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

66 lines (65 loc) 2.75 kB
"use strict"; import { BaseTriggerAndObjectJsNode } from "./_BaseTriggerAndObject"; import { inputObject3D } from "./_BaseObject3D"; import { Poly } from "../../Poly"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js"; import { RefJsDefinition } from "./utils/JsDefinition"; var CreatePhysicsRBDKinematicConstraintJsNodeOutput = /* @__PURE__ */ ((CreatePhysicsRBDKinematicConstraintJsNodeOutput2) => { CreatePhysicsRBDKinematicConstraintJsNodeOutput2["RBD_ID"] = "rbdId"; return CreatePhysicsRBDKinematicConstraintJsNodeOutput2; })(CreatePhysicsRBDKinematicConstraintJsNodeOutput || {}); class CreatePhysicsRBDKinematicConstraintJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); this.anchor = ParamConfig.VECTOR3([0, 0, 0]); } } const ParamsConfig = new CreatePhysicsRBDKinematicConstraintJsParamsConfig(); export class CreatePhysicsRBDKinematicConstraintJsNode extends BaseTriggerAndObjectJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "createPhysicsRBDKinematicConstraint"; } _additionalOutputs() { return [ new JsConnectionPoint("rbdId" /* RBD_ID */, JsConnectionPointType.STRING) ]; } setLines(linesController) { const usedOutputNames = this.io.outputs.used_output_names(); if (usedOutputNames.includes("rbdId" /* RBD_ID */)) { const outRBDIds = this._addRBDIdRef(linesController); const out = this.jsVarName("rbdId" /* RBD_ID */); linesController.addBodyOrComputed(this, [ { dataType: JsConnectionPointType.OBJECT_3D, varName: out, value: `this.${outRBDIds}.value` } ]); if (!usedOutputNames.includes(JsConnectionPointType.TRIGGER)) { this.setTriggeringLines(linesController, ""); } } } setTriggerableLines(linesController) { const object3D = inputObject3D(this, linesController); const anchor = this.variableForInputParam(linesController, this.p.anchor); const rbdId = this._addRBDIdRef(linesController); const func = Poly.namedFunctionsRegister.getFunction( "createPhysicsRBDKinematicConstraint", this, linesController ); const bodyLine = func.asString(object3D, anchor, `this.${rbdId}`); linesController.addTriggerableLines(this, [bodyLine]); } _addRBDIdRef(linesController) { const outRBDIds = this.jsVarName("rbdId" /* RBD_ID */); linesController.addDefinitions(this, [ // do not use a ref, as it makes the object reactive new RefJsDefinition(this, linesController, JsConnectionPointType.STRING, outRBDIds, `''`) ]); return outRBDIds; } }