@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
42 lines (41 loc) • 1.14 kB
JavaScript
;
import { BaseSopOperation } from "./_Base";
import { Group, LineSegments, Mesh, Object3D, Points } from "three";
import { ObjectType, DEFAULT_MATERIALS } from "../../../core/geometry/Constant";
export class EmptyObjectSopOperation extends BaseSopOperation {
static type() {
return "emptyObject";
}
cook(inputCoreGroups, params) {
const object = this._createObjectFromType(params);
const objects = [];
if (object) {
const material = DEFAULT_MATERIALS[params.type];
if (material) {
object.material = material;
}
BaseSopOperation.applyObjectDefault(object);
objects.push(object);
}
return this.createCoreGroupFromObjects(objects);
}
_createObjectFromType(params) {
switch (params.type) {
case ObjectType.GROUP: {
return new Group();
}
case ObjectType.LINE_SEGMENTS: {
return new LineSegments();
}
case ObjectType.MESH: {
return new Mesh();
}
case ObjectType.OBJECT3D: {
return new Object3D();
}
case ObjectType.POINTS: {
return new Points();
}
}
}
}