@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
73 lines (72 loc) • 3.18 kB
JavaScript
"use strict";
import { BaseTriggerAndObjectJsNode } from "./_BaseTriggerAndObject";
import { inputObject3D } from "./_BaseObject3D";
import { Poly } from "../../Poly";
import { NodeParamsConfig } from "../utils/params/ParamsConfig";
import { JsConnectionPointType } from "../utils/io/connections/Js";
export var CreateObjectsJsNodeInput = /* @__PURE__ */ ((CreateObjectsJsNodeInput2) => {
CreateObjectsJsNodeInput2["CHILD"] = "child";
CreateObjectsJsNodeInput2["CHILDREN"] = "children";
return CreateObjectsJsNodeInput2;
})(CreateObjectsJsNodeInput || {});
class CreateObjectsJsParamsConfig extends NodeParamsConfig {
}
const ParamsConfig = new CreateObjectsJsParamsConfig();
export class CreateObjectsJsNode extends BaseTriggerAndObjectJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "createObjects";
}
initializeNode() {
super.initializeNode();
this.io.connection_points.set_input_name_function(this._expectedInputName.bind(this));
this.io.connection_points.set_output_name_function(this._expectedOutputName.bind(this));
this.io.connection_points.set_expected_input_types_function(this._expectedInputTypes.bind(this));
this.io.connection_points.set_expected_output_types_function(this._expectedOutputTypes.bind(this));
}
_expectedInputName(index) {
return [JsConnectionPointType.TRIGGER, JsConnectionPointType.OBJECT_3D, this._childInputName()][index];
}
_expectedOutputName(index) {
return [JsConnectionPointType.TRIGGER, JsConnectionPointType.OBJECT_3D, this._childOutputName()][index];
}
_expectedInputTypes() {
return [JsConnectionPointType.TRIGGER, JsConnectionPointType.OBJECT_3D, this._childInputType()];
}
_expectedOutputTypes() {
return this._expectedInputTypes();
}
_isInputArray() {
const firstInputType = this.io.connection_points.input_connection_type(2);
return firstInputType == JsConnectionPointType.OBJECT_3D_ARRAY;
}
_childInputName() {
return this._isInputArray() ? "children" /* CHILDREN */ : "child" /* CHILD */;
}
_childOutputName() {
return this._childInputName();
}
_childInputType() {
return this._isInputArray() ? JsConnectionPointType.OBJECT_3D_ARRAY : JsConnectionPointType.OBJECT_3D;
}
setLines(linesController) {
super.setLines(linesController);
const object3D = this.variableForInput(linesController, this._childOutputName());
const out = this.jsVarName(this._childOutputName());
linesController.addBodyOrComputed(this, [
{ dataType: JsConnectionPointType.OBJECT_3D, varName: out, value: object3D }
]);
}
setTriggerableLines(linesController) {
const object3D = inputObject3D(this, linesController);
const inputName = this._childInputName();
const inputChildObjects = this.variableForInput(linesController, inputName);
const functionName = this._isInputArray() ? "createObjects" : "createObject";
const func = Poly.namedFunctionsRegister.getFunction(functionName, this, linesController);
const bodyLine = func.asString(object3D, inputChildObjects);
linesController.addTriggerableLines(this, [bodyLine]);
}
}