@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
44 lines (39 loc) • 1.6 kB
text/typescript
/**
* Adds attribute containing information about connected points.
*
*
*/
import {TypedSopNode} from './_Base';
import {CoreGroup} from '../../../core/geometry/Group';
import {InputCloneMode} from '../../poly/InputCloneMode';
import {AdjacencySopOperation} from '../../operations/sop/Adjacency';
import {NodeParamsConfig, ParamConfig} from '../utils/params/ParamsConfig';
import {SopType} from '../../poly/registers/nodes/types/Sop';
const DEFAULT = AdjacencySopOperation.DEFAULT_PARAMS;
class AdjacencySopParamsConfig extends NodeParamsConfig {
/** @param select which objects this add adjacency attributes to */
group = ParamConfig.STRING('', {
objectMask: true,
});
/** @param name of attribute with count of adjacency attributes */
adjacencyCountName = ParamConfig.STRING(DEFAULT.adjacencyCountName);
/** @param name of adjacency attribute */
adjacencyBaseName = ParamConfig.STRING(DEFAULT.adjacencyBaseName);
}
const ParamsConfig = new AdjacencySopParamsConfig();
export class AdjacencySopNode extends TypedSopNode<AdjacencySopParamsConfig> {
override paramsConfig = ParamsConfig;
static override type() {
return SopType.ADJACENCY;
}
override initializeNode() {
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState([InputCloneMode.FROM_NODE]);
}
private _operation: AdjacencySopOperation | undefined;
override cook(inputCoreGroups: CoreGroup[]) {
this._operation = this._operation || new AdjacencySopOperation(this.scene(), this.states, this);
const coreGroup = this._operation.cook(inputCoreGroups, this.pv);
this.setCoreGroup(coreGroup);
}
}