UNPKG

@polygonjs/polygonjs

Version:

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

43 lines (42 loc) 1.27 kB
"use strict"; import { CSGSopNode } from "./_BaseCSG"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { SopType } from "../../poly/registers/nodes/types/Sop"; import { maths } from "@jscad/modeling"; import { csgApplyTransform } from "../../../core/geometry/modules/csg/math/CsgMat4"; const { mat4 } = maths; class CSGTransformResetSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param bake matrix onto points */ this.extract = ParamConfig.BOOLEAN(0); } } const ParamsConfig = new CSGTransformResetSopParamsConfig(); export class CSGTransformResetSopNode extends CSGSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.CSG_TRANSFORM_RESET; } initializeNode() { this.io.inputs.setCount(1); } cook(inputCoreGroups) { const objects = inputCoreGroups[0].csgObjects(); if (objects) { for (const object of objects) { if (this.pv.extract) { csgApplyTransform(object.csgGeometry()); } else { mat4.identity(object.csgGeometry().transforms); } } this.setCSGObjects(objects); } else { this.setCSGObjects([]); } } }