{"ast":null,"code":"/**\n * Function indicating if a number is an exponent of 2\n * @param value defines the value to test\n * @returns true if the value is an exponent of 2\n */\nexport function IsExponentOfTwo(value) {\n let count = 1;\n do {\n count *= 2;\n } while (count < value);\n return count === value;\n}\n/**\n * Interpolates between a and b via alpha\n * @param a The lower value (returned when alpha = 0)\n * @param b The upper value (returned when alpha = 1)\n * @param alpha The interpolation-factor\n * @returns The mixed value\n */\nexport function Mix(a, b, alpha) {\n return a * (1 - alpha) + b * alpha;\n}\n/**\n * Find the nearest power of two.\n * @param x Number to start search from.\n * @returns Next nearest power of two.\n */\nexport function NearestPOT(x) {\n const c = CeilingPOT(x);\n const f = FloorPOT(x);\n return c - x > x - f ? f : c;\n}\n/**\n * Find the next highest power of two.\n * @param x Number to start search from.\n * @returns Next highest power of two.\n */\nexport function CeilingPOT(x) {\n x--;\n x |= x >> 1;\n x |= x >> 2;\n x |= x >> 4;\n x |= x >> 8;\n x |= x >> 16;\n x++;\n return x;\n}\n/**\n * Find the next lowest power of two.\n * @param x Number to start search from.\n * @returns Next lowest power of two.\n */\nexport function FloorPOT(x) {\n x = x | x >> 1;\n x = x | x >> 2;\n x = x | x >> 4;\n x = x | x >> 8;\n x = x | x >> 16;\n return x - (x >> 1);\n}\n/**\n * Get the closest exponent of two\n * @param value defines the value to approximate\n * @param max defines the maximum value to return\n * @param mode defines how to define the closest value\n * @returns closest exponent of two of the given value\n */\nexport function GetExponentOfTwo(value, max, mode = 2) {\n let pot;\n switch (mode) {\n case 1:\n pot = FloorPOT(value);\n break;\n case 2:\n pot = NearestPOT(value);\n break;\n case 3:\n default:\n pot = CeilingPOT(value);\n break;\n }\n return Math.min(pot, max);\n}","map":{"version":3,"names":["IsExponentOfTwo","value","count","Mix","a","b","alpha","NearestPOT","x","c","CeilingPOT","f","FloorPOT","GetExponentOfTwo","max","mode","pot","Math","min"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Misc/tools.functions.js"],"sourcesContent":["\n/**\n * Function indicating if a number is an exponent of 2\n * @param value defines the value to test\n * @returns true if the value is an exponent of 2\n */\nexport function IsExponentOfTwo(value) {\n let count = 1;\n do {\n count *= 2;\n } while (count < value);\n return count === value;\n}\n/**\n * Interpolates between a and b via alpha\n * @param a The lower value (returned when alpha = 0)\n * @param b The upper value (returned when alpha = 1)\n * @param alpha The interpolation-factor\n * @returns The mixed value\n */\nexport function Mix(a, b, alpha) {\n return a * (1 - alpha) + b * alpha;\n}\n/**\n * Find the nearest power of two.\n * @param x Number to start search from.\n * @returns Next nearest power of two.\n */\nexport function NearestPOT(x) {\n const c = CeilingPOT(x);\n const f = FloorPOT(x);\n return c - x > x - f ? f : c;\n}\n/**\n * Find the next highest power of two.\n * @param x Number to start search from.\n * @returns Next highest power of two.\n */\nexport function CeilingPOT(x) {\n x--;\n x |= x >> 1;\n x |= x >> 2;\n x |= x >> 4;\n x |= x >> 8;\n x |= x >> 16;\n x++;\n return x;\n}\n/**\n * Find the next lowest power of two.\n * @param x Number to start search from.\n * @returns Next lowest power of two.\n */\nexport function FloorPOT(x) {\n x = x | (x >> 1);\n x = x | (x >> 2);\n x = x | (x >> 4);\n x = x | (x >> 8);\n x = x | (x >> 16);\n return x - (x >> 1);\n}\n/**\n * Get the closest exponent of two\n * @param value defines the value to approximate\n * @param max defines the maximum value to return\n * @param mode defines how to define the closest value\n * @returns closest exponent of two of the given value\n */\nexport function GetExponentOfTwo(value, max, mode = 2) {\n let pot;\n switch (mode) {\n case 1:\n pot = FloorPOT(value);\n break;\n case 2:\n pot = NearestPOT(value);\n break;\n case 3:\n default:\n pot = CeilingPOT(value);\n break;\n }\n return Math.min(pot, max);\n}\n"],"mappings":"AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAeA,CAACC,KAAK,EAAE;EACnC,IAAIC,KAAK,GAAG,CAAC;EACb,GAAG;IACCA,KAAK,IAAI,CAAC;EACd,CAAC,QAAQA,KAAK,GAAGD,KAAK;EACtB,OAAOC,KAAK,KAAKD,K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