UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

41 lines (40 loc) 1.27 kB
"use strict"; import { CADSopNode } from "./_BaseCAD"; import { NodeParamsConfig } from "../utils/params/ParamsConfig"; import { isArray } from "../../../core/Type"; import { SopType } from "../../poly/registers/nodes/types/Sop"; import { SOPCADTesselationParamConfig } from "../../../core/geometry/modules/cad/utils/TesselationParamsConfig"; class CADTriangulateSopParamsConfig extends SOPCADTesselationParamConfig(NodeParamsConfig) { } const ParamsConfig = new CADTriangulateSopParamsConfig(); export class CADTriangulateSopNode extends CADSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.CAD_TRIANGULATE; } initializeNode() { this.io.inputs.setCount(1); } async cook(inputCoreGroups) { const cadObjects = inputCoreGroups[0].cadObjects(); if (cadObjects) { const newObjects = []; for (const cadObject of cadObjects) { const objects = cadObject.toObject3D(this.pv, this); if (objects) { if (isArray(objects)) { newObjects.push(...objects); } else { newObjects.push(objects); } } } this.setObjects(newObjects); } else { this.setObjects([]); } } }