UNPKG

@polygonjs/polygonjs

Version:

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

42 lines (41 loc) 1.53 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"; const OUTPUT_NAME = "radians"; class Vector3AngleToJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param vector 1 */ this.v1 = ParamConfig.VECTOR3([0, 0, 0]); /** @param vector 2 */ this.v2 = ParamConfig.VECTOR3([0, 0, 0]); } } const ParamsConfig = new Vector3AngleToJsParamsConfig(); export class Vector3AngleToJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "vector3AngleTo"; } initializeNode() { super.initializeNode(); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(OUTPUT_NAME, JsConnectionPointType.FLOAT) ]); } setLines(shadersCollectionController) { const v1 = this.variableForInputParam(shadersCollectionController, this.p.v1); const v2 = this.variableForInputParam(shadersCollectionController, this.p.v2); const out = this.jsVarName(OUTPUT_NAME); const func = Poly.namedFunctionsRegister.getFunction("vector3AngleTo", this, shadersCollectionController); const bodyLine = func.asString(v1, v2); shadersCollectionController.addBodyOrComputed(this, [ { dataType: JsConnectionPointType.SPHERE, varName: out, value: bodyLine } ]); } }