@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
36 lines (35 loc) • 1.16 kB
JavaScript
;
import { TypedSopNode } from "./_Base";
import { CsgObject } from "../../../core/geometry/modules/csg/CsgObject";
import { CoreGroup } from "../../../core/geometry/Group";
import { CoreObjectType } from "../../../core/geometry/ObjectContent";
import { ModuleName } from "../../poly/registers/modules/Common";
export class CSGSopNode extends TypedSopNode {
dataType() {
return CoreObjectType.CSG;
}
requiredModules() {
return [ModuleName.CSG];
}
setCSGGeometry(geometry) {
const objects = [new CsgObject(geometry)];
this._setContainerCsgObjects(objects);
}
setCSGGeometries(geometries) {
const objects = geometries.map((g) => new CsgObject(g));
this._setContainerCsgObjects(objects);
}
setCSGObjects(csgObjects) {
this._setContainerCsgObjects(csgObjects);
}
setCSGObject(csgObject) {
this._setContainerCsgObjects([csgObject]);
}
_setContainerCsgObjects(objects) {
const coreGroup = this.containerController.container().coreContent() || new CoreGroup();
coreGroup.setAllObjects(objects);
this._setContainer(coreGroup);
}
}
export class BaseCSGSopNodeClass extends CSGSopNode {
}