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