@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
51 lines (50 loc) • 1.94 kB
JavaScript
;
import { TypedJsNode } from "./_Base";
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 { inputObject3D } from "./_BaseObject3D";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class GetObjectJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param use current object */
this.getCurrentObject = ParamConfig.BOOLEAN(1);
/** @param object mask */
this.mask = ParamConfig.STRING("", {
visibleIf: {
getCurrentObject: 0
},
objectMask: true
});
}
}
const ParamsConfig = new GetObjectJsParamsConfig();
export class GetObjectJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "getObject";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint("mask", JsConnectionPointType.STRING, CONNECTION_OPTIONS)
]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D)
]);
}
setLines(linesController) {
const object3D = inputObject3D(this, linesController);
const getCurrentObject = this.variableForInputParam(linesController, this.p.getCurrentObject);
const mask = this.variableForInputParam(linesController, this.p.mask);
const out = this.jsVarName(JsConnectionPointType.OBJECT_3D);
const func = Poly.namedFunctionsRegister.getFunction("getObject", this, linesController);
const bodyLine = func.asString(object3D, getCurrentObject, mask);
linesController.addBodyOrComputed(this, [
{ dataType: JsConnectionPointType.PLANE, varName: out, value: bodyLine }
]);
}
}