@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
66 lines (65 loc) • 2.67 kB
JavaScript
"use strict";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js";
import { Poly } from "../../Poly";
import {
integerOutputFromParam,
floatOutputFromParam,
inputObject3D,
inputPointIndex,
vector3OutputFromParam
} from "./_BaseObject3D";
import { BaseTriggerAndObjectJsNode } from "./_BaseTriggerAndObject";
import { JsType } from "../../poly/registers/nodes/types/Js";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class SetInstanceScaleJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param point index */
this.ptnum = ParamConfig.INTEGER(0);
/** @param target scale */
this.scale = ParamConfig.VECTOR3([1, 1, 1]);
/** @param target scale */
this.mult = ParamConfig.FLOAT(1, {
range: [0, 2],
rangeLocked: [false, false]
});
/** @param lerp factor */
this.lerp = ParamConfig.FLOAT(1);
}
}
const ParamsConfig = new SetInstanceScaleJsParamsConfig();
export class SetInstanceScaleJsNode extends BaseTriggerAndObjectJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return JsType.SET_INSTANCE_SCALE;
}
_additionalOutputs() {
return [
new JsConnectionPoint("ptnum", JsConnectionPointType.INT, CONNECTION_OPTIONS),
new JsConnectionPoint("scale", JsConnectionPointType.VECTOR3, CONNECTION_OPTIONS),
new JsConnectionPoint("mult", JsConnectionPointType.FLOAT, CONNECTION_OPTIONS),
new JsConnectionPoint("lerp", JsConnectionPointType.FLOAT, CONNECTION_OPTIONS)
];
}
setLines(linesController) {
super.setLines(linesController);
integerOutputFromParam(this, this.p.ptnum, linesController);
vector3OutputFromParam(this, this.p.scale, linesController);
floatOutputFromParam(this, this.p.mult, linesController);
floatOutputFromParam(this, this.p.lerp, linesController);
}
setTriggerableLines(linesController) {
const object3D = inputObject3D(this, linesController);
const ptnum = inputPointIndex(this, linesController);
const scale = this.variableForInputParam(linesController, this.p.scale);
const mult = this.variableForInputParam(linesController, this.p.mult);
const lerp = this.variableForInputParam(linesController, this.p.lerp);
const func = Poly.namedFunctionsRegister.getFunction("setPointInstanceScale", this, linesController);
const bodyLine = func.asString(object3D, ptnum, scale, mult, lerp);
linesController.addTriggerableLines(this, [bodyLine]);
}
}