polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
61 lines (60 loc) • 2.27 kB
JavaScript
import {TypedSopNode} from "./_Base";
import {SphereSopOperation, SPHERE_TYPES, SPHERE_TYPE} from "../../../core/operations/sop/Sphere";
import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig";
const DEFAULT = SphereSopOperation.DEFAULT_PARAMS;
class SphereSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.type = ParamConfig.INTEGER(DEFAULT.type, {
menu: {
entries: SPHERE_TYPES.map((name) => {
return {name, value: SPHERE_TYPE[name]};
})
}
});
this.radius = ParamConfig.FLOAT(DEFAULT.radius, {visibleIf: {type: SPHERE_TYPE.default}});
this.resolution = ParamConfig.VECTOR2(DEFAULT.resolution, {visibleIf: {type: SPHERE_TYPE.default}});
this.open = ParamConfig.BOOLEAN(DEFAULT.open, {visibleIf: {type: SPHERE_TYPE.default}});
this.phiStart = ParamConfig.FLOAT(DEFAULT.phiStart, {
range: [0, Math.PI * 2],
visibleIf: {type: SPHERE_TYPE.default, open: true}
});
this.phiLength = ParamConfig.FLOAT("$PI*2", {
range: [0, Math.PI * 2],
visibleIf: {type: SPHERE_TYPE.default, open: true}
});
this.thetaStart = ParamConfig.FLOAT(DEFAULT.thetaStart, {
range: [0, Math.PI],
visibleIf: {type: SPHERE_TYPE.default, open: true}
});
this.thetaLength = ParamConfig.FLOAT("$PI", {
range: [0, Math.PI],
visibleIf: {type: SPHERE_TYPE.default, open: true}
});
this.detail = ParamConfig.INTEGER(DEFAULT.detail, {
range: [0, 5],
rangeLocked: [true, false],
visibleIf: {type: SPHERE_TYPE.isocahedron}
});
this.center = ParamConfig.VECTOR3(DEFAULT.center);
}
}
const ParamsConfig2 = new SphereSopParamsConfig();
export class SphereSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.params_config = ParamsConfig2;
}
static type() {
return "sphere";
}
initializeNode() {
this.io.inputs.setCount(0, 1);
this.io.inputs.initInputsClonedState(SphereSopOperation.INPUT_CLONED_STATE);
}
cook(input_contents) {
this._operation = this._operation || new SphereSopOperation(this.scene(), this.states);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
}