UNPKG

@polygonjs/polygonjs

Version:

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

53 lines (52 loc) 1.84 kB
"use strict"; import { TypedJsNode } from "./_Base"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js"; import { Euler } from "three"; import { Poly } from "../../Poly"; import { ROTATION_ORDERS, RotationOrder } from "../../../core/Transform"; class EulerJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param euler value */ this.Euler = ParamConfig.VECTOR3([0, 0, 0]); /** @param rotation order */ this.order = ParamConfig.INTEGER(ROTATION_ORDERS.indexOf(RotationOrder.XYZ), { menu: { entries: ROTATION_ORDERS.map((order, v) => { return { name: order, value: v }; }) } }); } } const ParamsConfig = new EulerJsParamsConfig(); export class EulerJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "euler"; } initializeNode() { super.initializeNode(); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.EULER, JsConnectionPointType.EULER) ]); } setLines(linesController) { const inputValue = this.variableForInputParam(linesController, this.p.Euler); const order = this.variableForInputParam(linesController, this.p.order); const varName = this.jsVarName(JsConnectionPointType.EULER); const tmpVarName = linesController.addVariable(this, new Euler()); const func = Poly.namedFunctionsRegister.getFunction("eulerSetFromVector3", this, linesController); linesController.addBodyOrComputed(this, [ { dataType: JsConnectionPointType.EULER, varName, value: func.asString(inputValue, order, tmpVarName) } ]); } }