UNPKG

@polygonjs/polygonjs

Version:

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

49 lines (48 loc) 1.44 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { EmptyObjectSopOperation } from "../../operations/sop/EmptyObject"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { ObjectType } from "../../../core/geometry/Constant"; const OBJECT_TYPES = [ ObjectType.OBJECT3D, ObjectType.GROUP, ObjectType.MESH, ObjectType.POINTS, ObjectType.LINE_SEGMENTS ]; class EmptyObjectSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); this.type = ParamConfig.STRING(ObjectType.GROUP, { menuString: { entries: OBJECT_TYPES.map((name, value) => ({ name, value: name })) } }); } } const ParamsConfig = new EmptyObjectSopParamsConfig(); export class EmptyObjectSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "emptyObject"; } initializeNode() { this.io.inputs.setCount(0); } cook(input_contents) { this._operation = this._operation || new EmptyObjectSopOperation(this._scene, this.states, this); const type = this.pv.type; const coreGroup = this._operation.cook(input_contents, { type }); this.setCoreGroup(coreGroup); } setObjectType(objectType) { this.p.type.set(objectType); } objectType() { const included = OBJECT_TYPES.includes(this.pv.type); return included ? this.pv.type : void 0; } }