UNPKG

@polygonjs/polygonjs

Version:

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

43 lines (42 loc) 1.48 kB
"use strict"; import { TypedJsNode } from "./_Base"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js"; import { Poly } from "../../Poly"; import { Matrix4 } from "three"; class Matrix4MakeTranslationJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param t */ this.t = ParamConfig.VECTOR3([0, 0, 0]); } } const ParamsConfig = new Matrix4MakeTranslationJsParamsConfig(); export class Matrix4MakeTranslationJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "matrix4MakeTranslation"; } initializeNode() { super.initializeNode(); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.MATRIX4, JsConnectionPointType.MATRIX4) ]); } setLines(linesController) { const t = this.variableForInputParam(linesController, this.p.t); const varName = this.jsVarName(JsConnectionPointType.MATRIX4); const tmpVarName = linesController.addVariable(this, new Matrix4()); const func = Poly.namedFunctionsRegister.getFunction("matrix4MakeTranslation", this, linesController); linesController.addBodyOrComputed(this, [ { dataType: JsConnectionPointType.MATRIX4, varName, value: func.asString(t, tmpVarName) } ]); } }