UNPKG

@polygonjs/polygonjs

Version:

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

41 lines (40 loc) 1.26 kB
"use strict"; import { CSGSopNode } from "./_BaseCSG"; import { NodeParamsConfig } from "../utils/params/ParamsConfig"; import { isArray } from "../../../core/Type"; import { SopType } from "../../poly/registers/nodes/types/Sop"; import { SOPCSGTesselationParamConfig } from "../../../core/geometry/modules/csg/utils/TesselationParamsConfig"; class CSGTriangulateSopParamsConfig extends SOPCSGTesselationParamConfig(NodeParamsConfig) { } const ParamsConfig = new CSGTriangulateSopParamsConfig(); export class CSGTriangulateSopNode extends CSGSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.CSG_TRIANGULATE; } initializeNode() { this.io.inputs.setCount(1); } async cook(inputCoreGroups) { const csgObjects = inputCoreGroups[0].csgObjects(); if (csgObjects) { const newObjects = []; for (const cadObject of csgObjects) { const objects = cadObject.toObject3D(this.pv); if (objects) { if (isArray(objects)) { newObjects.push(...objects); } else { newObjects.push(objects); } } } this.setObjects(newObjects); } else { this.setObjects([]); } } }