@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
49 lines (48 loc) • 1.97 kB
JavaScript
;
import { TypedJsNode } from "./_Base";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { JS_CONNECTION_POINT_IN_NODE_DEF, JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js";
import { Poly } from "../../Poly";
import { Vector3 } from "three";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class Vector3ApplyMatrix4JsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param Vector3 */
this.Vector3 = ParamConfig.VECTOR3([0, 0, 0]);
}
}
const ParamsConfig = new Vector3ApplyMatrix4JsParamsConfig();
export class Vector3ApplyMatrix4JsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "vector3ApplyMatrix4";
}
initializeNode() {
super.initializeNode();
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(JsConnectionPointType.VECTOR3, JsConnectionPointType.VECTOR3, CONNECTION_OPTIONS),
new JsConnectionPoint(JsConnectionPointType.MATRIX4, JsConnectionPointType.MATRIX4, CONNECTION_OPTIONS)
]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(JsConnectionPointType.VECTOR3, JsConnectionPointType.VECTOR3)
]);
}
setLines(linesController) {
const vector3 = this.variableForInputParam(linesController, this.p.Vector3);
const matrix4 = this.variableForInput(linesController, JsConnectionPointType.MATRIX4);
const varName = this.jsVarName(JsConnectionPointType.VECTOR3);
const tmpVarName = linesController.addVariable(this, new Vector3());
const func = Poly.namedFunctionsRegister.getFunction("vector3ApplyMatrix4", this, linesController);
linesController.addBodyOrComputed(this, [
{
dataType: JsConnectionPointType.MATRIX4,
varName,
value: func.asString(vector3, matrix4, tmpVarName)
}
]);
}
}