UNPKG

@polygonjs/polygonjs

Version:

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

46 lines (45 loc) 1.67 kB
"use strict"; import { TypedJsNode } from "./_Base"; import { NodeParamsConfig } from "../utils/params/ParamsConfig"; import { JS_CONNECTION_POINT_IN_NODE_DEF, JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js"; import { Euler } from "three"; import { Poly } from "../../Poly"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; class EulerFromQuaternionJsParamsConfig extends NodeParamsConfig { } const ParamsConfig = new EulerFromQuaternionJsParamsConfig(); export class EulerFromQuaternionJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "eulerFromQuaternion"; } initializeNode() { super.initializeNode(); this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint( JsConnectionPointType.QUATERNION, JsConnectionPointType.QUATERNION, CONNECTION_OPTIONS ) ]); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.EULER, JsConnectionPointType.EULER) ]); } setLines(linesController) { const quaternion = this.variableForInput(linesController, JsConnectionPointType.QUATERNION); const varName = this.jsVarName(JsConnectionPointType.EULER); const tmpVarName = linesController.addVariable(this, new Euler()); const func = Poly.namedFunctionsRegister.getFunction("eulerSetFromQuaternion", this, linesController); linesController.addBodyOrComputed(this, [ { dataType: JsConnectionPointType.EULER, varName, value: func.asString(quaternion, tmpVarName) } ]); } }