UNPKG

@polygonjs/polygonjs

Version:

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

49 lines (48 loc) 1.84 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { NodeContext } from "../../poly/NodeContext"; import { InputCloneMode } from "../../poly/InputCloneMode"; import { AttribFromTextureSopOperation } from "../../operations/sop/AttribFromTexture"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; const DEFAULT = AttribFromTextureSopOperation.DEFAULT_PARAMS; class AttribFromTextureSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param texture node */ this.texture = ParamConfig.NODE_PATH("", { nodeSelection: { context: NodeContext.COP } }); /** @param uv attribute */ this.uvAttrib = ParamConfig.STRING(DEFAULT.uvAttrib); /** @param attribute to set the value to */ this.attrib = ParamConfig.STRING(DEFAULT.attrib); /** @param target attribute size */ this.attribSize = ParamConfig.INTEGER(DEFAULT.attribSize, { range: [1, 3], rangeLocked: [true, true] }); /** @param value to add to the attribute */ this.add = ParamConfig.FLOAT(DEFAULT.add); /** @param value to multiply the attribute with */ this.mult = ParamConfig.FLOAT(DEFAULT.mult); } } const ParamsConfig = new AttribFromTextureSopParamsConfig(); export class AttribFromTextureSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "attribFromTexture"; } initializeNode() { this.io.inputs.setCount(1); this.io.inputs.initInputsClonedState(InputCloneMode.FROM_NODE); } async cook(input_contents) { this._operation = this._operation || new AttribFromTextureSopOperation(this.scene(), this.states, this); const core_group = await this._operation.cook(input_contents, this.pv); this.setCoreGroup(core_group); } }