@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
70 lines (69 loc) • 3.33 kB
JavaScript
"use strict";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { JsType } from "../../poly/registers/nodes/types/Js";
import { Poly } from "../../Poly";
import { inputObject3D, integerOutputFromParam, stringOutputFromParam } from "./_BaseObject3D";
import { BaseTriggerAndObjectJsNode } from "./_BaseTriggerAndObject";
import { JS_CONNECTION_POINT_IN_NODE_DEF, JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class SetWFCSoftConstraintJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param floorId */
this.floorId = ParamConfig.INTEGER(0);
/** @param quadId */
this.quadId = ParamConfig.INTEGER(0);
/** @param tileId */
this.tileId = ParamConfig.STRING("");
/** @param rotation */
this.rotation = ParamConfig.INTEGER(0, {
range: [0, 3],
rangeLocked: [true, true]
});
/** @param quadId */
this.quadSeed = ParamConfig.INTEGER(0);
/** @param quadId */
this.configSeed = ParamConfig.INTEGER(0);
}
}
const ParamsConfig = new SetWFCSoftConstraintJsParamsConfig();
export class SetWFCSoftConstraintJsNode extends BaseTriggerAndObjectJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return JsType.SET_WFC_SOFT_CONSTRAINT;
}
_additionalOutputs() {
return [
new JsConnectionPoint("floorId", JsConnectionPointType.INT, CONNECTION_OPTIONS),
new JsConnectionPoint("quadId", JsConnectionPointType.INT, CONNECTION_OPTIONS),
new JsConnectionPoint("tileId", JsConnectionPointType.STRING, CONNECTION_OPTIONS),
new JsConnectionPoint("rotation", JsConnectionPointType.INT, CONNECTION_OPTIONS),
new JsConnectionPoint("quadSeed", JsConnectionPointType.INT, CONNECTION_OPTIONS),
new JsConnectionPoint("configSeed", JsConnectionPointType.INT, CONNECTION_OPTIONS)
];
}
setLines(linesController) {
super.setLines(linesController);
integerOutputFromParam(this, this.p.floorId, linesController);
integerOutputFromParam(this, this.p.quadId, linesController);
stringOutputFromParam(this, this.p.tileId, linesController);
integerOutputFromParam(this, this.p.rotation, linesController);
integerOutputFromParam(this, this.p.quadSeed, linesController);
integerOutputFromParam(this, this.p.configSeed, linesController);
}
setTriggerableLines(linesController) {
const object3D = inputObject3D(this, linesController);
const floorId = this.variableForInputParam(linesController, this.p.floorId);
const quadId = this.variableForInputParam(linesController, this.p.quadId);
const tileId = this.variableForInputParam(linesController, this.p.tileId);
const rotation = this.variableForInputParam(linesController, this.p.rotation);
const quadSeed = this.variableForInputParam(linesController, this.p.quadSeed);
const configSeed = this.variableForInputParam(linesController, this.p.configSeed);
const func = Poly.namedFunctionsRegister.getFunction("setWFCSoftConstraint", this, linesController);
const bodyLine = func.asString(object3D, floorId, quadId, tileId, rotation, quadSeed, configSeed);
linesController.addTriggerableLines(this, [bodyLine]);
}
}