UNPKG

@polygonjs/polygonjs

Version:

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

38 lines (37 loc) 1.33 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { NodeParamsConfig } from "../utils/params/ParamsConfig"; import { InputCloneMode } from "../../poly/InputCloneMode"; import { SkeletonHelper } from "three"; import { SopType } from "../../poly/registers/nodes/types/Sop"; class SkeletonHelperSopParamsConfig extends NodeParamsConfig { // no keepInput param for now, as there seems to be a bug // where if the input is not kept, the skeleton does not display immediately. // It would only display if the input node is set its display flag first // keepInput = ParamConfig.BOOLEAN(1); } const ParamsConfig = new SkeletonHelperSopParamsConfig(); export class SkeletonHelperSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.SKELETON_HELPER; } initializeNode() { this.io.inputs.setCount(1); this.io.inputs.initInputsClonedState(InputCloneMode.NEVER); } cook(inputCoreGroups) { const inputCoreGroup = inputCoreGroups[0]; const objects = inputCoreGroup.threejsObjects(); const newObjects = []; for (const object of objects) { const helper = new SkeletonHelper(object); newObjects.push(object); newObjects.push(helper); } this.setObjects(newObjects); } }