UNPKG

@polygonjs/polygonjs

Version:

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

62 lines (61 loc) 2.6 kB
"use strict"; import { BaseTriggerAndObjectJsNode } from "./_BaseTriggerAndObject"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js"; import { JsType } from "../../poly/registers/nodes/types/Js"; import { Poly } from "../../Poly"; import { floatOutputFromParam, inputObject3D, inputPointIndex, integerOutputFromParam, vector3OutputFromParam } from "./_BaseObject3D"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; class SetInstanceLookAtJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param point index */ this.ptnum = ParamConfig.INTEGER(0); /** @param target position */ this.targetPosition = ParamConfig.VECTOR3([0, 0, 0]); /** @param up */ this.up = ParamConfig.VECTOR3([0, 1, 0]); /** @param lerp factor */ this.lerp = ParamConfig.FLOAT(1); } } const ParamsConfig = new SetInstanceLookAtJsParamsConfig(); export class SetInstanceLookAtJsNode extends BaseTriggerAndObjectJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return JsType.SET_INSTANCE_LOOK_AT; } _additionalOutputs() { return [ new JsConnectionPoint("ptnum", JsConnectionPointType.INT, CONNECTION_OPTIONS), new JsConnectionPoint("targetPosition", JsConnectionPointType.VECTOR3, CONNECTION_OPTIONS), new JsConnectionPoint("up", JsConnectionPointType.VECTOR3, CONNECTION_OPTIONS), new JsConnectionPoint("lerp", JsConnectionPointType.FLOAT, CONNECTION_OPTIONS) ]; } setLines(linesController) { super.setLines(linesController); integerOutputFromParam(this, this.p.ptnum, linesController); vector3OutputFromParam(this, this.p.targetPosition, linesController); floatOutputFromParam(this, this.p.lerp, linesController); } setTriggerableLines(linesController) { const object3D = inputObject3D(this, linesController); const ptnum = inputPointIndex(this, linesController); const targetPosition = this.variableForInputParam(linesController, this.p.targetPosition); const up = this.variableForInputParam(linesController, this.p.up); const lerp = this.variableForInputParam(linesController, this.p.lerp); const func = Poly.namedFunctionsRegister.getFunction("setPointInstanceLookAt", this, linesController); const bodyLine = func.asString(object3D, ptnum, targetPosition, up, lerp); linesController.addTriggerableLines(this, [bodyLine]); } }