@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
57 lines (56 loc) • 2.18 kB
JavaScript
"use strict";
import { TypedSopNode } from "./_Base";
import { PolarTransformSopOperation } from "../../operations/sop/PolarTransform";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { TRANSFORM_TARGET_TYPES } from "../../../core/Transform";
import { SopType } from "../../poly/registers/nodes/types/Sop";
const DEFAULT = PolarTransformSopOperation.DEFAULT_PARAMS;
class PolarTransformSopParamConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param sets if this node should transform objects or geometries */
this.applyOn = ParamConfig.INTEGER(DEFAULT.applyOn, {
menu: {
entries: TRANSFORM_TARGET_TYPES.map((target_type, i) => {
return { name: target_type, value: i };
})
}
});
/** @param center of the transform */
this.center = ParamConfig.VECTOR3(DEFAULT.center.toArray());
/** @param moves the objects along the longitude, which is equivalent to a rotation on the y axis */
this.longitude = ParamConfig.FLOAT(DEFAULT.longitude, {
range: [-360, 360]
});
/** @param moves the objects along the latitude, which is equivalent to a rotation on the z or x axis */
this.latitude = ParamConfig.FLOAT(DEFAULT.latitude, {
range: [-180, 180]
});
/** @param moves the point aways from the center */
this.depth = ParamConfig.FLOAT(DEFAULT.depth, {
range: [0, 10]
});
}
}
const ParamsConfig = new PolarTransformSopParamConfig();
export class PolarTransformSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopType.POLAR_TRANSFORM;
}
initializeNode() {
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState(PolarTransformSopOperation.INPUT_CLONED_STATE);
}
cook(input_contents) {
this._operation = this._operation || new PolarTransformSopOperation(this.scene(), this.states, this);
const core_group = this._operation.cook(input_contents, this.pv);
this.setCoreGroup(core_group);
}
setApplyOn(mode) {
this.p.applyOn.set(TRANSFORM_TARGET_TYPES.indexOf(mode));
}
}