UNPKG

@polygonjs/polygonjs

Version:

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

47 lines (46 loc) 1.46 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { CapsuleSopOperation } from "../../operations/sop/Capsule"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { SopType } from "../../poly/registers/nodes/types/Sop"; const DEFAULT = CapsuleSopOperation.DEFAULT_PARAMS; class CapsuleSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param radius */ this.radius = ParamConfig.FLOAT(DEFAULT.radius, { range: [0, 1], rangeLocked: [true, false] }); /** @param height */ this.height = ParamConfig.FLOAT(DEFAULT.height, { range: [0, 2], rangeLocked: [true, false] }); /** @param divisions */ this.divisions = ParamConfig.INTEGER(DEFAULT.divisions, { range: [1, 10], rangeLocked: [true, false] }); /** @param center */ this.center = ParamConfig.VECTOR3(DEFAULT.center); } } const ParamsConfig = new CapsuleSopParamsConfig(); export class CapsuleSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.CAPSULE; } initializeNode() { this.io.inputs.setCount(0); } cook(inputCoreGroups) { this._operation = this._operation || new CapsuleSopOperation(this._scene, this.states, this); const coreGroup = this._operation.cook(inputCoreGroups, this.pv); this.setCoreGroup(coreGroup); } }