UNPKG

@polygonjs/polygonjs

Version:

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

48 lines (47 loc) 1.5 kB
"use strict"; import { CSGSopNode } from "./_BaseCSG"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { SopType } from "../../poly/registers/nodes/types/Sop"; import { primitives } from "@jscad/modeling"; import { vector3ToCsgVec3 } from "../../../core/geometry/modules/csg/CsgVecToVector"; const { ellipsoid } = primitives; class CSGEllipsoidSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param center */ this.center = ParamConfig.VECTOR3([0, 0, 0]); /** @param radius */ this.radius = ParamConfig.VECTOR3([1, 1, 1]); /** @param segments */ this.segments = ParamConfig.INTEGER(32, { range: [4, 128], rangeLocked: [true, false] }); } /** @param axes */ // axes = ParamConfig.VECTOR3([0, 1, 0]); } const ParamsConfig = new CSGEllipsoidSopParamsConfig(); export class CSGEllipsoidSopNode extends CSGSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; this._center = [0, 0, 0]; this._radius = [0, 0, 0]; } static type() { return SopType.CSG_ELLIPSOID; } // private _axes: maths.vec3.Vec3 = [0, 0, 0]; cook(inputCoreGroups) { vector3ToCsgVec3(this.pv.center, this._center); vector3ToCsgVec3(this.pv.radius, this._radius); const geo = ellipsoid({ center: this._center, radius: this._radius, segments: this.pv.segments // axes: this._axes, }); this.setCSGGeometry(geo); } }