UNPKG

@polygonjs/polygonjs

Version:

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

52 lines (51 loc) 2.42 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, booleanOutputFromParam } 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 SetObjectPositionJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param target position */ this.position = ParamConfig.VECTOR3([0, 0, 0]); /** @param lerp factor */ this.lerp = ParamConfig.FLOAT(1); /** @param sets if the matrix should be updated as the animation progresses */ this.updateMatrix = ParamConfig.BOOLEAN(1); } } const ParamsConfig = new SetObjectPositionJsParamsConfig(); export class SetObjectPositionJsNode extends BaseTriggerAndObjectJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return JsType.SET_OBJECT_POSITION; } _additionalOutputs() { return [ new JsConnectionPoint("position", JsConnectionPointType.VECTOR3, CONNECTION_OPTIONS), new JsConnectionPoint("lerp", JsConnectionPointType.FLOAT, CONNECTION_OPTIONS), new JsConnectionPoint("updateMatrix", JsConnectionPointType.BOOLEAN, CONNECTION_OPTIONS) ]; } setLines(linesController) { super.setLines(linesController); vector3OutputFromParam(this, this.p.position, linesController); floatOutputFromParam(this, this.p.lerp, linesController); booleanOutputFromParam(this, this.p.updateMatrix, linesController); } setTriggerableLines(linesController) { const object3D = inputObject3D(this, linesController); const position = this.variableForInputParam(linesController, this.p.position); const lerp = this.variableForInputParam(linesController, this.p.lerp); const updateMatrix = this.variableForInputParam(linesController, this.p.updateMatrix); const func = Poly.namedFunctionsRegister.getFunction("setObjectPosition", this, linesController); const bodyLine = func.asString(object3D, position, lerp, updateMatrix); linesController.addTriggerableLines(this, [bodyLine]); } }