UNPKG

@polygonjs/polygonjs

Version:

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

53 lines (52 loc) 1.73 kB
"use strict"; import { TetSopNode } from "./_BaseTet"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { SopType } from "../../poly/registers/nodes/types/Sop"; import { CoreSoftBodyAttribute } from "../../../core/softBody/SoftBodyAttribute"; class TetEmbedSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param highRes Skinning Lookup Spacing */ this.spacing = ParamConfig.FLOAT(0.05, { range: [0, 0.5], rangeLocked: [true, false] }); /** @param highRes Skinning Lookup Padding */ this.padding = ParamConfig.FLOAT(0.05, { range: [0, 0.5], rangeLocked: [true, false] }); } } const ParamsConfig = new TetEmbedSopParamsConfig(); export class TetEmbedSopNode extends TetSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.TET_EMBED; } initializeNode() { this.io.inputs.setCount(2); } async cook(inputCoreGroups) { var _a; const tetObjects = inputCoreGroups[0].tetObjects(); const highResNodeId = (_a = this.io.inputs.input(1)) == null ? void 0 : _a.graphNodeId(); if (highResNodeId == null) { this.states.error.set(`no high res node connected`); return; } if (tetObjects) { for (const tetObject of tetObjects) { CoreSoftBodyAttribute.setTetEmbedHighResNodeId(tetObject, highResNodeId); CoreSoftBodyAttribute.setHighResSkinningLookupSpacing(tetObject, this.pv.spacing); CoreSoftBodyAttribute.setHighResSkinningLookupPadding(tetObject, this.pv.padding); } this.setObjects(tetObjects); } else { this.setObjects([]); } } }