UNPKG

polygonjs-engine

Version:

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

48 lines (47 loc) 2 kB
import {TypedSopNode} from "./_Base"; import {NodeContext as NodeContext2} from "../../poly/NodeContext"; import {MaterialSopOperation} from "../../../core/operations/sop/Material"; import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig"; const DEFAULT = MaterialSopOperation.DEFAULT_PARAMS; class MaterialSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); this.group = ParamConfig.STRING(DEFAULT.group); this.assignMat = ParamConfig.BOOLEAN(DEFAULT.assignMat); this.material = ParamConfig.NODE_PATH(DEFAULT.material.path(), { nodeSelection: { context: NodeContext2.MAT }, dependentOnFoundNode: false, visibleIf: {assignMat: 1} }); this.applyToChildren = ParamConfig.BOOLEAN(DEFAULT.applyToChildren, {visibleIf: {assignMat: 1}}); this.cloneMat = ParamConfig.BOOLEAN(DEFAULT.cloneMat, {visibleIf: {assignMat: 1}}); this.shareUniforms = ParamConfig.BOOLEAN(DEFAULT.shareUniforms, {visibleIf: {assignMat: 1, cloneMat: 1}}); this.swapCurrentTex = ParamConfig.BOOLEAN(DEFAULT.swapCurrentTex); this.texSrc0 = ParamConfig.STRING(DEFAULT.texSrc0, {visibleIf: {swapCurrentTex: 1}}); this.texDest0 = ParamConfig.STRING(DEFAULT.texDest0, {visibleIf: {swapCurrentTex: 1}}); } } const ParamsConfig2 = new MaterialSopParamsConfig(); export class MaterialSopNode extends TypedSopNode { constructor() { super(...arguments); this.params_config = ParamsConfig2; } static type() { return "material"; } static displayedInputNames() { return ["objects to assign material to"]; } initializeNode() { this.io.inputs.setCount(1); this.io.inputs.initInputsClonedState(MaterialSopOperation.INPUT_CLONED_STATE); } async cook(input_contents) { this._operation = this._operation || new MaterialSopOperation(this._scene, this.states); const core_group = await this._operation.cook(input_contents, this.pv); this.setCoreGroup(core_group); } }