UNPKG

@polygonjs/polygonjs

Version:

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

48 lines (47 loc) 1.55 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { BVHSopOperation, STRAGERY_MENU_ENTRIES } from "../../operations/sop/BVH"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { SopType } from "../../poly/registers/nodes/types/Sop"; const DEFAULT = BVHSopOperation.DEFAULT_PARAMS; class BVHSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); this.strategy = ParamConfig.INTEGER(DEFAULT.strategy, { menu: { entries: STRAGERY_MENU_ENTRIES } }); this.maxDepth = ParamConfig.INTEGER(DEFAULT.maxDepth, { range: [1, 128], rangeLocked: [true, false] }); this.maxLeafTris = ParamConfig.INTEGER(DEFAULT.maxLeafTris, { range: [1, 16], rangeLocked: [true, false] }); this.compact = ParamConfig.BOOLEAN(DEFAULT.compact); this.verbose = ParamConfig.BOOLEAN(DEFAULT.verbose, { visibleIf: { compact: 0 } }); } } const ParamsConfig = new BVHSopParamsConfig(); export class BVHSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.BVH; } initializeNode() { this.io.inputs.setCount(1); this.io.inputs.initInputsClonedState(BVHSopOperation.INPUT_CLONED_STATE); } cook(inputCoreGroups) { this._operation = this._operation || new BVHSopOperation(this._scene, this.states, this); const coreGroup = this._operation.cook(inputCoreGroups, this.pv); this.setCoreGroup(coreGroup); } }