UNPKG

@polygonjs/polygonjs

Version:

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

54 lines (53 loc) 1.61 kB
"use strict"; import { TypedJsNode } from "./_Base"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js"; import { NodeContext } from "../../poly/NodeContext"; import { Poly } from "../../Poly"; class GetTextureJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param the texture node */ this.node = ParamConfig.NODE_PATH("", { nodeSelection: { context: NodeContext.COP }, dependentOnFoundNode: false, computeOnDirty: true }); } } const ParamsConfig = new GetTextureJsParamsConfig(); export class GetTextureJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "getTexture"; } initializeNode() { this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.TEXTURE, JsConnectionPointType.TEXTURE) ]); } setLines(shadersCollectionController) { const node = this.pv.node.node(); if (!(node && node.context() == NodeContext.COP)) { return; } const nodePath = `'${node.path()}'`; const varName = this.jsVarName(JsConnectionPointType.TEXTURE); const func = Poly.namedFunctionsRegister.getFunction("getTexture", this, shadersCollectionController); shadersCollectionController.addBodyOrComputed(this, [ { dataType: JsConnectionPointType.TEXTURE, varName, value: func.asString(nodePath) } ]); } }