@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
39 lines (38 loc) • 1.44 kB
JavaScript
;
import { TypedSopNode } from "./_Base";
import { UvLayoutSopOperation } from "../../operations/sop/UvLayout";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { SopType } from "../../poly/registers/nodes/types/Sop";
const DEFAULT = UvLayoutSopOperation.DEFAULT_PARAMS;
class UvLayoutSopParamConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param expected map resolution */
this.res = ParamConfig.INTEGER(DEFAULT.res);
/** @param padding between uv islands, in pixels */
this.padding = ParamConfig.INTEGER(DEFAULT.padding);
/** @param uv attribute to layout */
this.uv = ParamConfig.STRING(DEFAULT.uv);
/** @param new uv attribute that will be set or created */
this.uv2 = ParamConfig.STRING(DEFAULT.uv2);
}
}
const ParamsConfig = new UvLayoutSopParamConfig();
export class UvLayoutSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopType.UV_LAYOUT;
}
initializeNode() {
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState(UvLayoutSopOperation.INPUT_CLONED_STATE);
}
cook(input_contents) {
this._operation = this._operation || new UvLayoutSopOperation(this.scene(), this.states, this);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
}