{"ast":null,"code":"/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { ShaderCodeNode } from \"./shaderCodeNode.js\";\nimport { ShaderCodeCursor } from \"./shaderCodeCursor.js\";\nimport { ShaderCodeConditionNode } from \"./shaderCodeConditionNode.js\";\nimport { ShaderCodeTestNode } from \"./shaderCodeTestNode.js\";\nimport { ShaderDefineIsDefinedOperator } from \"./Expressions/Operators/shaderDefineIsDefinedOperator.js\";\nimport { ShaderDefineOrOperator } from \"./Expressions/Operators/shaderDefineOrOperator.js\";\nimport { ShaderDefineAndOperator } from \"./Expressions/Operators/shaderDefineAndOperator.js\";\nimport { ShaderDefineExpression } from \"./Expressions/shaderDefineExpression.js\";\nimport { ShaderDefineArithmeticOperator } from \"./Expressions/Operators/shaderDefineArithmeticOperator.js\";\nimport { _WarnImport } from \"../../Misc/devTools.js\";\nimport { _getGlobalDefines } from \"../abstractEngine.functions.js\";\nconst regexSE = /defined\\s*?\\((.+?)\\)/g;\nconst regexSERevert = /defined\\s*?\\[(.+?)\\]/g;\nconst regexShaderInclude = /#include\\s?<(.+)>(\\((.*)\\))*(\\[(.*)\\])*/g;\nconst regexShaderDecl = /__decl__/;\nconst regexLightX = /light\\{X\\}.(\\w*)/g;\nconst regexX = /\\{X\\}/g;\nconst reusableMatches = [];\nconst _MoveCursorRegex = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;\n/** @internal */\nexport function Initialize(options) {\n if (options.processor && options.processor.initializeShaders) {\n options.processor.initializeShaders(options.processingContext);\n }\n}\n/** @internal */\nexport function Process(sourceCode, options, callback, engine) {\n var _options$processor;\n if ((_options$processor = options.processor) !== null && _options$processor !== void 0 && _options$processor.preProcessShaderCode) {\n sourceCode = options.processor.preProcessShaderCode(sourceCode, options.isFragment);\n }\n _ProcessIncludes(sourceCode, options, codeWithIncludes => {\n if (options.processCodeAfterIncludes) {\n codeWithIncludes = options.processCodeAfterIncludes(options.isFragment ? \"fragment\" : \"vertex\", codeWithIncludes, options.defines);\n }\n const migratedCode = _ProcessShaderConversion(codeWithIncludes, options, engine);\n callback(migratedCode, codeWithIncludes);\n });\n}\n/** @internal */\nexport function PreProcess(sourceCode, options, callback, engine) {\n var _options$processor2;\n if ((_options$processor2 = options.processor) !== null && _options$processor2 !== void 0 && _options$processor2.preProcessShaderCode) {\n sourceCode = options.processor.preProcessShaderCode(sourceCode, options.isFragment);\n }\n _ProcessIncludes(sourceCode, options, codeWithIncludes => {\n if (options.processCodeAfterIncludes) {\n codeWithIncludes = options.processCodeAfterIncludes(options.isFragment ? \"fragment\" : \"vertex\", codeWithIncludes, options.defines);\n }\n const migratedCode = _ApplyPreProcessing(codeWithIncludes, options, engine);\n callback(migratedCode, codeWithIncludes);\n });\n}\n/** @internal */\nexport function Finalize(vertexCode, fragmentCode, options) {\n if (!options.processor || !options.processor.finalizeShaders) {\n return {\n vertexCode,\n fragmentCode\n };\n }\n return options.processor.finalizeShaders(vertexCode, fragmentCode, options.processingContext);\n}\nfunction _ProcessPrecision(source, options) {\n var _options$processor3;\n if ((_options$processor3 = options.processor) !== null && _options$processor3 !== void 0 && _options$processor3.noPrecision) {\n return source;\n }\n const shouldUseHighPrecisionShader = options.shouldUseHighPrecisionShader;\n if (source.indexOf(\"precision highp float\") === -1) {\n if (!shouldUseHighPrecisionShader) {\n source = \"precision mediump float;\\n\" + source;\n } else {\n source = \"precision highp float;\\n\" + source;\n }\n } else {\n if (!shouldUseHighPrecisionShader) {\n // Moving highp to mediump\n source = source.replace(\"precision highp float\", \"precision mediump float\");\n }\n }\n return source;\n}\nfunction _ExtractOperation(expression) {\n const regex = /defined\\((.+)\\)/;\n const match = regex.exec(expression);\n if (match && match.length) {\n return new ShaderDefineIsDefinedOperator(match[1].trim(), expression[0] === \"!\");\n }\n const operators = [\"==\", \"!=\", \">=\", \"<=\", \"<\", \">\"];\n let operator = \"\";\n let indexOperator = 0;\n for (operator of operators) {\n indexOperator = expression.indexOf(operator);\n if (indexOperator > -1) {\n break;\n }\n }\n if (indexOperator === -1) {\n return new ShaderDefineIsDefinedOperator(expression);\n }\n const define = expression.substring(0, indexOperator).trim();\n const value = expression.substring(indexOperator + operator.length).trim();\n return new ShaderDefineArithmeticOperator(define, operator, value);\n}\nfunction _BuildSubExpression(expression) {\n expression = expression.replace(regexSE, \"defined[$1]\");\n const postfix = ShaderDefineExpression.infixToPostfix(expression);\n const stack = [];\n for (const c of postfix) {\n if (c !== \"||\" && c !== \"&&\") {\n stack.push(c);\n } else if (stack.length >= 2) {\n let v1 = stack[stack.length - 1],\n v2 = stack[stack.length - 2];\n stack.length -= 2;\n const operator = c == \"&&\" ? new ShaderDefineAndOperator() : new ShaderDefineOrOperator();\n if (typeof v1 === \"string\") {\n v1 = v1.replace(regexSERevert, \"defined($1)\");\n }\n if (typeof v2 === \"string\") {\n v2 = v2.replace(regexSERevert, \"defined($1)\");\n }\n operator.leftOperand = typeof v2 === \"string\" ? _ExtractOperation(v2) : v2;\n operator.rightOperand = typeof v1 === \"string\" ? _ExtractOperation(v1) : v1;\n stack.push(operator);\n }\n }\n let result = stack[stack.length - 1];\n if (typeof result === \"string\") {\n result = result.replace(regexSERevert, \"defined($1)\");\n }\n // note: stack.length !== 1 if there was an error in the parsing\n return typeof result === \"string\" ? _ExtractOperation(result) : result;\n}\nfunction _BuildExpression(line, start) {\n const node = new ShaderCodeTestNode();\n const command = line.substring(0, start);\n let expression = line.substring(start);\n expression = expression.substring(0, (expression.indexOf(\"//\") + 1 || expression.length + 1) - 1).trim();\n if (command === \"#ifdef\") {\n node.testExpression = new ShaderDefineIsDefinedOperator(expression);\n } else if (command === \"#ifndef\") {\n node.testExpression = new ShaderDefineIsDefinedOperator(expression, true);\n } else {\n node.testExpression = _BuildSubExpression(expression);\n }\n return node;\n}\nfunction _MoveCursorWithinIf(cursor, rootNode, ifNode) {\n let line = cursor.currentLine;\n while (_MoveCursor(cursor, ifNode)) {\n line = cursor.currentLine;\n const first5 = line.substring(0, 5).toLowerCase();\n if (first5 === \"#else\") {\n const elseNode = new ShaderCodeNode();\n rootNode.children.push(elseNode);\n _MoveCursor(cursor, elseNode);\n return;\n } else if (first5 === \"#elif\") {\n const elifNode = _BuildExpression(line, 5);\n rootNode.children.push(elifNode);\n ifNode = elifNode;\n }\n }\n}\nfunction _MoveCursor(cursor, rootNode) {\n while (cursor.canRead) {\n cursor.lineIndex++;\n const line = cursor.currentLine;\n if (line.indexOf(\"#\") >= 0) {\n const matches = _MoveCursorRegex.exec(line);\n if (matches && matches.length) {\n const keyword = matches[0];\n switch (keyword) {\n case \"#ifdef\":\n {\n const newRootNode = new ShaderCodeConditionNode();\n rootNode.children.push(newRootNode);\n const ifNode = _BuildExpression(line, 6);\n newRootNode.children.push(ifNode);\n _MoveCursorWithinIf(cursor, newRootNode, ifNode);\n break;\n }\n case \"#else\":\n case \"#elif\":\n return true;\n case \"#endif\":\n return false;\n case \"#ifndef\":\n {\n const newRootNode = new ShaderCodeConditionNode();\n rootNode.children.push(newRootNode);\n const ifNode = _BuildExpression(line, 7);\n newRootNode.children.push(ifNode);\n _MoveCursorWithinIf(cursor, newRootNode, ifNode);\n break;\n }\n case \"#if\":\n {\n const newRootNode = new ShaderCodeConditionNode();\n const ifNode = _BuildExpression(line, 3);\n rootNode.children.push(newRootNode);\n newRootNode.children.push(ifNode);\n _MoveCursorWithinIf(cursor, newRootNode, ifNode);\n break;\n }\n }\n continue;\n }\n }\n const newNode = new ShaderCodeNode();\n newNode.line = line;\n rootNode.children.push(newNode);\n // Detect additional defines\n if (line[0] === \"#\" && line[1] === \"d\") {\n const split = line.replace(\";\", \"\").split(\" \");\n newNode.additionalDefineKey = split[1];\n if (split.length === 3) {\n newNode.additionalDefineValue = split[2];\n }\n }\n }\n return false;\n}\nfunction _EvaluatePreProcessors(sourceCode, preprocessors, options) {\n const rootNode = new ShaderCodeNode();\n const cursor = new ShaderCodeCursor();\n cursor.lineIndex = -1;\n cursor.lines = sourceCode.split(\"\\n\");\n // Decompose (We keep it in 2 steps so it is easier to maintain and perf hit is insignificant)\n _MoveCursor(cursor, rootNode);\n // Recompose\n return rootNode.process(preprocessors, options);\n}\nfunction _PreparePreProcessors(options, engine) {\n var _options$processor4;\n const defines = options.defines;\n const preprocessors = {};\n for (const define of defines) {\n const keyValue = define.replace(\"#define\", \"\").replace(\";\", \"\").trim();\n const split = keyValue.split(\" \");\n preprocessors[split[0]] = split.length > 1 ? split[1] : \"\";\n }\n if (((_options$processor4 = options.processor) === null || _options$processor4 === void 0 ? void 0 : _options$processor4.shaderLanguage) === 0 /* ShaderLanguage.GLSL */) {\n preprocessors[\"GL_ES\"] = \"true\";\n }\n preprocessors[\"__VERSION__\"] = options.version;\n preprocessors[options.platformName] = \"true\";\n _getGlobalDefines(preprocessors, engine === null || engine === void 0 ? void 0 : engine.isNDCHalfZRange, engine === null || engine === void 0 ? void 0 : engine.useReverseDepthBuffer, engine === null || engine === void 0 ? void 0 : engine.useExactSrgbConversions);\n return preprocessors;\n}\nfunction _ProcessShaderConversion(sourceCode, options, engine) {\n let preparedSourceCode = _ProcessPrecision(sourceCode, options);\n if (!options.processor) {\n return preparedSourceCode;\n }\n // Already converted\n if (options.processor.shaderLanguage === 0 /* ShaderLanguage.GLSL */ && preparedSourceCode.indexOf(\"#version 3\") !== -1) {\n preparedSourceCode = preparedSourceCode.replace(\"#version 300 es\", \"\");\n if (!options.processor.parseGLES3) {\n return preparedSourceCode;\n }\n }\n const defines = options.defines;\n const preprocessors = _PreparePreProcessors(options, engine);\n // General pre processing\n if (options.processor.preProcessor) {\n preparedSourceCode = options.processor.preProcessor(preparedSourceCode, defines, preprocessors, options.isFragment, options.processingContext);\n }\n preparedSourceCode = _EvaluatePreProcessors(preparedSourceCode, preprocessors, options);\n // Post processing\n if (options.processor.postProcessor) {\n preparedSourceCode = options.processor.postProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext, engine ? {\n drawBuffersExtensionDisabled: engine.getCaps().drawBuffersExtension ? false : true\n } : {});\n }\n // Inline functions tagged with #define inline\n if (engine !== null && engine !== void 0 && engine._features.needShaderCodeInlining) {\n preparedSourceCode = engine.inlineShaderCode(preparedSourceCode);\n }\n return preparedSourceCode;\n}\nfunction _ApplyPreProcessing(sourceCode, options, engine) {\n var _options$processor5, _options$processor6;\n let preparedSourceCode = sourceCode;\n const defines = options.defines;\n const preprocessors = _PreparePreProcessors(options, engine);\n // General pre processing\n if ((_options$processor5 = options.processor) !== null && _options$processor5 !== void 0 && _options$processor5.preProcessor) {\n preparedSourceCode = options.processor.preProcessor(preparedSourceCode, defines, preprocessors, options.isFragment, options.processingContext);\n }\n preparedSourceCode = _EvaluatePreProcessors(preparedSourceCode, preprocessors, options);\n // Post processing\n if ((_options$processor6 = options.processor) !== null && _options$processor6 !== void 0 && _options$processor6.postProcessor) {\n preparedSourceCode = options.processor.postProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext, engine ? {\n drawBuffersExtensionDisabled: engine.getCaps().drawBuffersExtension ? false : true\n } : {});\n }\n // Inline functions tagged with #define inline\n if (engine._features.needShaderCodeInlining) {\n preparedSourceCode = engine.inlineShaderCode(preparedSourceCode);\n }\n return preparedSourceCode;\n}\n/** @internal */\nexport function _ProcessIncludes(sourceCode, options, callback) {\n reusableMatches.length = 0;\n let match;\n // stay back-compat to the old matchAll syntax\n while ((match = regexShaderInclude.exec(sourceCode)) !== null) {\n reusableMatches.push(match);\n }\n let returnValue = String(sourceCode);\n let parts = [sourceCode];\n let keepProcessing = false;\n for (const match of reusableMatches) {\n let includeFile = match[1];\n // Uniform declaration\n if (includeFile.indexOf(\"__decl__\") !== -1) {\n includeFile = includeFile.replace(regexShaderDecl, \"\");\n if (options.supportsUniformBuffers) {\n includeFile = includeFile.replace(\"Vertex\", \"Ubo\").replace(\"Fragment\", \"Ubo\");\n }\n includeFile = includeFile + \"Declaration\";\n }\n if (options.includesShadersStore[includeFile]) {\n // Substitution\n let includeContent = options.includesShadersStore[includeFile];\n if (match[2]) {\n const splits = match[3].split(\",\");\n for (let index = 0; index < splits.length; index += 2) {\n const source = new RegExp(splits[index], \"g\");\n const dest = splits[index + 1];\n includeContent = includeContent.replace(source, dest);\n }\n }\n if (match[4]) {\n const indexString = match[5];\n if (indexString.indexOf(\"..\") !== -1) {\n const indexSplits = indexString.split(\"..\");\n const minIndex = parseInt(indexSplits[0]);\n let maxIndex = parseInt(indexSplits[1]);\n let sourceIncludeContent = includeContent.slice(0);\n includeContent = \"\";\n if (isNaN(maxIndex)) {\n maxIndex = options.indexParameters[indexSplits[1]];\n }\n for (let i = minIndex; i < maxIndex; i++) {\n if (!options.supportsUniformBuffers) {\n // Ubo replacement\n sourceIncludeContent = sourceIncludeContent.replace(regexLightX, (str, p1) => {\n return p1 + \"{X}\";\n });\n }\n includeContent += sourceIncludeContent.replace(regexX, i.toString()) + \"\\n\";\n }\n } else {\n if (!options.supportsUniformBuffers) {\n // Ubo replacement\n includeContent = includeContent.replace(regexLightX, (str, p1) => {\n return p1 + \"{X}\";\n });\n }\n includeContent = includeContent.replace(regexX, indexString);\n }\n }\n // Replace\n // Split all parts on match[0] and intersperse the parts with the include content\n const newParts = [];\n for (const part of parts) {\n const splitPart = part.split(match[0]);\n for (let i = 0; i < splitPart.length - 1; i++) {\n newParts.push(splitPart[i]);\n newParts.push(includeContent);\n }\n newParts.push(splitPart[splitPart.length - 1]);\n }\n parts = newParts;\n keepProcessing = keepProcessing || includeContent.indexOf(\"#include<\") >= 0 || includeContent.indexOf(\"#include <\") >= 0;\n } else {\n const includeShaderUrl = options.shadersRepository + \"ShadersInclude/\" + includeFile + \".fx\";\n _functionContainer.loadFile(includeShaderUrl, fileContent => {\n options.includesShadersStore[includeFile] = fileContent;\n _ProcessIncludes(parts.join(\"\"), options, callback);\n });\n return;\n }\n }\n reusableMatches.length = 0;\n returnValue = parts.join(\"\");\n if (keepProcessing) {\n _ProcessIncludes(returnValue.toString(), options, callback);\n } else {\n callback(returnValue);\n }\n}\n/** @internal */\nexport const _functionContainer = {\n /**\n * Loads a file from a url\n * @param url url to load\n * @param onSuccess callback called when the file successfully loads\n * @param onProgress callback called while file is loading (if the server supports this mode)\n * @param offlineProvider defines the offline provider for caching\n * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer\n * @param onError callback called when the file fails to load\n * @returns a file request object\n * @internal\n */\n loadFile: (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) => {\n throw _WarnImport(\"FileTools\");\n }\n};","map":{"version":3,"names":["ShaderCodeNode","ShaderCodeCursor","ShaderCodeConditionNode","ShaderCodeTestNode","ShaderDefineIsDefinedOperator","ShaderDefineOrOperator","ShaderDefineAndOperator","ShaderDefineExpression","ShaderDefineArithmeticOperator","_WarnImport","_getGlobalDefines","regexSE","regexSERevert","regexShaderInclude","regexShaderDecl","regexLightX","regexX","reusableMatches","_MoveCursorRegex","Initialize","options","processor","initializeShaders","processingContext","Process","sourceCode","callback","engine","_options$processor","preProcessShaderCode","isFragment","_ProcessIncludes","codeWithIncludes","processCodeAfterIncludes","defines","migratedCode","_ProcessShaderConversion","PreProcess","_options$processor2","_ApplyPreProcessing","Finalize","vertexCode","fragmentCode","finalizeShaders","_ProcessPrecision","source","_options$processor3","noPrecision","shouldUseHighPrecisionShader","indexOf","replace","_ExtractOperation","expression","regex","match","exec","length","trim","operators","operator","indexOperator","define","substring","value","_BuildSubExpression","postfix","infixToPostfix","stack","c","push","v1","v2","leftOperand","rightOperand","result","_BuildExpression","line","start","node","command","testExpression","_MoveCursorWithinIf","cursor","rootNode","ifNode","currentLine","_MoveCursor","first5","toLowerCase","elseNode","children","elifNode","canRead","lineIndex","matches","keyword","newRootNode","newNode","split","additionalDefineKey","additionalDefineValue","_EvaluatePreProcessors","preprocessors","lines","process","_PreparePreProcessors","_options$processor4","keyValue","shaderLanguage","version","platformName","isNDCHalfZRange","useReverseDepthBuffer","useExactSrgbConversions","preparedSourceCode","parseGLES3","preProcessor","postProcessor","drawBuffersExtensionDisabled","getCaps","drawBuffersExtension","_features","needShaderCodeInlining","inlineShaderCode","_options$processor5","_options$processor6","returnValue","String","parts","keepProcessing","includeFile","supportsUniformBuffers","includesShadersStore","includeContent","splits","index","RegExp","dest","indexString","indexSplits","minIndex","parseInt","maxIndex","sourceIncludeContent","slice","isNaN","indexParameters","i","str","p1","toString","newParts","part","splitPart","includeShaderUrl","shadersRepository","_functionContainer","loadFile","fileContent","join","url","onSuccess","onProgress","offlineProvider","useArrayBuffer","onError"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/Processors/shaderProcessor.js"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { ShaderCodeNode } from \"./shaderCodeNode.js\";\nimport { ShaderCodeCursor } from \"./shaderCodeCursor.js\";\nimport { ShaderCodeConditionNode } from \"./shaderCodeConditionNode.js\";\nimport { ShaderCodeTestNode } from \"./shaderCodeTestNode.js\";\nimport { ShaderDefineIsDefinedOperator } from \"./Expressions/Operators/shaderDefineIsDefinedOperator.js\";\nimport { ShaderDefineOrOperator } from \"./Expressions/Operators/shaderDefineOrOperator.js\";\nimport { ShaderDefineAndOperator } from \"./Expressions/Operators/shaderDefineAndOperator.js\";\nimport { ShaderDefineExpression } from \"./Expressions/shaderDefineExpression.js\";\nimport { ShaderDefineArithmeticOperator } from \"./Expressions/Operators/shaderDefineArithmeticOperator.js\";\nimport { _WarnImport } from \"../../Misc/devTools.js\";\nimport { _getGlobalDefines } from \"../abstractEngine.functions.js\";\nconst regexSE = /defined\\s*?\\((.+?)\\)/g;\nconst regexSERevert = /defined\\s*?\\[(.+?)\\]/g;\nconst regexShaderInclude = /#include\\s?<(.+)>(\\((.*)\\))*(\\[(.*)\\])*/g;\nconst regexShaderDecl = /__decl__/;\nconst regexLightX = /light\\{X\\}.(\\w*)/g;\nconst regexX = /\\{X\\}/g;\nconst reusableMatches = [];\nconst _MoveCursorRegex = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;\n/** @internal */\nexport function Initialize(options) {\n if (options.processor && options.processor.initializeShaders) {\n options.processor.initializeShaders(options.processingContext);\n }\n}\n/** @internal */\nexport function Process(sourceCode, options, callback, engine) {\n if (options.processor?.preProcessShaderCode) {\n sourceCode = options.processor.preProcessShaderCode(sourceCode, options.isFragment);\n }\n _ProcessIncludes(sourceCode, options, (codeWithIncludes) => {\n if (options.processCodeAfterIncludes) {\n codeWithIncludes = options.processCodeAfterIncludes(options.isFragment ? \"fragment\" : \"vertex\", codeWithIncludes, options.defines);\n }\n const migratedCode = _ProcessShaderConversion(codeWithIncludes, options, engine);\n callback(migratedCode, codeWithIncludes);\n });\n}\n/** @internal */\nexport function PreProcess(sourceCode, options, callback, engine) {\n if (options.processor?.preProcessShaderCode) {\n sourceCode = options.processor.preProcessShaderCode(sourceCode, options.isFragment);\n }\n _ProcessIncludes(sourceCode, options, (codeWithIncludes) => {\n if (options.processCodeAfterIncludes) {\n codeWithIncludes = options.processCodeAfterIncludes(options.isFragment ? \"fragment\" : \"vertex\", codeWithIncludes, options.defines);\n }\n const migratedCode = _ApplyPreProcessing(codeWithIncludes, options, engine);\n callback(migratedCode, codeWithIncludes);\n });\n}\n/** @internal */\nexport function Finalize(vertexCode, fragmentCode, options) {\n if (!options.processor || !options.processor.finalizeShaders) {\n return { vertexCode, fragmentCode };\n }\n return options.processor.finalizeShaders(vertexCode, fragmentCode, options.processingContext);\n}\nfunction _ProcessPrecision(source, options) {\n if (options.processor?.noPrecision) {\n return source;\n }\n const shouldUseHighPrecisionShader = options.shouldUseHighPrecisionShader;\n if (source.indexOf(\"precision highp float\") === -1) {\n if (!shouldUseHighPrecisionShader) {\n source = \"precision mediump float;\\n\" + source;\n }\n else {\n source = \"precision highp float;\\n\" + source;\n }\n }\n else {\n if (!shouldUseHighPrecisionShader) {\n // Moving highp to mediump\n source = source.replace(\"precision highp float\", \"precision mediump float\");\n }\n }\n return source;\n}\nfunction _ExtractOperation(expression) {\n const regex = /defined\\((.+)\\)/;\n const match = regex.exec(expression);\n if (match && match.length) {\n return new ShaderDefineIsDefinedOperator(match[1].trim(), expression[0] === \"!\");\n }\n const operators = [\"==\", \"!=\", \">=\", \"<=\", \"<\", \">\"];\n let operator = \"\";\n let indexOperator = 0;\n for (operator of operators) {\n indexOperator = expression.indexOf(operator);\n if (indexOperator > -1) {\n break;\n }\n }\n if (indexOperator === -1) {\n return new ShaderDefineIsDefinedOperator(expression);\n }\n const define = expression.substring(0, indexOperator).trim();\n const value = expression.substring(indexOperator + operator.length).trim();\n return new ShaderDefineArithmeticOperator(define, operator, value);\n}\nfunction _BuildSubExpression(expression) {\n expression = expression.replace(regexSE, \"defined[$1]\");\n const postfix = ShaderDefineExpression.infixToPostfix(expression);\n const stack = [];\n for (const c of postfix) {\n if (c !== \"||\" && c !== \"&&\") {\n stack.push(c);\n }\n else if (stack.length >= 2) {\n let v1 = stack[stack.length - 1], v2 = stack[stack.length - 2];\n stack.length -= 2;\n const operator = c == \"&&\" ? new ShaderDefineAndOperator() : new ShaderDefineOrOperator();\n if (typeof v1 === \"string\") {\n v1 = v1.replace(regexSERevert, \"defined($1)\");\n }\n if (typeof v2 === \"string\") {\n v2 = v2.replace(regexSERevert, \"defined($1)\");\n }\n operator.leftOperand = typeof v2 === \"string\" ? _ExtractOperation(v2) : v2;\n operator.rightOperand = typeof v1 === \"string\" ? _ExtractOperation(v1) : v1;\n stack.push(operator);\n }\n }\n let result = stack[stack.length - 1];\n if (typeof result === \"string\") {\n result = result.replace(regexSERevert, \"defined($1)\");\n }\n // note: stack.length !== 1 if there was an error in the parsing\n return typeof result === \"string\" ? _ExtractOperation(result) : result;\n}\nfunction _BuildExpression(line, start) {\n const node = new ShaderCodeTestNode();\n const command = line.substring(0, start);\n let expression = line.substring(start);\n expression = expression.substring(0, (expression.indexOf(\"//\") + 1 || expression.length + 1) - 1).trim();\n if (command === \"#ifdef\") {\n node.testExpression = new ShaderDefineIsDefinedOperator(expression);\n }\n else if (command === \"#ifndef\") {\n node.testExpression = new ShaderDefineIsDefinedOperator(expression, true);\n }\n else {\n node.testExpression = _BuildSubExpression(expression);\n }\n return node;\n}\nfunction _MoveCursorWithinIf(cursor, rootNode, ifNode) {\n let line = cursor.currentLine;\n while (_MoveCursor(cursor, ifNode)) {\n line = cursor.currentLine;\n const first5 = line.substring(0, 5).toLowerCase();\n if (first5 === \"#else\") {\n const elseNode = new ShaderCodeNode();\n rootNode.children.push(elseNode);\n _MoveCursor(cursor, elseNode);\n return;\n }\n else if (first5 === \"#elif\") {\n const elifNode = _BuildExpression(line, 5);\n rootNode.children.push(elifNode);\n ifNode = elifNode;\n }\n }\n}\nfunction _MoveCursor(cursor, rootNode) {\n while (cursor.canRead) {\n cursor.lineIndex++;\n const line = cursor.currentLine;\n if (line.indexOf(\"#\") >= 0) {\n const matches = _MoveCursorRegex.exec(line);\n if (matches && matches.length) {\n const keyword = matches[0];\n switch (keyword) {\n case \"#ifdef\": {\n const newRootNode = new ShaderCodeConditionNode();\n rootNode.children.push(newRootNode);\n const ifNode = _BuildExpression(line, 6);\n newRootNode.children.push(ifNode);\n _MoveCursorWithinIf(cursor, newRootNode, ifNode);\n break;\n }\n case \"#else\":\n case \"#elif\":\n return true;\n case \"#endif\":\n return false;\n case \"#ifndef\": {\n const newRootNode = new ShaderCodeConditionNode();\n rootNode.children.push(newRootNode);\n const ifNode = _BuildExpression(line, 7);\n newRootNode.children.push(ifNode);\n _MoveCursorWithinIf(cursor, newRootNode, ifNode);\n break;\n }\n case \"#if\": {\n const newRootNode = new ShaderCodeConditionNode();\n const ifNode = _BuildExpression(line, 3);\n rootNode.children.push(newRootNode);\n newRootNode.children.push(ifNode);\n _MoveCursorWithinIf(cursor, newRootNode, ifNode);\n break;\n }\n }\n continue;\n }\n }\n const newNode = new ShaderCodeNode();\n newNode.line = line;\n rootNode.children.push(newNode);\n // Detect additional defines\n if (line[0] === \"#\" && line[1] === \"d\") {\n const split = line.replace(\";\", \"\").split(\" \");\n newNode.additionalDefineKey = split[1];\n if (split.length === 3) {\n newNode.additionalDefineValue = split[2];\n }\n }\n }\n return false;\n}\nfunction _EvaluatePreProcessors(sourceCode, preprocessors, options) {\n const rootNode = new ShaderCodeNode();\n const cursor = new ShaderCodeCursor();\n cursor.lineIndex = -1;\n cursor.lines = sourceCode.split(\"\\n\");\n // Decompose (We keep it in 2 steps so it is easier to maintain and perf hit is insignificant)\n _MoveCursor(cursor, rootNode);\n // Recompose\n return rootNode.process(preprocessors, options);\n}\nfunction _PreparePreProcessors(options, engine) {\n const defines = options.defines;\n const preprocessors = {};\n for (const define of defines) {\n const keyValue = define.replace(\"#define\", \"\").replace(\";\", \"\").trim();\n const split = keyValue.split(\" \");\n preprocessors[split[0]] = split.length > 1 ? split[1] : \"\";\n }\n if (options.processor?.shaderLanguage === 0 /* ShaderLanguage.GLSL */) {\n preprocessors[\"GL_ES\"] = \"true\";\n }\n preprocessors[\"__VERSION__\"] = options.version;\n preprocessors[options.platformName] = \"true\";\n _getGlobalDefines(preprocessors, engine?.isNDCHalfZRange, engine?.useReverseDepthBuffer, engine?.useExactSrgbConversions);\n return preprocessors;\n}\nfunction _ProcessShaderConversion(sourceCode, options, engine) {\n let preparedSourceCode = _ProcessPrecision(sourceCode, options);\n if (!options.processor) {\n return preparedSourceCode;\n }\n // Already converted\n if (options.processor.shaderLanguage === 0 /* ShaderLanguage.GLSL */ && preparedSourceCode.indexOf(\"#version 3\") !== -1) {\n preparedSourceCode = preparedSourceCode.replace(\"#version 300 es\", \"\");\n if (!options.processor.parseGLES3) {\n return preparedSourceCode;\n }\n }\n const defines = options.defines;\n const preprocessors = _PreparePreProcessors(options, engine);\n // General pre processing\n if (options.processor.preProcessor) {\n preparedSourceCode = options.processor.preProcessor(preparedSourceCode, defines, preprocessors, options.isFragment, options.processingContext);\n }\n preparedSourceCode = _EvaluatePreProcessors(preparedSourceCode, preprocessors, options);\n // Post processing\n if (options.processor.postProcessor) {\n preparedSourceCode = options.processor.postProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext, engine\n ? {\n drawBuffersExtensionDisabled: engine.getCaps().drawBuffersExtension ? false : true,\n }\n : {});\n }\n // Inline functions tagged with #define inline\n if (engine?._features.needShaderCodeInlining) {\n preparedSourceCode = engine.inlineShaderCode(preparedSourceCode);\n }\n return preparedSourceCode;\n}\nfunction _ApplyPreProcessing(sourceCode, options, engine) {\n let preparedSourceCode = sourceCode;\n const defines = options.defines;\n const preprocessors = _PreparePreProcessors(options, engine);\n // General pre processing\n if (options.processor?.preProcessor) {\n preparedSourceCode = options.processor.preProcessor(preparedSourceCode, defines, preprocessors, options.isFragment, options.processingContext);\n }\n preparedSourceCode = _EvaluatePreProcessors(preparedSourceCode, preprocessors, options);\n // Post processing\n if (options.processor?.postProcessor) {\n preparedSourceCode = options.processor.postProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext, engine\n ? {\n drawBuffersExtensionDisabled: engine.getCaps().drawBuffersExtension ? false : true,\n }\n : {});\n }\n // Inline functions tagged with #define inline\n if (engine._features.needShaderCodeInlining) {\n preparedSourceCode = engine.inlineShaderCode(preparedSourceCode);\n }\n return preparedSourceCode;\n}\n/** @internal */\nexport function _ProcessIncludes(sourceCode, options, callback) {\n reusableMatches.length = 0;\n let match;\n // stay back-compat to the old matchAll syntax\n while ((match = regexShaderInclude.exec(sourceCode)) !== null) {\n reusableMatches.push(match);\n }\n let returnValue = String(sourceCode);\n let parts = [sourceCode];\n let keepProcessing = false;\n for (const match of reusableMatches) {\n let includeFile = match[1];\n // Uniform declaration\n if (includeFile.indexOf(\"__decl__\") !== -1) {\n includeFile = includeFile.replace(regexShaderDecl, \"\");\n if (options.supportsUniformBuffers) {\n includeFile = includeFile.replace(\"Vertex\", \"Ubo\").replace(\"Fragment\", \"Ubo\");\n }\n includeFile = includeFile + \"Declaration\";\n }\n if (options.includesShadersStore[includeFile]) {\n // Substitution\n let includeContent = options.includesShadersStore[includeFile];\n if (match[2]) {\n const splits = match[3].split(\",\");\n for (let index = 0; index < splits.length; index += 2) {\n const source = new RegExp(splits[index], \"g\");\n const dest = splits[index + 1];\n includeContent = includeContent.replace(source, dest);\n }\n }\n if (match[4]) {\n const indexString = match[5];\n if (indexString.indexOf(\"..\") !== -1) {\n const indexSplits = indexString.split(\"..\");\n const minIndex = parseInt(indexSplits[0]);\n let maxIndex = parseInt(indexSplits[1]);\n let sourceIncludeContent = includeContent.slice(0);\n includeContent = \"\";\n if (isNaN(maxIndex)) {\n maxIndex = options.indexParameters[indexSplits[1]];\n }\n for (let i = minIndex; i < maxIndex; i++) {\n if (!options.supportsUniformBuffers) {\n // Ubo replacement\n sourceIncludeContent = sourceIncludeContent.replace(regexLightX, (str, p1) => {\n return p1 + \"{X}\";\n });\n }\n includeContent += sourceIncludeContent.replace(regexX, i.toString()) + \"\\n\";\n }\n }\n else {\n if (!options.supportsUniformBuffers) {\n // Ubo replacement\n includeContent = includeContent.replace(regexLightX, (str, p1) => {\n return p1 + \"{X}\";\n });\n }\n includeContent = includeContent.replace(regexX, indexString);\n }\n }\n // Replace\n // Split all parts on match[0] and intersperse the parts with the include content\n const newParts = [];\n for (const part of parts) {\n const splitPart = part.split(match[0]);\n for (let i = 0; i < splitPart.length - 1; i++) {\n newParts.push(splitPart[i]);\n newParts.push(includeContent);\n }\n newParts.push(splitPart[splitPart.length - 1]);\n }\n parts = newParts;\n keepProcessing = keepProcessing || includeContent.indexOf(\"#include<\") >= 0 || includeContent.indexOf(\"#include <\") >= 0;\n }\n else {\n const includeShaderUrl = options.shadersRepository + \"ShadersInclude/\" + includeFile + \".fx\";\n _functionContainer.loadFile(includeShaderUrl, (fileContent) => {\n options.includesShadersStore[includeFile] = fileContent;\n _ProcessIncludes(parts.join(\"\"), options, callback);\n });\n return;\n }\n }\n reusableMatches.length = 0;\n returnValue = parts.join(\"\");\n if (keepProcessing) {\n _ProcessIncludes(returnValue.toString(), options, callback);\n }\n else {\n callback(returnValue);\n }\n}\n/** @internal */\nexport const _functionContainer = {\n /**\n * Loads a file from a url\n * @param url url to load\n * @param onSuccess callback called when the file successfully loads\n * @param onProgress callback called while file is loading (if the server supports this mode)\n * @param offlineProvider defines the offline provider for caching\n * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer\n * @param onError callback called when the file fails to load\n * @returns a file request object\n * @internal\n */\n loadFile: (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) => {\n throw _WarnImport(\"FileTools\");\n },\n};\n"],"mappings":"AAAA;AACA,SAASA,cAAc,QAAQ,qBAAqB;AACpD,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,6BAA6B,QAAQ,0DAA0D;AACxG,SAASC,sBAAsB,QAAQ,mDAAmD;AAC1F,SAASC,uBAAuB,QAAQ,oDAAoD;AAC5F,SAASC,sBAAsB,QAAQ,yCAAyC;AAChF,SAASC,8BAA8B,QAAQ,2DAA2D;AAC1G,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,MAAMC,OAAO,GAAG,uBAAuB;AACvC,MAAMC,aAAa,GAAG,uBAAuB;AAC7C,MAAMC,kBAAkB,GAAG,0CAA0C;AACrE,MAAMC,eAAe,GAAG,UAAU;AAClC,MAAMC,WAAW,GAAG,mBAAmB;AACvC,MAAMC,MAAM,GAAG,QAAQ;AACvB,MAAMC,eAAe,GAAG,EAAE;AAC1B,MAAMC,gBAAgB,GAAG,mDAAmD;AAC5E;AACA,OAAO,SAASC,UAAUA,CAACC,OAAO,EAAE;EAChC,IAAIA,OAAO,CAACC,SAAS,IAAID,OAAO,CAACC,SAAS,CAACC,iBAAiB,EAAE;IAC1DF,OAAO,CAACC,SAAS,CAACC,iBAAiB,CAACF,OAAO,CAACG,iBAAiB,CAAC;EAClE;AACJ;AACA;AACA,OAAO,SAASC,OAAOA,CAACC,UAAU,EAAEL,OAAO,EAAEM,QAAQ,EAAEC,MAAM,EAAE;EAAA,IAAAC,kBAAA;EAC3D,KAAAA,kBAAA,GAAIR,OAAO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