@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
42 lines (41 loc) • 1.64 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 { Vector2 } from "three";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
var CursorToUvJsNodeOutputName = /* @__PURE__ */ ((CursorToUvJsNodeOutputName2) => {
CursorToUvJsNodeOutputName2["uv"] = "uv";
return CursorToUvJsNodeOutputName2;
})(CursorToUvJsNodeOutputName || {});
class CursorToUvJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.cursor = ParamConfig.VECTOR2([0, 0]);
}
}
const ParamsConfig = new CursorToUvJsParamsConfig();
export class CursorToUvJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "cursorToUv";
}
initializeNode() {
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint("uv" /* uv */, JsConnectionPointType.VECTOR2, CONNECTION_OPTIONS)
]);
}
setLines(linesController) {
const cursor = this.variableForInputParam(linesController, this.p.cursor);
const varName = this.jsVarName("uv" /* uv */);
const tmpVarName = linesController.addVariable(this, new Vector2());
const func = Poly.namedFunctionsRegister.getFunction("cursorToUv", this, linesController);
linesController.addBodyOrComputed(this, [
{ dataType: JsConnectionPointType.VECTOR2, varName, value: func.asString(cursor, tmpVarName) }
]);
}
}