1 |
- {"ast":null,"code":"import { Color4 } from \"../Maths/math.color.js\";\n/** Class used to store color4 gradient */\nexport class ColorGradient {\n /**\n * Creates a new color4 gradient\n * @param gradient gets or sets the gradient value (between 0 and 1)\n * @param color1 gets or sets first associated color\n * @param color2 gets or sets first second color\n */\n constructor(\n /**\n * Gets or sets the gradient value (between 0 and 1)\n */\n gradient,\n /**\n * Gets or sets first associated color\n */\n color1,\n /**\n * Gets or sets second associated color\n */\n color2) {\n this.gradient = gradient;\n this.color1 = color1;\n this.color2 = color2;\n }\n /**\n * Will get a color picked randomly between color1 and color2.\n * If color2 is undefined then color1 will be used\n * @param result defines the target Color4 to store the result in\n */\n getColorToRef(result) {\n if (!this.color2) {\n result.copyFrom(this.color1);\n return;\n }\n Color4.LerpToRef(this.color1, this.color2, Math.random(), result);\n }\n}\n/** Class used to store color 3 gradient */\nexport class Color3Gradient {\n /**\n * Creates a new color3 gradient\n * @param gradient gets or sets the gradient value (between 0 and 1)\n * @param color gets or sets associated color\n */\n constructor(\n /**\n * Gets or sets the gradient value (between 0 and 1)\n */\n gradient,\n /**\n * Gets or sets the associated color\n */\n color) {\n this.gradient = gradient;\n this.color = color;\n }\n}\n/** Class used to store factor gradient */\nexport class FactorGradient {\n /**\n * Creates a new factor gradient\n * @param gradient gets or sets the gradient value (between 0 and 1)\n * @param factor1 gets or sets first associated factor\n * @param factor2 gets or sets second associated factor\n */\n constructor(\n /**\n * Gets or sets the gradient value (between 0 and 1)\n */\n gradient,\n /**\n * Gets or sets first associated factor\n */\n factor1,\n /**\n * Gets or sets second associated factor\n */\n factor2) {\n this.gradient = gradient;\n this.factor1 = factor1;\n this.factor2 = factor2;\n }\n /**\n * Will get a number picked randomly between factor1 and factor2.\n * If factor2 is undefined then factor1 will be used\n * @returns the picked number\n */\n getFactor() {\n if (this.factor2 === undefined || this.factor2 === this.factor1) {\n return this.factor1;\n }\n return this.factor1 + (this.factor2 - this.factor1) * Math.random();\n }\n}\n/**\n * Helper used to simplify some generic gradient tasks\n */\nexport class GradientHelper {\n /**\n * Gets the current gradient from an array of IValueGradient\n * @param ratio defines the current ratio to get\n * @param gradients defines the array of IValueGradient\n * @param updateFunc defines the callback function used to get the final value from the selected gradients\n */\n static GetCurrentGradient(ratio, gradients, updateFunc) {\n // Use last index if over\n if (gradients[0].gradient > ratio) {\n updateFunc(gradients[0], gradients[0], 1.0);\n return;\n }\n for (let gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {\n const currentGradient = gradients[gradientIndex];\n const nextGradient = gradients[gradientIndex + 1];\n if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {\n const scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);\n updateFunc(currentGradient, nextGradient, scale);\n return;\n }\n }\n // Use last index if over\n const lastIndex = gradients.length - 1;\n updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);\n }\n}","map":{"version":3,"names":["Color4","ColorGradient","constructor","gradient","color1","color2","getColorToRef","result","copyFrom","LerpToRef","Math","random","Color3Gradient","color","FactorGradient","factor1","factor2","getFactor","undefined","GradientHelper","GetCurrentGradient","ratio","gradients","updateFunc","gradientIndex","length","currentGradient","nextGradient","scale","lastIndex"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Misc/gradients.js"],"sourcesContent":["import { Color4 } from \"../Maths/math.color.js\";\n/** Class used to store color4 gradient */\nexport class ColorGradient {\n /**\n * Creates a new color4 gradient\n * @param gradient gets or sets the gradient value (between 0 and 1)\n * @param color1 gets or sets first associated color\n * @param color2 gets or sets first second color\n */\n constructor(\n /**\n * Gets or sets the gradient value (between 0 and 1)\n */\n gradient, \n /**\n * Gets or sets first associated color\n */\n color1, \n /**\n * Gets or sets second associated color\n */\n color2) {\n this.gradient = gradient;\n this.color1 = color1;\n this.color2 = color2;\n }\n /**\n * Will get a color picked randomly between color1 and color2.\n * If color2 is undefined then color1 will be used\n * @param result defines the target Color4 to store the result in\n */\n getColorToRef(result) {\n if (!this.color2) {\n result.copyFrom(this.color1);\n return;\n }\n Color4.LerpToRef(this.color1, this.color2, Math.random(), result);\n }\n}\n/** Class used to store color 3 gradient */\nexport class Color3Gradient {\n /**\n * Creates a new color3 gradient\n * @param gradient gets or sets the gradient value (between 0 and 1)\n * @param color gets or sets associated color\n */\n constructor(\n /**\n * Gets or sets the gradient value (between 0 and 1)\n */\n gradient, \n /**\n * Gets or sets the associated color\n */\n color) {\n this.gradient = gradient;\n this.color = color;\n }\n}\n/** Class used to store factor gradient */\nexport class FactorGradient {\n /**\n * Creates a new factor gradient\n * @param gradient gets or sets the gradient value (between 0 and 1)\n * @param factor1 gets or sets first associated factor\n * @param factor2 gets or sets second associated factor\n */\n constructor(\n /**\n * Gets or sets the gradient value (between 0 and 1)\n */\n gradient, \n /**\n * Gets or sets first associated factor\n */\n factor1, \n /**\n * Gets or sets second associated factor\n */\n factor2) {\n this.gradient = gradient;\n this.factor1 = factor1;\n this.factor2 = factor2;\n }\n /**\n * Will get a number picked randomly between factor1 and factor2.\n * If factor2 is undefined then factor1 will be used\n * @returns the picked number\n */\n getFactor() {\n if (this.factor2 === undefined || this.factor2 === this.factor1) {\n return this.factor1;\n }\n return this.factor1 + (this.factor2 - this.factor1) * Math.random();\n }\n}\n/**\n * Helper used to simplify some generic gradient tasks\n */\nexport class GradientHelper {\n /**\n * Gets the current gradient from an array of IValueGradient\n * @param ratio defines the current ratio to get\n * @param gradients defines the array of IValueGradient\n * @param updateFunc defines the callback function used to get the final value from the selected gradients\n */\n static GetCurrentGradient(ratio, gradients, updateFunc) {\n // Use last index if over\n if (gradients[0].gradient > ratio) {\n updateFunc(gradients[0], gradients[0], 1.0);\n return;\n }\n for (let gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {\n const currentGradient = gradients[gradientIndex];\n const nextGradient = gradients[gradientIndex + 1];\n if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {\n const scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);\n updateFunc(currentGradient, nextGradient, scale);\n return;\n }\n }\n // Use last index if over\n const lastIndex = gradients.length - 1;\n updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C;AACA,OAAO,MAAMC,aAAa,CAAC;EACvB;AACJ;AACA;AACA;AACA;AACA;EACIC,WAAWA;EACX;AACJ;AACA;EACIC,QAAQ;EACR;AACJ;AACA;EACIC,MAAM;EACN;AACJ;AACA;EACIC,MAAM,EAAE;IACJ,IAAI,CAACF,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,MAAM,GAAGA,MAAM;EACxB;EACA;AACJ;AACA;AACA;AACA;EACIC,aAAaA,CAACC,MAAM,EAAE;IAClB,IAAI,CAAC,IAAI,CAACF,MAAM,EAAE;MACdE,MAAM,CAACC,QAAQ,CAAC,IAAI,CAACJ,MAAM,CAAC;MAC5B;IACJ;IACAJ,MAAM,CAACS,SAAS,CAAC,IAAI,CAACL,MAAM,EAAE,IAAI,CAACC,MAAM,EAAEK,IAAI,CAACC,MAAM,CAAC,CAAC,EAAEJ,MAAM,CAAC;EACrE;AACJ;AACA;AACA,OAAO,MAAMK,cAAc,CAAC;EACxB;AACJ;AACA;AACA;AACA;EACIV,WAAWA;EACX;AACJ;AACA;EACIC,QAAQ;EACR;AACJ;AACA;EACIU,KAAK,EAAE;IACH,IAAI,CAACV,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACU,KAAK,GAAGA,KAAK;EACtB;AACJ;AACA;AACA,OAAO,MAAMC,cAAc,CAAC;EACxB;AACJ;AACA;AACA;AACA;AACA;EACIZ,WAAWA;EACX;AACJ;AACA;EACIC,QAAQ;EACR;AACJ;AACA;EACIY,OAAO;EACP;AACJ;AACA;EACIC,OAAO,EAAE;IACL,IAAI,CAACb,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACY,OAAO,GAA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