@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
60 lines (59 loc) • 2.75 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 { booleanOutputFromParam, floatOutputFromParam, inputObject3D, 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 SetObjectScaleJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @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);
/** @param sets if the matrix should be updated as the animation progresses */
this.updateMatrix = ParamConfig.BOOLEAN(1);
}
}
const ParamsConfig = new SetObjectScaleJsParamsConfig();
export class SetObjectScaleJsNode extends BaseTriggerAndObjectJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return JsType.SET_OBJECT_SCALE;
}
_additionalOutputs() {
return [
new JsConnectionPoint("scale", JsConnectionPointType.VECTOR3, CONNECTION_OPTIONS),
new JsConnectionPoint("mult", JsConnectionPointType.FLOAT, CONNECTION_OPTIONS),
new JsConnectionPoint("lerp", JsConnectionPointType.FLOAT, CONNECTION_OPTIONS),
new JsConnectionPoint("updateMatrix", JsConnectionPointType.BOOLEAN, CONNECTION_OPTIONS)
];
}
setLines(linesController) {
super.setLines(linesController);
vector3OutputFromParam(this, this.p.scale, linesController);
floatOutputFromParam(this, this.p.mult, linesController);
floatOutputFromParam(this, this.p.lerp, linesController);
booleanOutputFromParam(this, this.p.updateMatrix, linesController);
}
setTriggerableLines(linesController) {
const object3D = inputObject3D(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 updateMatrix = this.variableForInputParam(linesController, this.p.updateMatrix);
const func = Poly.namedFunctionsRegister.getFunction("setObjectScale", this, linesController);
const bodyLine = func.asString(object3D, scale, mult, lerp, updateMatrix);
linesController.addTriggerableLines(this, [bodyLine]);
}
}