UNPKG

laya-coreui-es

Version:

laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改

60 lines (59 loc) 2.01 kB
import { ILaya } from "../../../ILaya"; export class ShaderNode { constructor(includefiles) { this.childs = []; this.text = ""; this.useFuns = ""; this.z = 0; this.includefiles = includefiles; } setParent(parent) { parent.childs.push(this); this.z = parent.z + 1; this.parent = parent; } setCondition(condition, type) { if (condition) { this.conditionType = type; condition = condition.replace(/(\s*$)/g, ""); this.condition = function () { return this[condition]; }; this.condition.__condition = condition; } } toscript(def, out) { return this._toscript(def, out, ++ShaderNode.__id); } _toscript(def, out, id) { if (this.childs.length < 1 && !this.text) return out; var outIndex = out.length; if (this.condition) { var ifdef = !!this.condition.call(def); this.conditionType === ILaya.ShaderCompile.IFDEF_ELSE && (ifdef = !ifdef); if (!ifdef) return out; } if (this.noCompile) this.text && out.push(this.text); this.childs.length > 0 && this.childs.forEach(function (o, index, arr) { o._toscript(def, out, id); }); if (this.includefiles.length > 0 && this.useFuns.length > 0) { var funsCode; for (var i = 0, n = this.includefiles.length; i < n; i++) { if (this.includefiles[i].curUseID == id) { continue; } funsCode = this.includefiles[i].file.getFunsScript(this.useFuns); if (funsCode.length > 0) { this.includefiles[i].curUseID = id; out[0] = funsCode + out[0]; } } } return out; } } ShaderNode.__id = 1;