UNPKG

polygonjs-engine

Version:

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

43 lines (42 loc) 1.53 kB
import {TypedSopNode} from "./_Base"; import {NodeContext as NodeContext2} from "../../poly/NodeContext"; import {InstanceSopOperation} from "../../../core/operations/sop/Instance"; import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig"; const DEFAULT = InstanceSopOperation.DEFAULT_PARAMS; class InstanceSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); this.attributesToCopy = ParamConfig.STRING(DEFAULT.attributesToCopy); this.applyMaterial = ParamConfig.BOOLEAN(DEFAULT.applyMaterial); this.material = ParamConfig.NODE_PATH(DEFAULT.material.path(), { visibleIf: {applyMaterial: 1}, nodeSelection: { context: NodeContext2.MAT }, dependentOnFoundNode: false }); } } const ParamsConfig2 = new InstanceSopParamsConfig(); export class InstanceSopNode extends TypedSopNode { constructor() { super(...arguments); this.params_config = ParamsConfig2; } static type() { return "instance"; } static displayedInputNames() { return ["geometry to be instanciated", "points to instance to"]; } initializeNode() { super.initializeNode(); this.io.inputs.setCount(2); this.io.inputs.initInputsClonedState(InstanceSopOperation.INPUT_CLONED_STATE); } async cook(input_contents) { this._operation = this._operation || new InstanceSopOperation(this.scene(), this.states); const core_group = await this._operation.cook(input_contents, this.pv); this.setCoreGroup(core_group); } }