From 8f0beb80f9b64bc26656352ade6f6a319e8a4729 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 15:41:00 -0700 Subject: [PATCH 01/36] FastNoiseLite extension noise extension with the following: perlin cellular opensimplex2 opensimplex2S value cubic value --- docs/Corbnorb/noise.md | 70 + extensions/Corbnorb/noise.js | 3268 ++++++++++++++++++++++++++++++++++ extensions/extensions.json | 1 + 3 files changed, 3339 insertions(+) create mode 100644 docs/Corbnorb/noise.md create mode 100644 extensions/Corbnorb/noise.js diff --git a/docs/Corbnorb/noise.md b/docs/Corbnorb/noise.md new file mode 100644 index 0000000000..a21e061009 --- /dev/null +++ b/docs/Corbnorb/noise.md @@ -0,0 +1,70 @@ +# FastNoiseLite + +## Creator +I did not create the noise, I only turned it into an extension. +For the original project go here: +https://github.com/Auburn/FastNoiseLite +https://auburn.github.io/FastNoiseLite/ + +## How to use + +All features you can test on this website: https://auburn.github.io/FastNoiseLite/ +*except for easing and inverted* + +There are 2 blocks: + +1. [create noise](#createNoise) +2. [get noise](#getNoise) + +Although the [get noise](#getNoise) block has 3D coordinates, you can use just X and Y if you want 2D noise + +### Create Noise + +```scratch +create noise id: [myNoise] seed: (0) type: [Perlin v] octaves: (1) frequency: (0.01) fractal: [FBm v] inverted? (false v) easing: [Linear v] :: motion +``` +The create noise block is where you actually add a new noise function to use. + +**ID:** +the ID value is the name of this noise function, your noise must have a name for the [get noise](#getNoise) block to be able to use. + +**SEED:** +defaulted to 0, this is the seed for the noise. The same seed will always be the same noise, so if you want to use the same noise every time keep the seed the same. + +**TYPE:** +there are many types of noise, to get a better understanding of them go to this website: https://auburn.github.io/FastNoiseLite/ + +**OCTAVES:** +this describes how many different noises are layered onto eachother, every octave is a lower strength and size than the previous octave; gives more texture to your noise. + +**FREQUENCY:** +this is the size of the noise, higher the frequency, smaller the size of the noise. If working with pixels I'd suggest keeping frequency from 0.001 - 0.02, with other things just test values until something works + +**FRACTAL:** +None turns off octaves, FBm is normal noise and octaves, Ridged has octaves and changes the noise to give sharp ridges going through the noise instead of smooth hills, Ping Pong is similar to ridged except there are deep valleys between the ridges. + +**INVERTED:** +inverts the noise values + +**EASING:** + +- Linear: does nothing to the values + +- Squared: squares the value + +- Cubed: cubes the value + +- Root: square roots the value + +### Get Noise + +```scratch +(get noise id: [myNoise] at x: (0) y: (0) z: (0) :: motion) +``` +This block returns the value of your given noise at your given coordinates. + +**ID:** +the ID value of your noise (what you set for the id in the [create noise](#createNoise) block) + +**X Y Z:** +the coordinates of the noise \ No newline at end of file diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js new file mode 100644 index 0000000000..fc685f3fdb --- /dev/null +++ b/extensions/Corbnorb/noise.js @@ -0,0 +1,3268 @@ +let noises = new Object(); + +const BlockType = Scratch.BlockType; +const ArgumentType = Scratch.ArgumentType; + +(function (Scratch) { + 'use strict'; + + class PerlinNoise { + constructor() { + this.noiseSeed = 0; + this.worleySeed = 0; + this.time = performance.now(); + } + + getInfo() { + return { + id: 'noise', + name: 'Noise', + color1: '#b5074c', + color2: '#990841', + docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", + blocks: [ + { + opcode: 'initNoise', + blockType: BlockType.COMMAND, + text: 'create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]', + arguments: { + ID: { + type: ArgumentType.STRING, + defaultValue: 'myNoise', + }, + SEED: { + type: ArgumentType.NUMBER, + defaultValue: '0' + }, + TYPE: { + type: ArgumentType.STRING, + menu: 'NOISE_TYPE', + defaultValue: 'Perlin', + }, + OCTAVES: { + type: ArgumentType.NUMBER, + defaultValue: '1', + }, + FREQUENCY: { + type: ArgumentType.NUMBER, + defaultValue: '0.01', + }, + FRACTAL: { + type: ArgumentType.STRING, + menu: 'FRACTAL_TYPE', + defaultValue: 'FBm', + }, + INVERTED: { + type: ArgumentType.STRING, + menu: 'INVERTED_MENU', + defaultValue: 'false', + }, + EASING: { + type: ArgumentType.STRING, + menu: 'EASING_TYPE', + defaultValue: 'Linear', + } + } + }, + { + opcode: 'getNoise', + blockType: BlockType.REPORTER, + text: 'get noise id:[ID] at x:[X] y:[Y] z:[Z]', + arguments: { + ID: { + type: ArgumentType.STRING, + defaultValue: 'myNoise', + }, + X: { + type: ArgumentType.NUMBER, + defaultValue: '0', + }, + Y: { + type: ArgumentType.NUMBER, + defaultValue: '0', + }, + Z: { + type: ArgumentType.NUMBER, + defaultValue: '0', + }, + }, + }, + ], + menus: { + NOISE_TYPE: { + acceptReporters: false, + items: ['OpenSimpex2', 'OpenSimpex2S', 'Cellular', 'Perlin', 'Value Cubic', 'Value'], + }, + FRACTAL_TYPE: { + acceptReporters: false, + items: ['None', 'FBm', 'Ridged', 'Ping Pong'], + }, + INVERTED_MENU: { + acceptReporters: true, + items: ['true', 'false'], + }, + EASING_TYPE: { + acceptReporters: false, + items: ['Linear', 'Squared', 'Cubed', 'Root'], + } + } + }; + } + + initNoise(args) + { + noises[args.ID] = [new FastNoiseLite(args.SEED), 0, 0]; + switch(args.TYPE) { + case "OpenSimplex2": + noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); + break; + case "OpenSimplex2S": + noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2S); + break; + case "Cellular": + noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Cellular); + break; + case "Perlin": + noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Perlin); + break; + case "Value Cubic": + noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.ValueCubic); + break; + case "Value": + noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Value); + break; + } + switch(args.FRACTAL) { + case "None": + noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.None); + break; + case "FBm": + noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.FBm); + break; + case "Ridged": + noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.Ridged); + break; + case "Ping Pong": + noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.PingPong); + break; + } + noises[args.ID][2] = args.EASING; + noises[args.ID][0].SetFrequency(args.FREQUENCY); + noises[args.ID][0].SetFractalOctaves(args.OCTAVES); + noises[args.ID][1] = args.INVERTED; + } + + getNoise(args) + { + if(args.ID in noises) + { + let value = noises[args.ID][0].GetNoise(args.X, args.Y, args.Z); + value = noises[args.ID][1] == 'true' ? value : -value; + value = (value + 1) / 2; + switch(noises[args.ID][2]) { + case "Linear": + break; + case "Squared": + value = Math.pow(value, 2); + break; + case "Cubed": + value = Math.pow(value, 3); + break; + case "Root": + value = Math.sqrt(Math.abs(value)); + break; + } + value = (value * 2) - 1; + return value; + } + return 0; + } + + } + + Scratch.extensions.register(new PerlinNoise()); +})(window.Scratch = window.Scratch || {}); + + + +class FastNoiseLite { + static NoiseType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2S: "OpenSimplex2S", + Cellular: "Cellular", + Perlin: "Perlin", + ValueCubic: "ValueCubic", + Value: "Value", + }); + static RotationType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + }); + static FractalType = Object.freeze({ + None: "None", + FBm: "FBm", + Ridged: "Ridged", + PingPong: "PingPong", + DomainWarpProgressive: "DomainWarpProgressive", + DomainWarpIndependent: "DomainWarpIndependent", + }); + static CellularDistanceFunction = Object.freeze({ + Euclidean: "Euclidean", + EuclideanSq: "EuclideanSq", + Manhattan: "Manhattan", + Hybrid: "Hybrid", + }); + static CellularReturnType = Object.freeze({ + CellValue: "CellValue", + Distance: "Distance", + Distance2: "Distance2", + Distance2Add: "Distance2Add", + Distance2Sub: "Distance2Sub", + Distance2Mul: "Distance2Mul", + Distance2Div: "Distance2Div", + }); + static DomainWarpType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2Reduced: "OpenSimplex2Reduced", + BasicGrid: "BasicGrid", + }); + static TransformType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + DefaultOpenSimplex2: "DefaultOpenSimplex2", + }); + + /* Private */ + _Seed = 1337; + _Frequency = 0.01; + _NoiseType = FastNoiseLite.NoiseType.OpenSimplex2; + _RotationType3D = FastNoiseLite.RotationType3D.None; + _TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + _DomainWarpAmp = 1.0; + + _FractalType = FastNoiseLite.FractalType.None; + _Octaves = 3; + _Lacunarity = 2.0; + _Gain = 0.5; + _WeightedStrength = 0.0; + _PingPongStrength = 2.0; + + _FractalBounding = 1 / 1.75; + + _CellularDistanceFunction = FastNoiseLite.CellularDistanceFunction.EuclideanSq; + _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; + _CellularJitterModifier = 1.0; + + _DomainWarpType = FastNoiseLite.DomainWarpType.OpenSimplex2; + _WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + + /** + * @description Create new FastNoiseLite object with optional seed + * @param {number} [seed] + * @constructor + */ + constructor(seed) { + if (seed !== undefined) { + this._Seed = seed; + } + } + + /** + * @description Sets seed used for all noise types + * @remarks Default: 1337 + * @default 1337 + * @param {number} seed + */ + SetSeed(seed) { + this._Seed = seed; + } + + /** + * @description Sets frequency for all noise types + * @remarks Default: 0.01 + * @default 0.01 + * @param {number} frequency + */ + SetFrequency(frequency) { + this._Frequency = frequency; + } + + /** + * @description Sets noise algorithm used for GetNoise(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.NoiseType.OpenSimplex2 + * @param {FastNoiseLite.NoiseType} noiseType + */ + SetNoiseType(noiseType) { + this._NoiseType = noiseType; + this._UpdateTransformType3D(); + } + + /** + * @description Sets domain rotation type for 3D Noise and 3D DomainWarp. + * @description Can aid in reducing directional artifacts when sampling a 2D plane in 3D + * @remarks Default: None + * @default FastNoiseLite.RotationType3D.None + * @param {FastNoiseLite.RotationType3D} rotationType3D + */ + SetRotationType3D(rotationType3D) { + this._RotationType3D = rotationType3D; + this._UpdateTransformType3D(); + this._UpdateWarpTransformType3D(); + } + + /** + * @description Sets method for combining octaves in all fractal noise types + * @remarks Default: None + * @default FastNoiseLite.FractalType.None + * @param {FastNoiseLite.FractalType} fractalType + */ + SetFractalType(fractalType) { + this._FractalType = fractalType; + } + + /** + * @description Sets octave count for all fractal noise types + * @remarks Default: 3 + * @default 3 + * @param {number} octaves + */ + SetFractalOctaves(octaves) { + this._Octaves = octaves; + this._CalculateFractalBounding(); + } + + /** + * @description Sets octave lacunarity for all fractal noise types + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} lacunarity + */ + SetFractalLacunarity(lacunarity) { + this._Lacunarity = lacunarity; + } + + /** + * @description Sets octave gain for all fractal noise types + * @remarks Default: 0.5 + * @default 0.5 + * @param {number} gain + */ + SetFractalGain(gain) { + this._Gain = gain; + this._CalculateFractalBounding(); + } + + /** + * @description Sets octave weighting for all none DomainWarp fratal types + * @remarks Default: 0.0 | Keep between 0...1 to maintain -1...1 output bounding + * @default 0.5 + * @param {number} weightedStrength + */ + SetFractalWeightedStrength(weightedStrength) { + this._WeightedStrength = weightedStrength; + } + + /** + * @description Sets strength of the fractal ping pong effect + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} pingPongStrength + */ + SetFractalPingPongStrength(pingPongStrength) { + this._PingPongStrength = pingPongStrength; + } + + /** + * @description Sets distance function used in cellular noise calculations + * @remarks Default: EuclideanSq + * @default FastNoiseLite.CellularDistanceFunction.EuclideanSq + * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction + */ + SetCellularDistanceFunction(cellularDistanceFunction) { + this._CellularDistanceFunction = cellularDistanceFunction; + } + + /** + * @description Sets return type from cellular noise calculations + * @remarks Default: Distance + * @default FastNoiseLite.CellularReturnType.Distance + * @param {FastNoiseLite.CellularReturnType} cellularReturnType + */ + SetCellularReturnType(cellularReturnType) { + this._CellularReturnType = cellularReturnType; + } + + /** + * @description Sets the maximum distance a cellular point can move from it's grid position + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} cellularJitter + */ + SetCellularJitter(cellularJitter) { + this._CellularJitterModifier = cellularJitter; + } + + /** + * @description Sets the warp algorithm when using DomainWarp(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.DomainWarpType.OpenSimplex2 + * @param {FastNoiseLite.DomainWarpType} domainWarpType + */ + SetDomainWarpType(domainWarpType) { + this._DomainWarpType = domainWarpType; + this._UpdateWarpTransformType3D(); + } + + /** + * @description Sets the maximum warp distance from original position when using DomainWarp(...) + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} domainWarpAmp + */ + SetDomainWarpAmp(domainWarpAmp) { + this._DomainWarpAmp = domainWarpAmp; + } + + /** + * @description 2D/3D noise at given position using current settings + * @param {number} x X coordinate + * @param {number} y Y coordinate + * @param {number} [z] Z coordinate + * @return {number} Noise output bounded between -1...1 + */ + GetNoise(x, y, z) { + /** + * @description 2D noise at given position using current settings + * @param {number} x + * @param {number} y + * @return {number} Noise output bounded between -1...1 + */ + let R2 = (x, y) => { + x *= this._Frequency; + y *= this._Frequency; + + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: + const SQRT3 = 1.7320508075688772935274463415059; + const F2 = 0.5 * (SQRT3 - 1); + let t = (x + y) * F2; + x += t; + y += t; + break; + default: + break; + } + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR2(this._Seed, x, y); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR2(x, y); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR2(x, y); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR2(x, y); + } + }; + + /** + * @description 3D noise at given position using current settings + * @param {number} x + * @param {number} y + * @param {number} z + * @return {number} Noise output bounded between -1...1 + */ + let R3 = (x, y, z) => { + x *= this._Frequency; + y *= this._Frequency; + z *= this._Frequency; + + switch (this._TransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: { + let xy = x + y; + let s2 = xy * -0.211324865405187; + z *= 0.577350269189626; + x += s2 - z; + y += s2 - z; + z += xy * 0.577350269189626; + break; + } + case FastNoiseLite.TransformType3D.ImproveXZPlanes: { + let xz = x + z; + let s2 = xz * -0.211324865405187; + y *= 0.577350269189626; + x += s2 - y; + z += s2 - y; + y += xz * 0.577350269189626; + break; + } + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + const R3 = 2.0 / 3.0; + let r = (x + y + z) * R3; + x = r - x; + y = r - y; + z = r - z; + break; + default: + break; + } + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR3(this._Seed, x, y, z); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR3(x, y, z); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR3(x, y, z); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR3(x, y, z); + } + }; + + if (arguments.length === 2) { + return R2(x, y); + } + + if (arguments.length === 3) { + return R3(x, y, z); + } + } + + /** + * @description 2D/3D warps the input position using current domain warp settings + * @param {Vector2|Vector3} coord + */ + DomainWrap(coord) { + switch (this._FractalType) { + default: + this._DomainWarpSingle(coord); + break; + case FastNoiseLite.FractalType.DomainWarpProgressive: + this._DomainWarpFractalProgressive(coord); + break; + case FastNoiseLite.FractalType.DomainWarpIndependent: + this._DomainWarpFractalIndependent(coord); + break; + } + } + + // prettier-ignore + _Gradients2D = [ + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, + -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, + ]; + + // prettier-ignore + _RandVecs2D = [ + -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, + -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, + -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, + -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, + -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, + 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, + 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, + -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, + 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, + 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, + -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, + 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, + -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, + -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, + 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, + -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, + 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, + 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, + 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, + -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, + 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, + 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, + 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, + -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, + 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, + -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, + 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, + -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, + 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, + -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, + 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, + 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, + ]; + + // prettier-ignore + _Gradients3D = [ + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 + ]; + + // prettier-ignore + _RandVecs3D = [ + -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, + 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, + -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, + -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, + 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, + -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, + 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, + 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, + -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, + 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, + -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, + -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, + 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, + 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, + -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, + 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, + 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, + -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, + -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, + -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, + -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, + 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, + 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, + 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, + -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, + -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, + -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, + 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, + 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, + 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, + 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, + -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 + ]; + + _PrimeX = 501125321; + _PrimeY = 1136930381; + _PrimeZ = 1720413743; + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} t + * @returns {number} + */ + static _Lerp(a, b, t) { + return a + t * (b - a); + } + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _InterpHermite(t) { + return t * t * (3 - 2 * t); + } + + /** + * @private + * @param t + * @returns {number} + */ + static _InterpQuintic(t) { + return t * t * t * (t * (t * 6 - 15) + 10); + } + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} c + * @param {number} d + * @param {number} t + * @returns {number} + */ + static _CubicLerp(a, b, c, d, t) { + let p = d - c - (a - b); + return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; + } + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _PingPong(t) { + t -= Math.trunc(t * 0.5) * 2; + return t < 1 ? t : 2 - t; + } + + /** + * @private + */ + _CalculateFractalBounding() { + let gain = Math.abs(this._Gain); + let amp = gain; + let ampFractal = 1.0; + for (let i = 1; i < this._Octaves; i++) { + ampFractal += amp; + amp *= gain; + } + this._FractalBounding = 1 / ampFractal; + } + + /** + * @private + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @returns {number} + */ + _HashR2(seed, xPrimed, yPrimed) { + let hash = seed ^ xPrimed ^ yPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _HashR3(seed, xPrimed, yPrimed, zPrimed){ + let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; + } + + /** + * @private + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @returns {number} + */ + _ValCoordR2(seed, xPrimed, yPrimed) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _ValCoordR3(seed, xPrimed, yPrimed, zPrimed){ + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} xd + * @param {number} yd + * @returns {number} + */ + _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + hash ^= hash >> 15; + hash &= 127 << 1; + + let xg = this._Gradients2D[hash]; + let yg = this._Gradients2D[hash | 1]; + + return xd * xg + yd * yg; + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @param {number} xd + * @param {number} yd + * @param {number} zd + * @returns {number} + */ + _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + hash ^= hash >> 15; + hash &= 63 << 2; + + let xg = this._Gradients3D[hash]; + let yg = this._Gradients3D[hash | 1]; + let zg = this._Gradients3D[hash | 2]; + + return xd * xg + yd * yg + zd * zg; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenNoiseSingleR2(seed, x, y) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R2(seed, x, y); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR2(seed, x, y); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR2(seed, x, y); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR2(seed, x, y); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR2(seed, x, y); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR2(seed, x, y); + default: + return 0; + } + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenNoiseSingleR3(seed, x, y, z){ + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R3(seed, x, y, z); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR3(seed, x, y, z); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR3(seed, x, y, z); + default: + return 0; + } + } + + /** + * @private + */ + _UpdateTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: + this._TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; + default: + this._TransformType3D = FastNoiseLite.TransformType3D.None; + break; + } + break; + } + } + + /** + * @private + */ + _UpdateWarpTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._WarpTransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._WarpTransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; + default: + this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; + break; + } + break; + } + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalFBmR2(x,y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR2(seed++, x, y); + sum += noise * amp; + amp *= FastNoiseLite._Lerp(1.0, Math.min(noise + 1, 2) * 0.5, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalFBmR3(x,y,z){ + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR3(seed++, x, y, z); + sum += noise * amp; + amp *= FastNoiseLite._Lerp(1.0, (noise + 1) * 0.5, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalRidgedR2(x,y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalRidgedR3(x,y,z){ + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalPingPongR2(x,y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalPingPongR3(x,y,z){ + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleOpenSimplex2R2(seed,x,y) { + const SQRT3 = 1.7320508075688772935274463415059; + const G2 = (3 - SQRT3) / 6; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let n0, n1, n2; + + let a = 0.5 - x0 * x0 - y0 * y0; + + if (a <= 0) { + n0 = 0; + } else { + n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); + } + + let c = 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + + if (c <= 0) { + n2 = 0; + } else { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + n2 = c * c * (c * c) * this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); + } + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = b * b * (b * b) * this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); + } + } else { + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = b * b * (b * b) * this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); + } + } + return (n0 + n1 + n2) * 99.83685446303647; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleOpenSimplex2R3(seed,x,y,z){ + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let yNSign = Math.trunc((-1.0 - y0) | 1); + let xNSign = Math.trunc((-1.0 - x0) | 1); + let zNSign = Math.trunc((-1.0 - z0) | 1); + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let value = 0; + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + + for (let l = 0; ; l++) { + if (a > 0) { + value += a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); + } + + if (ax0 >= ay0 && ax0 >= az0) { + let b = a + ax0 + ax0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i - xNSign * this._PrimeX, + j, + k, + x0 + xNSign, + y0, + z0 + ); + } + } else if (ay0 > ax0 && ay0 >= az0) { + let b = a + ay0 + ay0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j - yNSign * this._PrimeY, + k, + x0, + y0 + yNSign, + z0 + ); + } + } else { + let b = a + az0 + az0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j, + k - zNSign * this._PrimeZ, + x0, + y0, + z0 + zNSign + ); + } + } + + if (l === 1) { + break; + } + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed = ~seed; + } + return value * 32.69428253173828125; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleOpenSimplex2SR2(seed,x,y) { + // 2D OpenSimplex2S case is a modified 2D simplex noise. + + const SQRT3 = 1.7320508075688772935274463415059; + const G2 = (3 - SQRT3) / 6; + + /* + * --- Skew moved to TransformNoiseCoordinate method --- + * final FNLfloat F2 = 0.5f * (SQRT3 - 1); + * FNLfloat s = (x + y) * F2; + * x += s; y += s; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + let i1 = i + this._PrimeX; + let j1 = j + this._PrimeY; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; + let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); + let a1 = 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); + let x1 = x0 - (1 - 2 * G2); + let y1 = y0 - (1 - 2 * G2); + value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); + + // Nested conditionals were faster than compact bit logic/arithmetic. + let xmyi = xi - yi; + if (t > G2) { + if (xi + xmyi > 1) { + let x2 = x0 + (3 * G2 - 2); + let y2 = y0 + (3 * G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i + (this._PrimeX << 1), j + this._PrimeY, x2, y2); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * a2 * (a2 * a2) * this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); + } + } + + if (yi - xmyi > 1) { + let x3 = x0 + (3 * G2 - 1); + let y3 = y0 + (3 * G2 - 2); + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2(seed, i + this._PrimeX, j + (this._PrimeY << 1), x3, y3); + } + } else { + let x3 = x0 + (G2 - 1); + let y3 = y0 + G2; + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * a3 * (a3 * a3) * this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); + } + } + } else { + if (xi + xmyi < 0) { + let x2 = x0 + (1 - G2); + let y2 = y0 - G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * a2 * (a2 * a2) * this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); + } + } else { + let x2 = x0 + (G2 - 1); + let y2 = y0 + G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * a2 * (a2 * a2) * this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); + } + } + + if (yi < xmyi) { + let x2 = x0 - G2; + let y2 = y0 - (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * a2 * (a2 * a2) * this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * a2 * (a2 * a2) * this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); + } + } + } + + return value * 18.24196194486065; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleOpenSimplex2SR3 (seed, x, y, z) { + // 3D OpenSimplex2S case uses two offset rotated cube grids. + + /* + * --- Rotation moved to TransformNoiseCoordinate method --- + * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); + * FNLfloat r = (x + y + z) * R3; // Rotation, not skew + * x = r - x; y = r - y; z = r - z; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let k = Math.floor(z); + let xi = x - i; + let yi = y - j; + let zi = z - k; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + let seed2 = seed + 1293373; + + let xNMask = Math.trunc(-0.5 - xi); + let yNMask = Math.trunc(-0.5 - yi); + let zNMask = Math.trunc(-0.5 - zi); + + let x0 = xi + xNMask; + let y0 = yi + yNMask; + let z0 = zi + zNMask; + let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; + let value = + a0 * + a0 * + (a0 * a0) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x0, + y0, + z0 + ); + + let x1 = xi - 0.5; + let y1 = yi - 0.5; + let z1 = zi - 0.5; + let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; + value += + a1 * + a1 * + (a1 * a1) * + this._GradCoordR3(seed2, i + this._PrimeX, j + this._PrimeY, k + this._PrimeZ, x1, y1, z1); + + let xAFlipMask0 = ((xNMask | 1) << 1) * x1; + let yAFlipMask0 = ((yNMask | 1) << 1) * y1; + let zAFlipMask0 = ((zNMask | 1) << 1) * z1; + let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; + let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; + let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; + + let skip5 = false; + let a2 = xAFlipMask0 + a0; + if (a2 > 0) { + let x2 = x0 - (xNMask | 1); + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x2, + y0, + z0 + ); + } else { + let a3 = yAFlipMask0 + zAFlipMask0 + a0; + + if (a3 > 0) { + let x3 = x0; + let y3 = y0 - (yNMask | 1); + let z3 = z0 - (zNMask | 1); + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x3, + y3, + z3 + ); + } + + let a4 = xAFlipMask1 + a1; + if (a4 > 0) { + let x4 = (xNMask | 1) + x1; + value += + a4 * + a4 * + (a4 * a4) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + this._PrimeZ, + x4, + y1, + z1 + ); + skip5 = true; + } + } + + let skip9 = false; + let a6 = yAFlipMask0 + a0; + if (a6 > 0) { + let x6 = x0; + let y6 = y0 - (yNMask | 1); + value += + a6 * + a6 * + (a6 * a6) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x6, + y6, + z0 + ); + } else { + let a7 = xAFlipMask0 + zAFlipMask0 + a0; + if (a7 > 0) { + let x7 = x0 - (xNMask | 1); + let y7 = y0; + let z7 = z0 - (zNMask | 1); + value += + a7 * + a7 * + (a7 * a7) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x7, + y7, + z7 + ); + } + + let a8 = yAFlipMask1 + a1; + if (a8 > 0) { + let x8 = x1; + let y8 = (yNMask | 1) + y1; + value += + a8 * + a8 * + (a8 * a8) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + x8, + y8, + z1 + ); + skip9 = true; + } + } + + let skipD = false; + let aA = zAFlipMask0 + a0; + if (aA > 0) { + let xA = x0; + let yA = y0; + let zA = z0 - (zNMask | 1); + value += + aA * + aA * + (aA * aA) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + xA, + yA, + zA + ); + } else { + let aB = xAFlipMask0 + yAFlipMask0 + a0; + if (aB > 0) { + let xB = x0 - (xNMask | 1); + let yB = y0 - (yNMask | 1); + value += + aB * + aB * + (aB * aB) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + xB, + yB, + z0 + ); + } + + let aC = zAFlipMask1 + a1; + if (aC > 0) { + let xC = x1; + let yC = y1; + let zC = (zNMask | 1) + z1; + value += + aC * + aC * + (aC * aC) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + xC, + yC, + zC + ); + skipD = true; + } + } + + if (!skip5) { + let a5 = yAFlipMask1 + zAFlipMask1 + a1; + if (a5 > 0) { + let x5 = x1; + let y5 = (yNMask | 1) + y1; + let z5 = (zNMask | 1) + z1; + value += + a5 * + a5 * + (a5 * a5) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + (zNMask & (this._PrimeZ << 1)), + x5, + y5, + z5 + ); + } + } + + if (!skip9) { + let a9 = xAFlipMask1 + zAFlipMask1 + a1; + if (a9 > 0) { + let x9 = (xNMask | 1) + x1; + let y9 = y1; + let z9 = (zNMask | 1) + z1; + value += + a9 * + a9 * + (a9 * a9) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + x9, + y9, + z9 + ); + } + } + + if (!skipD) { + let aD = xAFlipMask1 + yAFlipMask1 + a1; + if (aD > 0) { + let xD = (xNMask | 1) + x1; + let yD = (yNMask | 1) + y1; + value += + aD * + aD * + (aD * aD) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX << 1)), + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + xD, + yD, + z1 + ); + } + } + + return value * 9.046026385208288; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleCellularR2(seed,x,y) { + /** + * + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + let xr = Math.round(x); + let yr = Math.round(y); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + + let closestHash = 0; + + let cellularJitter = 0.43701595 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + + switch (this._CellularDistanceFunction) { + default: + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY; + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = Math.abs(vecX) + Math.abs(vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + } + + if ( + this._CellularDistanceFunction === FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + + if (this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue) { + distance1 = Math.sqrt(distance1); + } + } + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; + } + + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleCellularR3 (seed, x, y, z) { + let xr = Math.round(x); + let yr = Math.round(y); + let zr = Math.round(z); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + let closestHash = 0; + + let cellularJitter = 0.39614353 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + let zPrimedBase = (zr - 1) * this._PrimeZ; + + switch (this._CellularDistanceFunction) { + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = + Math.abs(vecX) + + Math.abs(vecY) + + Math.abs(vecZ) + + (vecX * vecX + vecY * vecY + vecZ * vecZ); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + default: + break; + } + + if ( + this._CellularDistanceFunction === FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + + if (this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue) { + distance1 = Math.sqrt(distance1); + } + } + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; + } + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SinglePerlinR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xd0 = x - x0; + let yd0 = y - y0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y0, xd0, yd0), + this._GradCoordR2(seed, x1, y0, xd1, yd0), + xs + ); + let xf1 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y1, xd0, yd1), + this._GradCoordR2(seed, x1, y1, xd1, yd1), + xs + ); + + return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SinglePerlinR3 (seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xd0 = x - x0; + let yd0 = y - y0; + let zd0 = z - z0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + let zd1 = zd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + let zs = FastNoiseLite._InterpQuintic(zd0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), + this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), + xs + ); + let xf10 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), + this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), + xs + ); + let xf01 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), + this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), + xs + ); + let xf11 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), + this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), + xs + ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueCubicR2(seed, x, y) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + + let xs = x - x1; + let ys = y - y1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), + this._ValCoordR2(seed, x2, y0), + this._ValCoordR2(seed, x3, y0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), + this._ValCoordR2(seed, x2, y1), + this._ValCoordR2(seed, x3, y1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y2), + this._ValCoordR2(seed, x1, y2), + this._ValCoordR2(seed, x2, y2), + this._ValCoordR2(seed, x3, y2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y3), + this._ValCoordR2(seed, x1, y3), + this._ValCoordR2(seed, x2, y3), + this._ValCoordR2(seed, x3, y3), + xs + ), + ys + ) * + (1 / (1.5 * 1.5)) + ); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueCubicR3(seed, x, y, z) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + let z1 = Math.floor(z); + + let xs = x - x1; + let ys = y - y1; + let zs = z - z1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + z1 = Math.imul(z1, this._PrimeZ); + + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let z0 = z1 - this._PrimeZ; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let z2 = z1 + this._PrimeZ; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + let z3 = z1 + (this._PrimeZ << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + this._ValCoordR3(seed, x2, y0, z0), + this._ValCoordR3(seed, x3, y0, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + this._ValCoordR3(seed, x2, y1, z0), + this._ValCoordR3(seed, x3, y1, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z0), + this._ValCoordR3(seed, x1, y2, z0), + this._ValCoordR3(seed, x2, y2, z0), + this._ValCoordR3(seed, x3, y2, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z0), + this._ValCoordR3(seed, x1, y3, z0), + this._ValCoordR3(seed, x2, y3, z0), + this._ValCoordR3(seed, x3, y3, z0), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + this._ValCoordR3(seed, x2, y0, z1), + this._ValCoordR3(seed, x3, y0, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + this._ValCoordR3(seed, x2, y1, z1), + this._ValCoordR3(seed, x3, y1, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z1), + this._ValCoordR3(seed, x1, y2, z1), + this._ValCoordR3(seed, x2, y2, z1), + this._ValCoordR3(seed, x3, y2, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z1), + this._ValCoordR3(seed, x1, y3, z1), + this._ValCoordR3(seed, x2, y3, z1), + this._ValCoordR3(seed, x3, y3, z1), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z2), + this._ValCoordR3(seed, x1, y0, z2), + this._ValCoordR3(seed, x2, y0, z2), + this._ValCoordR3(seed, x3, y0, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z2), + this._ValCoordR3(seed, x1, y1, z2), + this._ValCoordR3(seed, x2, y1, z2), + this._ValCoordR3(seed, x3, y1, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z2), + this._ValCoordR3(seed, x1, y2, z2), + this._ValCoordR3(seed, x2, y2, z2), + this._ValCoordR3(seed, x3, y2, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z2), + this._ValCoordR3(seed, x1, y3, z2), + this._ValCoordR3(seed, x2, y3, z2), + this._ValCoordR3(seed, x3, y3, z2), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z3), + this._ValCoordR3(seed, x1, y0, z3), + this._ValCoordR3(seed, x2, y0, z3), + this._ValCoordR3(seed, x3, y0, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z3), + this._ValCoordR3(seed, x1, y1, z3), + this._ValCoordR3(seed, x2, y1, z3), + this._ValCoordR3(seed, x3, y1, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z3), + this._ValCoordR3(seed, x1, y2, z3), + this._ValCoordR3(seed, x2, y2, z3), + this._ValCoordR3(seed, x3, y2, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z3), + this._ValCoordR3(seed, x1, y3, z3), + this._ValCoordR3(seed, x2, y3, z3), + this._ValCoordR3(seed, x3, y3, z3), + xs + ), + ys + ), + zs + ) * + (1 / (1.5 * 1.5 * 1.5)) + ); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp(this._ValCoordR2(seed, x0, y0), this._ValCoordR2(seed, x1, y0), xs); + let xf1 = FastNoiseLite._Lerp(this._ValCoordR2(seed, x0, y1), this._ValCoordR2(seed, x1, y1), xs); + + return FastNoiseLite._Lerp(xf0, xf1, ys); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + let zs = FastNoiseLite._InterpHermite(z - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + xs + ); + let xf10 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + xs + ); + let xf01 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + xs + ); + let xf11 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + xs + ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs); + } + + /** + * @private + */ + _DoSingleDomainWarp() { + /** + * + * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + let R2 = (seed, amp, freq, coord, x, y) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 38.283687591552734375, + freq, + coord, + false, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 16.0, + freq, + coord, + true, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); + break; + } + }; + + /** + * + * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, amp, freq, coord, x, y, z) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 32.69428253173828125, + freq, + coord, + false, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 7.71604938271605, + freq, + coord, + true, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); + break; + } + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + return R2(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + return R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + } + + /** + * @private + */ + _DomainWarpSingle() { + /** + * + * @param {Vector2} coord + */ + let R2 = coord => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + const SQRT3 = 1.7320508075688772935274463415059; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = coord => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + break; + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + _DomainWarpFractalProgressive() { + /** + * + * @param {Vector2} coord + */ + let R2 = coord => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + const SQRT3 = 1.7320508075688772935274463415059; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = coord => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + } + break; + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + /** + * @private + */ + _DomainWarpFractalIndependent() { + /** + * + * @param {Vector2} coord + */ + let R2 = coord => { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + const SQRT3 = 1.7320508075688772935274463415059; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + default: + break; + } + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = coord => { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + } + break; + default: + break; + } + + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + /** + * @private + */ + _SingleDomainWarpBasicGrid() { + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + + let R2 = (seed, warpAmp, frequency, coord, x, y) => { + let xf = x * frequency; + let yf = y * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); + let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); + + let lx0x = FastNoiseLite._Lerp(this._RandVecs2D[hash0], this._RandVecs2D[hash1], xs); + let ly0x = FastNoiseLite._Lerp(this._RandVecs2D[hash0 | 1], this._RandVecs2D[hash1 | 1], xs); + + hash0 = this._HashR2(seed, x0, y1) & (255 << 1); + hash1 = this._HashR2(seed, x1, y1) & (255 << 1); + + let lx1x = FastNoiseLite._Lerp(this._RandVecs2D[hash0], this._RandVecs2D[hash1], xs); + let ly1x = FastNoiseLite._Lerp(this._RandVecs2D[hash0 | 1], this._RandVecs2D[hash1 | 1], xs); + + coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; + coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { + let xf = x * frequency; + let yf = y * frequency; + let zf = z * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + let z0 = Math.floor(zf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + let zs = FastNoiseLite._InterpHermite(zf - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); + let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); + + let lx0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0], this._RandVecs3D[hash1], xs); + let ly0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 1], this._RandVecs3D[hash1 | 1], xs); + let lz0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 2], this._RandVecs3D[hash1 | 2], xs); + + hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); + + let lx1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0], this._RandVecs3D[hash1], xs); + let ly1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 1], this._RandVecs3D[hash1 | 1], xs); + let lz1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 2], this._RandVecs3D[hash1 | 2], xs); + + let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); + let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); + let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); + + hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); + + lx0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0], this._RandVecs3D[hash1], xs); + ly0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 1], this._RandVecs3D[hash1 | 1], xs); + lz0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 2], this._RandVecs3D[hash1 | 2], xs); + + hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); + + lx1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0], this._RandVecs3D[hash1], xs); + ly1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 1], this._RandVecs3D[hash1 | 1], xs); + lz1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 2], this._RandVecs3D[hash1 | 2], xs); + + coord.x += FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * warpAmp; + coord.y += FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * warpAmp; + coord.z += FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * warpAmp; + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + R2(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + } + + /** + * @private + */ + _SingleDomainWarpOpenSimplex2Gradient() { + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + */ + let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { + const SQRT3 = 1.7320508075688772935274463415059; + const G2 = (3 - SQRT3) / 6; + + x *= frequency; + y *= frequency; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let vx, vy; + vx = vy = 0; + + let a = 0.5 - x0 * x0 - y0 * y0; + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i, j) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i, j); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x0 * xg + y0 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += aaaa * xo; + vy += aaaa * yo; + } + + let c = 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + if (c > 0) { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + let cccc = c * c * (c * c); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x2 * xg + y2 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += cccc * xo; + vy += cccc * yo; + } + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i, j + this._PrimeY); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x1 * xg + y1 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += bbbb * xo; + vy += bbbb * yo; + } + } else { + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i + this._PrimeX, j); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x1 * xg + y1 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += bbbb * xo; + vy += bbbb * yo; + } + } + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { + x *= frequency; + y *= frequency; + z *= frequency; + + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let xNSign = (-x0 - 1.0) | 1; + let yNSign = (-y0 - 1.0) | 1; + let zNSign = (-z0 - 1.0) | 1; + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let vx, vy, vz; + vx = vy = vz = 0; + + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + for (let l = 0; ; l++) { + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i, j, k) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i, j, k); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x0 * xg + y0 * yg + z0 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; + } + vx += aaaa * xo; + vy += aaaa * yo; + vz += aaaa * zo; + } + + let b = a; + let i1 = i; + let j1 = j; + let k1 = k; + let x1 = x0; + let y1 = y0; + let z1 = z0; + + if (ax0 >= ay0 && ax0 >= az0) { + x1 += xNSign; + b = b + ax0 + ax0; + i1 -= xNSign * this._PrimeX; + } else if (ay0 > ax0 && ay0 >= az0) { + y1 += yNSign; + b = b + ay0 + ay0; + j1 -= yNSign * this._PrimeY; + } else { + z1 += zNSign; + b = b + az0 + az0; + k1 -= zNSign * this._PrimeZ; + } + + if (b > 1) { + b -= 1; + let bbbb = b * b * (b * b); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i1, j1, k1); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x1 * xg + y1 * yg + z1 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; + } + vx += bbbb * xo; + vy += bbbb * yo; + vz += bbbb * zo; + } + + if (l === 1) break; + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed += 1293373; + } + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + coord.z += vz * warpAmp; + }; + + if (arguments.length === 7) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + + if (arguments.length === 8) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6], + arguments[7] + ); + } + } +} + +class Vector2 { + /** + * 2d Vector + * @param {number} x + * @param {number} y + */ + constructor(x, y) { + this.x = x; + this.y = y; + } +} + +class Vector3 { + /** + * 3d Vector + * @param {number} x + * @param {number} y + * @param {number} z + */ + constructor(x, y, z) { + this.x = x; + this.y = y; + this.z = z; + } +} \ No newline at end of file diff --git a/extensions/extensions.json b/extensions/extensions.json index 9027c00ac9..1c461be5f3 100644 --- a/extensions/extensions.json +++ b/extensions/extensions.json @@ -96,5 +96,6 @@ "itchio", "gamejolt", "obviousAlexC/newgroundsIO", + "Corbnorb/noise" "Lily/McUtils" // McUtils should always be the last item. ] From 76b90c11733ebc58b8e21f0460bf1c01be4ebac0 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 15:57:30 -0700 Subject: [PATCH 02/36] ready to pull i think --- extensions/Corbnorb/noise.js | 8 ++++++++ images/Corbnorb/noise.png | Bin 0 -> 63085 bytes 2 files changed, 8 insertions(+) create mode 100644 images/Corbnorb/noise.png diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index fc685f3fdb..cdc4950a1f 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -1,3 +1,11 @@ +// Name: Noise +// ID: noise +// Description: Adds many types of noises using FastNoiseLite +// By: Corbnorbs +// Original: Auburn +// License: MPL-2.0 + + let noises = new Object(); const BlockType = Scratch.BlockType; diff --git a/images/Corbnorb/noise.png b/images/Corbnorb/noise.png new file mode 100644 index 0000000000000000000000000000000000000000..030cb21b7d0a90e7da84bc0fcccbf1d9df323ebd GIT binary patch literal 63085 zcmXt9Ra8{n+eZW`X&9u00g0izL%N3;L`piPVFaW>x|^YEVB{4fr38@}xhWdRUEtI12{FnZqzN zX*RLsd0er?Z`jT8n5H`5p|R~pMsthDj>1ZkP3lICBIqbJsd4;Mc8~1MIbMlg;!(kL zbt?8)t^cVV_caS3vPNqz<8(B8&qA}vJ03S>AFbcD8!Y29YC#r267xB%*Uuh8mp#&Y z;;#No&F`l*Q<(PCU(H2WtGNKwwa$9pQ*4jkZJS5_uEJj&owsq`Q(CFtz^1&RWDqQ@ z|){oq{MKS~w!aQkCA?wG<)o9=EgjP3^@yPP;)UM+BifM+ctyLysYYUmbIm?G|9 zX`{^H45+cTwBWo*CFo%{_|cxnc{xJ0{-)-PYG}FmM~vOwR{=m>%E>tX`BbC@F0H9MrHpLe-;Xy*x3VwZuJ zubXZWmgG>dbB4Tq7{adki#z0XEV{_ zH*(a2`ur`cf>NIW5oaVCQMHJaS;z{mo1-|UXQ)k38MWGB9C>(y`USde8`0>Aw2SDJ0 zJ8f(5MC=aQh<~>M$qbshdSmj=meaLw6_ix%UuwsC7fw7NrJzbaX9ufK533b`|1{Pc z(iA4!$?A((Aj8rxeMN%guPK&#Y8;fYl4GYggly1z)sFPf%?&(hL@XBb2w>}l9vC2{{juJU>Vwk?ofO;C$ui;$|s0j;Dpu>#i5_lyPM2#XQu+0}gw_DJCX-_%F+( zPJ7?TivA7*TR-RGj(v;6df>TjA+}HRT3Ds#IdK=!a%^LM8_t2J(tO{|gj8pS*FLSL zYF}#{mRFp}A!aNgk;2+k!juSe-3X zaaa%mNa^pDXTG7S%C~ae=~mM%VjE5fa3(&Q13j`xe5^&5y{p}$SAGUU&s>fQEQ1hdJUT_ zKDt5ruR{}qYy7ayCay!=O&#ha1;|yKPE~wMV2i%yiY57C@*gcW4u#woTSjpfCBs}E zurr&}ehvmMWUnHAm;H90?Zy3UThpuLUctt^2>^cRo9sBcC|&w(%X*y^vW zqo-x$eYvaSNIv6LNQ!fs6mv^leMlqK?XTaG3!lV_DwbS~D9~ZG`}jd~l1w}OPSgZq z`ly6m{;K+zu;@ewWbi0X<UzxBTX zF={4af`WiPH#nd`RZAn?FMQ(q%14YvFN+0NPQOi>ztU#V@~MI?f;#xipRR1eH&o}; zc8KTqBKaPbD45u>7QIs6-&I zcx^gUBtL8LVv-z$?9`>1J(zhd|0RwP76pxOGo^n%t_ zTo1XC`^V2`Ol+;;#%d<$t%<013VcdM$@LK{gKekIEpt(%k%g1sN*lX|o?Z)4Sey0; z<1_kPDurDTXZTr4vR(o_^X^v-3ODepLg&dkssZzkT00(Z;tl-<{VW>#U5YDePM~C! zysmy~M*;h|?>StID67k+vX5kMsm?M~YyXi0txaI!5?Xu-^hrz-ZIxXW)_SeWMn4NF zqAu{Vtge3BrFzDW4&WrPiX~Ec3i7<>Hk&%11*Z!Y2Z?+=7%i=?r*#!JdOp_gx;OdM z(_NBGIFh3N@AEsQS9B`jwdN(La%c{mZ6}`A2(oYg1<8{CgHwyp zTfp^{*Yw|KiGSGFvMDDoZf9lhyJeFJDqZ5NQuV5FE08yU?4qB~#s70y8X=HdEy#1t z$-B!ib5_AjU{7auo(da2-kdwZrYfMQfBIb1X@Hpj=l3TTu!!r>`oS+&&pKuK_qXV_ zgtjrR-(#>Y8+(>avD)tK{iCtv&VNcysO{=S zQ5O@K*rh`R)!13pqg<~Ai6w1{$$ur-j0A+H)vf{K9C;hRC9ty$uskDM&Azy_xV&`GvrcSS%rpxR}_C;#;Kr>J^GStT7hjW+1kf z#r747*wc8^!f=o%iBVDe1;+ARGY!1I6p)0VfcxXauSl(2U1}@OgUBR#3Z!LfTIiQo z-1)N&t<-*IkGo5aYQGXj4#>>6tQLnCF?On~z4@N?c2((`pzI|WxrC9NIp^_|_yCbJ zLvEiiVAy)CFlHH0tXNX%1ZWGjS23$nk*kbP@t=xEqI7cShC{;JhtQUF8JwWYt1r+rV+fM-JeM} zXoVyip(prE6=5d3&^}DzprQy=Az0}^Hi%-XXD5&9i)nQ@TO2!eu&_%L*27i?!Zhab zv>WEi6Z5B@Q)U&{{)WTD{QDi!Y4lWbn*SWO_BR~FQ#IPE-%(H19{+C((<*)t7ciaj zTK#jpSWGBAun}YXlm17xuGAl|@U=%Sr5dvy)e7 z6-aD)=@*j6&{rqA*Pd!yJaOlp16Z*AIJ^(-vrBxRNEQ}msKu$y6g-)R#&NqjSh}vZ z@+VkS5l$+KmQFMbZR-FU(8rMw9kKhC0d( zij#PgJ9uz=>&ujS<+#WhVQ;Qjlu&Vf7Gtb{Qi)hE1plVM_DpT0D`Ikm!zbf3@nhXf z7q+Ou*NT}gC}NGG-8OuU_^B7(b#Es&Hnqb`-BUrW-43DJ(KRv;(t!PlAO1{q1g7DJ z|Jdp~`?w@=A&~;YVv+eiuRIAc2Oa8!)9P^a3=N!ruI;q@4$G$5W`UNuAdQX^aC6XQ zU`bvNcqO2hB1TJMcty5I^YrespRQJgK0~;*WqQy?8OwO|sP|XXxDr$_onmt{pU-K8 zzfod|zb3GCC$pKSU)C^P*2bpYI`+*hS)eT0Uc9^UH?DMu9-FOtxtWg!(a71Lx3z7H zd}f(43#~_3~nD&(8KcTLq2($BX!tO-|xa?0-nV#<3tcv)HP*% zTy}D7-X-O%z2bfPQ43F>5F%#@&p27$W6;4-qm~_o_ff!g0O&MUH>a$cKXwWpB~w2t zN+^s&HYClu?#;9~PbwIFSsC3|FzMs^*6B(Q`OPlzl5$77-L3KopXTEZoY?T-dYl^d zmNPVIk5rHLyOY_XkNN|Qfyl9ha-`0i_P}QBb=o8wgi7Ngrb|*>F8gg3E0}bV1q^u$ z0{2!AtBKY{f=tBHnTJzCKZ*7cuYY~W1Ld`*3#~&e4=;*sz*Souu^=+nbx*3&SvC=` z1{ihParCEnjHy~kCOP8PR5yo0_jh4LMjEda>7bTf=uj)4=WkRutSjE<{?;ZdC#Rt& z(N(NkViQkPsO4K-_YsMFtr+&OfPOi9If>Wb=O@&9xkk+$O#H`tp9HDy<5aivZl8UF zLF+J5NDtqjl1i4-F`Ifm1(r?Q@8eD`Za31Bvq%fG0fe$pWikDJP6T5Ta`O>&-%NSb zI%fMjhk=^4XEF3W0A>4sRANQUUFrIBpPxv)zt+3^brmM}jB?E5NLibHBndz^5T7< ze9#FP^QKFiEdHH&+q+|jlMPs(t1ZN~-B81I6Tas9FqdP}Yn$)!%xd%|gzya#Iu9xj z*~rpO0hDWA; zBcTX%OVc%`^FDrf!Zpr_e5*j5@QxuF(zvykcUmqPQb@|v8iJaOfVdmKE>rX<(!}xM z*-9I<_wfsJea9|IEt#8>&qqx6ECIF+xdn?yK9B~;)2caYhvPH?C|O6&NLKsiQIxvHrb6@B3>+mZYQkytD! z^$0RFttG*A6isqVsc0czK7)%c&7Z2@AIeXp=Z`&qH>jf>sFYuoB+eQvZ(n<+eaLLL zP9`mkl8ri0Z#`*-uih$Prb4>djPL`JDRzUG~ zpIm0*Dg;4v;FhqH8`#n;SwJ)c8a95Sw!H>-ti)06a|V4_Yq=S_i znHr|~gw8B&3H?SF-B(SH&H0g;Q(prjO)V_#2L213 zju?vRY0Q1~^m;vDVD+S(IUP6xgC=27zY|X=XJK@y1+!HasZ@k)`h6c3gH9A6we?4-1C)-KE+zqW!eG}J9Zr*7Vcp+w@gXkh(lgx zPN9H*fM(WTLNuBCEPm2Nm*Ci%<_jGT{`9tp)Of6GYo`rKkd<@T_6HC+;bQVf)<)~* zMTU{AJ+Xldy<0g!zaLCmgikR+mC&dZ7kPpfX})wsOdPoo+{de-@=%7td*HgNC{z8` z`Ugr1Be(n#2gVUXn9DXmTSd&)CksIFeC;I5ZYG*`Mp&X%N zXF4D8mJ`sBaCG%sq2R!vcLyM0nn_~Yig2D__DTR=+NFyBVy}PoX=wv^-0^V%Y|1AD>G8xkcpf%fnH zZrTS75BT^E^mvlL!S0Pe$&6M{x$x$4xX=9$99t^7pzDWIq208gS*ylLjw6U=gNT7bx)XP|%?9;2y|(+e*Q5qM&y zw-K~VA^Nox3j9sN*u3pXg?jHVK9^V=*;c<+>i=H!5OvkUk!|%=DKUkmt!bC5q@HrU z49~HWM^BqVHtcPvs}V3s5-;oLPzi0A^v5waK9)^v2CT!kA5Tk1sic}jvwzMxqk8f# z%EcD7T-nUTF1beHs?iD;S9M@~KxV<+2R<8@(~Oq2Fzp|*i!7AiWn-Kj5NZBi2_r|N zeV@Bj5ZPeMgFC^vkW}v-y)T-iELsyFh3pc+oVGunP3n>lc=)kH=|YrEz8WBl#Naho zwcFCKa^GCK!<>503gJnByA4~M7x%OI;nUR^!a_HDhQVu9OJ zg?@iG_g7>-O_Xjf zzE=FmuMt#Za${`KR<>lqPsy#$Rk1<;-dIf76MWa#kvA&cw1x1yn;#`QW=;Xen0OYV zmqXdQXL;w z?_Kj}A1t)V?xhgj^FFh5QGLQmz!jPAlC8N(Ue*YSRTF$9y#+@P%sfLlvLaEQ)=Q?EAx?LF4G|$WBvBj4*nvHK_t5@$QS?zK#f5wJ$;1|gK5Q61^lE9>%fqd)R zBNQ(&|171^{b6tNR?|&)Qr;CWpEO0n8h>skT95U%uQB@3!+`u&tQ=!CMB4>8j*50E z>mRkvNZctHXFi9J?+N`>br|JPzEivXz~VF-UVt5d)O#ty%QT-8#$v&9_sovS$e*2F zA$AP=3f4bhRN!<<@(0aOPso#G!-Ia4p<7rvDDOXB{%jS)3rTf9X(BGC9FTzgeplf0 zuH{>~*5|fXv9j3JoT17A5rg8NbVTL{tWq)%MrYLWQYyq714H92FF!$<_5+0`T@=$3 z%6K4p6lZ7W24xxx%<=0^oe?fZ|F&GG6t$Lcxb<>91*74_Mo>fDN-43CoP_He#~rWm z<7P@1@~iINo~zdAh(l#BMkH^#O#Q>JU=M+j9kXL_1)X3wFbLTcyXV#6eK58S+|Qm+o(BgqE#E+YnGoOitHRPpO zY1gW%7s|VtxXTsGM)Y_Mtx#~62ZpQHp1I>+>y{FXNwQJ?Pcw)9+U)i|dreZ)+K~+L zPF;YIl#B9qp?|M*bj`I1l}!qwK9q`&Y&hKF{4DzryQVf0qjv)Jrh#8Ua*4eh;!3b3 z=zWwiu75|o*}hT)BxP3{)L*NNY3@#o4n1H!32}fGxP)dqQiMM&&SzdaX?|!Hx{r&NU#7m06vrt;52T6vVl-h+d8WJ7CpM-YT?)OA>L35&(Q?*j(ADiFF5hC+{ zg)&hnhInQ&kbF(Inbk;q~%BwHo_03t1>6kt5d-K67 zPbcI7uSl4*YScLDQtp^u`sd`{Hy3$oeJAxYlh#yA%R3{f{uO9E4{_G^kpRIXr%W9Y zxCo{n?s6M!b%8&9CtAZwHTgx|Wo9qCWc|O;Kcn@^B|@OCD3#Ef)4--OzZ1lvp~E?bmofW9cwi z#k!~NFE!mKH<+fH5OZ zhELyF2%UzjkWvFbeGW*>nl4dP2*y*26BpQ9;0NVucfPy8)oyVAI6);)W_Zfe6Hxpj zyPPk(q+Lgj_72}R(XNr9h@YTf4uuUSDEnNU{qyG8H7I_k{nJ@w1uDb)jea3SA`2xi zaZ2c1JtPWBlnw6!1K7h%h6_%}Q@fTHX~E6Xh&WQOtMWy?_nv;cK|@{i6oIW$6>kyD zFx$be2#SER*ZJEF#zpjL0qhZI|8mTB9p)TZ7TEyHH#0B`2>_TJwU9Yrx&QXmL_FNE zIY`d7RL#*2&ezc|&v{a?(vc%NbrGrKILs;c&F|#5CKSbJcY!U zP&u!tys}^UfNX;&9mq4|vjxXd32XXD>6*RSOb5zw7`*l^4*zz8pOLs$07&e*1c1{5 zl#PPB9(dyk+u1=Dc8Ac_(JMb>#UBN!4@@R0_)e>oq!T~#FNufTXQMG6xgJBz)|MF? z^S&$d>83Q!w{h8gjfz^hm`83 zU-f?VXmB56YK&JND}ouRiE0n6OR}PtI7e*1Zn|O$z6Ih}OLhJNNwCla+?na|@F-oU`gtja<6T0cF2$CjS{Q*L7q;E=1lawtNfY zBxUt4SJsiGb?%8UV@9mKBh&0Fz;~?an9l_UBDYx_1a`wEnl(8VjpBbaJF{wc;v+u$;y6GyAN?W$ByZ{~r zv@~58GTo8jnnVCyDxaaMi@e6NAN|$Yf^XaJNUAeA+W6M4#A$a&Fh{)ko&wKqW~=bN z5rQu+3IQHnyirCH5cR783ssXCkMv8Rs)J-7Uisl8M9%NF9+y2Cu$%G^xbpnEBZk_I zFsgR&zab*BrB|Q`g^|36=bprS6p6U*Id-1Z$R!zU!q2fk@-eXoW`uq*9bg7AR6P|U zn`M2dU{dJ^(#_ZA=@(&~_DReuV@qp&2Awo13Vi?h{N>u&^dlG_Gqgew zvjm@u2G>tFsiz=y40N%eu9OLLT@~U%8%}Jl>(2`q&c!bYN4*%NZZrPTpWC%a?s4hm z4oSyLF8u2y+?6=VNBH7inxKOXlXR4X=BoHYUH99(!AASkP)=W3YcI)Ll0@q|gH{>H z-=zuuwa%Dn3;PFYmddUfteKy`e|cS3paocqs@l@}x!!7DrT;C=S&uOffaavgIx9Ca zpR=EM`Q|2X{WcCb+AUmNT*wfcn43Z>l%z_uXt|Q!G@rMIz>AtgLo7e8Ls%aEB2PCk z#C|=h1lA$_I_&h|;-5kWJm&X5LUnSzG+J=Lu;iiOe?9a1hE1wudS` zVcQ0#N`zh9`cllMQy8Afn~kVdn~@u2$E}8+rdQoO;o8colLsrL(A*)4*)FzQnVl0K zgzGTW@$0XSu4(Xl2D?Mg1d#n~^kunqY7-G{x#`W~PUUY2 z`DG)Mtv9rodXL#Yzik*;R7SXS-0H+K@GrK35<8^z41LtK^-^%yXaX3KR4|jemd-p* z-gVpx-uQoo76KfTnkmjB;ZDPMiUd%Jfyxiq5w$JahbBezg2FdlD3Es}F;RWbbs=tT zB{s;njEREa!Fy2n^Ne%-Ur#eX&PExU(+swZvYlVC!(B8tbR3RdSrq8#6LB%A>~=%w zP;ZY|Z=B{ty^T(uEoC-N9O?h44X}Q9~J@^ zCTWx_wyrV1qASARVmb?=gG38WurO(=Y2A8FmJhRT=$~W#Dj3X49|Diz z7^0WJwU@(nox7Hj`R1{kU4p%E3T*kB{Q$_ma?5~{X?8+YU{PjCbEt?)>T@5PCwTQ^ z@(=|ff2^u$vQ;jJ>-yChQPmWeRE2o)2;b1p{oHhL>=c3GXTyj2bsLIJFL|Qo83497 zpZBeTl&BI<3MXJadao6?Ryabhf12hQ+^Y>>7+^aZbd9RytvcXMYkv74Yw`2R%50SV zj3X6#yXWR*q>6b2W2zlUO6c(g)gEEKfR3iht^NDeVho^KP^nvK5kq zCisF2kM)N;C5*9>!@hqNlivY6sh`HNsFG`{z?i>es4(P;mB8t}_o|r4z(QjZ?1dwz zMi2LSnHTbI1+Cr2`De=u9UobK8+Q>p7WmSV$%Yw49FhIjK?gP1)D=Gdt}S#FC42;Y z=U1{^xyaq_Wq!;2GETxS^g4|;jaA9?ui#nQewR(z=B;mX$d4X8kz4;tfTZF7F9fYs zXBJzj!xh>D?b|@$r^tmM`|LC9rtO2T1g&$E+Rv^uLiIL3Jq{5V zP9MOxo42eLCx1&bEF`+=M9d5igcVBlw?!ExO}jwT)cb`(v6XzK#n ztG^rm(xZ(jC=Ri zlt$Y7yvy;lSSn6FQT+=foVt+kp|4ULkX<{El9ou(aM!T@=vQZ0hhg^_#eQ9alN0&g&k9Mjw+RJDI3wcBvXaLoV<>pR+xv7!sRtL~P`&Lf`wxYmUi*RT((^p!tJDk3HcWI$a3?PW69 zcC(*!rD@8pkiPn-)A#|pnXn~#N4fKs1zHgu*O=*AK8+WeQS;7UvXq%6jGn`LSvNTK zuVS(cmQgnXEpr6li_PZV2pfye=VZ}Fa>0mgLVBepX2X)GD}@|V zb)!_?Nwv7UJG;RW@PvD7$wr!lD@wupO)OwfXrknXN%)2TddB!I9K!>*!S;cgvDDD$!rU zdwseeRkM-y>3!CR-P3netA4EcMmH&BovemFr^$7edVRaT01B;Gl2+x_H#8ThF0_Tlf4Vfp#dmxd?LyfB*fN{co91SO@UJ<0jC+c#v~kKyNo zm#O$pcev>E2B(!B#lfjYOPms_WEyVmqC$aqSr%OEHqeiOpSlBB|21RMJw{- zBXqB6gt?6W5}i|QrUcZzkWni%z*YTVNbBbU!WR2OdgzrWMW4Llkv3}U5J#o-cgUVk zX+NCRSm;yKkPxbfJ`Q6NbBG0&`1hdj>0jXxM8zrIL3Nqw=bV&M^06;>4_=mdPz0s_ zl0arsKJKyQ$_Uw1&>b9aiat&J@wgBj{?_C{z|c^UiXhV~{5!oM_tqb^G^XR5KT(?X z??OkSGlE?w`LNU--`(5%%^V*X95k)Z!GcR)oPJd#5coy&*)7I9Y+?%VF*He{LcYJ3%i`mAOf%`s1w-^&L zxpl@!Qj}giaogHD#_rLHjToHYw8m8_n!3N#e!9@!qR+x4S1hokJ3V(!%$EOHRCP!G zq`1Q)(`aewsq1Dv^uWo5kfh0ts5WO&W|hHgM12iP`KBxOA}maH={pltx{>)A611)n0X`2K{0eQ4_&YxHrr_pClG-U;Rm@jB zs51~h=z`Up78|gQ<*yx7xfS}Cf%C^1QZkzpH~WFIqmLqt^Xw?W|2|Td5|M;s zvuLU-VRQ_KudznxnGSkV962;kQZRk$qi=Mn56-bbH=5^8#BvgW`ZxUuPJsd#W`gQ{ zIVmaYuJ>GwRhPe>8Eu~?xBACUj<-3IAc+CAPL^H^UvB89P(^2rYK}bM=Mb;<@S)f} zek8e+DCpWPc8bkT0r@6Lfr~&A+49=92Vb<1p58S)*lbHul5z9aS`Er*u@iZgt&a~Tjoe9$$*0(ZlC0Ig{irMR z3au{|$QWxc&yEl_lQsGaX4~0jzZ+-A#@(CsZ{2;9zhZ=$ASM^e%tYVE{kdr`p31Yh zda0V_wAES^=f2BO^JnaoLznRy#d`ZT>jc`7)Q%!nl2l5^T?XYv4jS>$D*`mownTY| zZo?Pg$9TGBadsATv6#5{$5Z&8g%0P&a*vfGv=(8Ypaiv-#=JLG&^&!O0{=c zOYaMBOLRPa6Ze7Z`x7ZHa>U@pzdCY(y9{GzOF+OMTqVh{i^L(4MWbKu_)mP-(~HUH zTduR7FDduhywh%DvT|MT-_8f^G_qPwz+s0|Kl5qL!Fu4V47A_b1;SKs-PYe6aZ8#h z=CUu_jAmb06AL?*;$5xy!Kh`|A*Y>n+uJ-tg)&6Im``#w>o--}f^faSvD`G$`IZG2 zo5xs=iLR$QAZAL=r^802F$L`HioEjpL|&-SXky641g=8bp`8nx{fONs%Bc=hu(^a9 zN?8KnudBD0u_&;<32ol>Ty)F?uA}wz+$HUKHQr;Jk+O{169IOrpw@o^{1L)iI=%9% z!Bz;LzlwNYm<@ueLJ#wX=217E>@dL>Lf0I)d)2Y@;Sflk9&wB5Bz+3)>z~28lXp?z zcr$Wn4xn7pd|)ICwdjR+|C-by4TdR&KiT@xb&+)E=9*0&ZPCYTyljnm4kkqxugGFW z?SGpLnMM(5sWLVNw}C-vqg(-BHs`Y6#X-kSga*$U?N0NI?-&ENK2y6%DK2e9;)b&N zNkH?7(zT1GHg=&%0_UBkQ)rC5nJ`m+d>1`BdUJPjX`)VECWgext^b(e(M}C{Gd=b~ zL-USX)1x;Wc2MdvwpS;AWocE&g9sUL0MeES+I_tJp#$=4;ohYDTw6&cwoGOFb+*Rp zyQFu0_fOkhVoUWth3HgP&(>_`Yp!#dA-+J`&P1&S)xzj;X|F#lnfkh0Jq0vn5mFWt zHD^UPGa$wv14;jGPjI!rT21%o#i0B_~k*hbFO9RXY9_}f2Mg`lI%)}(}$_27dW1CBJ(@thu==o@`!{QF|O z(s&Ndsekr`-_EabD-wZRPsd?@@pcD?<~Lf(1{_NQ6k>xdUEM<((-a0^=PeAGUjm-R ziVQ92wr1zq9&NP5oowx-9YygRXxnr)&e>647W`z-u#K5gREi^myj7DcUytl7MW=%1 zj1sIaDfs%R=v-(?%{{UajPbJ5N|nLI=;@m7f~h@;k?;msIaRK0;0%1llXp&rww#^S zJAn9q26~DMWgK7qeB@MeAvq}B3Sk{OSDa->+si5s|D~|KcQ$aYtt3AdK4QP5x6`_k zPSKd5qiOyVol$gX^%xunWRZ#|5`SvRwh@YD?Fy8jz;NVWw()-WT?$XG_@Rg%2MnSf z{Hbe}T79DF=D^komFg@2PTeUWJVlyQgctpCvs|wq2zK;XxkGts;f?^Q{f44koC7B1 z3HY_#^F;SpRVWh?44v=2=;;}ws$^M_4KE1TkinM$mLxxN$(9p?AiuneEGiqmJm(10 zI^dq4Aq};Y2n-^Y=J0`ipvo?{yKISz2!!^c8>}8H>p!*rvFGWx69<2yr2ThUC@Ufm zZ2zhGRy{k)p<9rbOQOHdGcgpiRfPk1E!py*NJvy-Bt}AZyfl4g2wM9C5G{S? zxeQ$;?05}`IJ&6%9A>4Gf~H;oZ#p2u1J}|p<>EUsDhykmWBK%lIEWYfC7DHnyVQCP zg-!u|5r3LG$4AF&{L zLckvT!bTjKqyaB%Iu_NNo`DsOO()1 zY}Yc03ApqIoh$z|%A)#UU?`T8w-GZiv$Ua(*Bz;(7W`$hr8K9E)u>QmrtGn&V)%hH zR*8aqm-9PSkl`jNIFAWmJn+JA9ZGS8A5Y|@N^hB{KVvxkMYbg%R+7dTy=%_u9F5qY zQ$M%L?T1B?STC@N*uUfcEhP5x5)nr19ZM_`r){4=a${0wpJXSz&}psO%IvU#i=aG$ zlZeA%Of9fjP)P0=%$H~GRPGja7O!^w;Y5S>YlsA&uID<=FK_Vu1~DOOXv8v9L|^ek&!J`b0ML zfs6#u-x>Y3L{Eiyo37D7*`mIN+XmM4nnB6gYK@3A{&QG|*=R$P1`d4`lPoLf=bz=L ze<~JJVlNNz=a70p_`2HrOT=}}6rKZ2Hv_({b_v5BEECM#pMi$YLK_w{rK4-B&e?UW z&w_40=#KTgiBevUn_P$fTO$IcR^b(_Tvr?RpFp5NQDkv7=wnMisHjHh4|dL+aQP2+ zaYqf*JZm3ZojOF>sK8Z>YmzUo#YI8Dqmb8+!=WyXa-f<+N041!peJ$CY}tM3K4 z6-sKMuJqLhWsoB7aa=EIb@l8Lkhx3D0eRx4g3A;)jYP4=<_ZbZ541H@xPdABR{a7@ z;^pLasPGZ?j^Tn+eWu|zE4G>_?+BY<%Y>KUu{an(wLp({J> zMa#1i-5f9jOKe+amAAA-Y(~_1US32&J^;LX)0h04f<-uJspbKbyCb3iTZtAu&Xx_4 zwfGkM4-4B4e-BiNEdx@3_ktP14hwIwgxfuNeyQTD!CX3p20yAB;*1J95+)yYF_ugNaQTV&fTZdTd+I^*J|@7Fkf zDLMa`BjaUgA-Pl}xll`YNn(VadohLcfkw9^+R`L;S1!B=vZ4C&W7Vz)4}T|~ShpGG z)!TKaW@(D?A*m#iH$gxBmS48Nc(q%LjF_6P_KXU44&+t$yG>I(ttX~&|Lu565YOS~ z-}O@|uZWRZwa`MBJyEEyhu6jgYP47PJqj$mg3+pY`s2$hZklBu{tZQ*aGp_s43tOJ zk`P&Y6-70uUG(n;cws3-?!iQG#xtH6L8qtr49Sb6@?=T|%r#mauhN(sZss1>j5~^V zrq3TH90yhiYDT59nk`83qY%wryhFMu`6uroUwH&XuHe+ujPR3h26w8^gmo7}Ozv4S z*?i=+b&4-LUKR^7p z4pfX$2IcP#`g`gdLs3o4fkUqvJ zyr{lOGr}^7mC_Mb@$T;<@Pc~SK`OUkoV~tRD_|wU+RA>q{bLb~8Up)Os|T4hlN}ZD zFdi<$^iz+=OPFG%5B1m9g+bm+xB9%e1L0qh#@s#OF36WZa3<;Y5iH;dUvp>ZmhqYI z5Wdu9cE+SR#~a3U!vN|%AN@)M+*wlzT+!~}cj8gwUlFl+NivH`vf~*oZy@1l7#7cKb zgY;5LOQ$qTNlL>4OE*g{tO!U-NeHqaoj20m4I&-S-2dk_Z+7N0%$(mj-|IRx-7(Gk z?hDEHF->&}oyAV{$`k5Jd?0HM0ZQMiXqTW3#}cW^FDn8P(%%{OAGAb;Jm{+Ah{%Nz=sfE?(*Hr3G&?Wo{Ox>~aO?Bw zY_?4uC3ZJMs+d9Pq;cMiZRV4cltXZPkX)U4P=S8Sy}~cO{z$>rw_!|F_RNX+f~D0C zflPY>5%cd{7_CZ?9^7a$w%4jGqFhqu;@;y7X>`w*wmw#ePZ?Yo$kaO5~=&2fHl|crzE^vX^X138(4vi zy^91#sVHBmP`|9|t9}J^-9{8;nWmF;U=hmrvwQf!67}7lM>R^Kr*S#E#@8g=>$*&F zH+0S@vw71WJc>Y1R+B3~U4Y16e3RMHzx7JAyti=u)FAK_xS$PkAClsm*jk41rL{iK zrGHz;BgoeI%5^XX9AN@R z^3~`@*8XvzSZRQqrs;vHnJL87+y}fBM?x*hnEq0F+c+nYAFyS@6KBsJ5Lz~SW}iD= zR}+A>W}08qYrj!z#OY;reh&MK)nc>!-?^sbQI7mjVWRU~-AT=#rVo z$M0G7?yqcCR>f}Ohxp%)SJ_9kcDD}6&6WudaxJe)Hsx4ghX5uVRKw6Xg{oj6LQ)k|-*S z^*F7&0{1XC3NPW z@1gB0p08OHSBIl(jx8LtBgHSi{S(-u$`n8o9T$UMf(Yd`VdOKY4_?-!$k$aLHeVJW zvgBq1Igqn8*LZx#c+w+lJ``mJ(+e|u2P%W;$%s=qb|X>Nw#v1bAa_e)18aC53qe2# zROyUv7SctUl$sY&6QlAQ(c^G!O3K%GeDD1t{Vk~paox}j__?lAUt1w*s2$EgOEN4Z z<~h&cdnfbH;KApvPmyc~e*VNInxRWd2aNOHa|{3mT1S$_`se*K6y@C8Bvvh*l<#s| zW8As)Hr}FzL(g2BqPy!z63f?H5WJCWWtzEDuSP#KJQxi40J*I?U%~5cTYO-g0t`YV zpJjc5PEa$AD`Xe|O}+C6<6=3hZV9lw3IV<1nWdOt{mxeESz#*)oDzXtB)6Di!4TRG zX>nZXiTwe)%Y`22Vp!_EjfWmjA>TEDlLMkFhv3cxuv{(l|1?I5ScJ{Jo3(_lE z*zu74X@#7C&<%%8h1hUpHA|mXErQFL?k5R*Y zDNs(`?)zo%2@WNfdn`fR#93V}*xC?%Pr`lk=QFE6UrRhP#r5@jV$s+Ga?+S3;#e}p zVL1tEIzoWz_JTfdqrOD&Dj`f77C@P0%!CFBg#Sb z@hl=gds{qK4X2W*tZmL2r<83jLiG!7$z#b*XiTC})0P2*Qlkl9u@HN_YyZS$TqVD@ zsyY#9HKL7cdr($wT->FN&U`_*$OJ3Ud0{=Jq3&u7?ZPgOb1Dz9%;_QD^)nx^&)h`A;jfx&#wvQwp3#_F(|KX?VXE~?g9NvE`!mA_| z$tbj5zOSMBlAf9JS`JrHbmw3|7E8`a|IGHbPsw_|i<3Y};rDZmLvkG;GxM7f@HPMv z2@D&ZfK|$;88N~cCDBkX$o8_oK9XNB8>&Z-{LXHoM>?nz9>9R=Xs1UYP4ub%OPIYO zItsI7h~Rr5KT`7D%9TqD)ddt4<&TF96;YJjyoaBryFOdN$6*yUKN(2y9FvSv^|IiT z%pCtd4SDm!;OMXDqxX@1vdNfIRFTAfzdyNEFS%pP30v17&l&cJ+)K>be_~jcW13gn^A%!gW~)wJ+XNqS z<}M->r7A2+A4kf+nY{Qq z)D+L)>bWL5?bo{oH8pt^jfZLK-vYmVA20qR=Z2rp;`oDlWwW{8aNBPZUE5$2YfsrM=j#Uph&0dTj1bDFalmf+P`K)`ul6?~Nu>|O-KR?+l< z${*oS374F^8#wyk??=ti9`2GZS-|mh#WP)JCoBvpsCW&cMl7^;*Hc|;0>Q;)iY?0X z^^4FBI?izP_jmYcR;1Lx&Hfpia>-rpR|A|D1!b;ORw-rtV|)A*L~IAXCqA0ZFN7`o zEagz9Qto6-4&&*8xBt5$GR)KT_9F#b3;z(Huk@jpi(WP4P38ow>xi$< zW&052D|fCP?oo#;V|TKBT7;5TRC?mrO*=2zvo}mfs3RS+qeaVO#J+i_hBZ&9lT$fk z5#{tZH1BtbllQg#J6dKS*YX-^iN8_^R(bBF4tzOYkmcAk2I|4(E>up2Hf&#SFma#H zgGV#=_VCp)Tvw`tr-9^|5`ITqX8Qx>!}BkHiznF#78-|8K>qA<_h`<;xOGl4j33hX ztVP_iixCifqptD-p0n$?ETi?7=B%#so|daUvxmQC3(=XVj(E1s7ydl9@$3-mpGEI% zx7xXj;kJ(WW?wP&($DBdI8296DJXRFEfK9qY-4`!XA~$9vYc4k)d1nelX?_!8+v>; za}-FK0$uu~oux!-^_}Nb1;T8i3s;IADXdI^6!AiZWbMLN(d=iIm{_;)L#LT^$O51P z1G;h|FYHg#DilU${QJYIdqfr>>zwtWTQszX&b7Vt?b=Ul}o) z@oVYdWcEV?@Hr%xJ~5X(PCUrQ=`h0V=rm9FO`F?R%_49Dd-l$=k=)40I^J#pLXedA zt4iXyyQ*n%cAc%hn_v#&(>acSC^Xl5_=~CD{yloQKeBo`9LXC8pVS=12B{}72PI6{ z9{0BU@J=4RMMciI@?NyhaM?cBct1@vG*g~nh2LpA{jL{eK0&Q~QuopDPA*8OKoUdO z;Jfg0sPYZFT(FF2w@yC!_bd#8F5jO1Bt8ndgO|W;dj%L@z=uK4zcsTsa<40DzqWH_ zmxuNa?#XQ!ifUM>X7dW#1^f`k52_)($_rx~@4f@*O+Es8Pzy!<*U0|e|1pFr8edQS zd4HcMAP^4uvDYtVB6O1wmQ?Uhcq|m0k{72~7i-bgPjmumf^h403@m!tiEGt*IVga0 zbpop~d5i9^gBoKiwy36wkN>V6(I&Hk>%LmavL12IrcUMtbZYfrf1mAQx9Mt$t{}DH z!jmWsev#Y$!Zx9i#HM+`wm;F`CM4=#hOFknZ&^ZcT*iox-51YQQfPH3liiwZY_9Iu{;1Nvr z>%L*wH$@e~cIH5Pdjsgb!}}sorFnxH#0V9Ht4k|!uKQ?~VGx{HEXn+Xb%$;W>HjfB zq!iaXE>QHI1kqXGNxHyCPp$U8k9rSm-<>}Hszo%Bn%hU?#Hm^@f9^`A)XdBhn30v% z*Q`xjSOLjdb%QM}%4b!$Q_%w=a{ScaoLw_GXe99JtycPUVe0P898BMqGfO43;3^XI za)YxhrEL&Ku2c;6_I``_zA_eN4o`nsUe+&sx?j|K}*-41MH|%GYF*K|bf& z>>y?{nq&Ife#k|npqy}ZWb`r0msb8GrXL4nY#iw%~`!BX}yYoo~IcC7GYuaZy6 z_`hS#9!?k@3Lgse6X-_jNs1lK>xhwy!uo#9;FP8kr+Yl~_q;nw*xk4Km9!!4ur<~| z&obecZqdzzXVZo+l$3T*qGGA`g(hPscs6<~^+f@ZwLe;LmDaYrKDx1Z@1wT|b%_A- zN>Gh2Rj|gayHAsen`RgnW?f`PpVQh7j7 z$4i~O3T@OLgLeM4^tx3DG8E((v+@YLFWU1|e=d%P=^l1aCiTSYdPw0z0Wdx=HwBOP zy$jDcbaP-9(lQ?h`egO&9DIdJ;a;JA+xjM1MVW{`hq+P|=)EUTV#**_Yf?%TC#deY z%~%kdpG%%5*snL|o z>8JB|N3dZsn2tuLYs|tYxQxnSry<(Cs3Tcrv@6$mNA%JUI$8if&q+@I<03{Fe?|Cr zgsC2>_CXhT>UdIwfrJ_h5H^HNq)2_SSH-`RU7q&&FlN;$pSY(gEz95y&q}LSu-LO2 zR(UKguM!^^ZWVGb(;}py(%7VluPs<`uub!hT@eLo$y;Ms`pJ9~OFOhd+j$}2av+ob zT;gw(7D~A8-(8S>uQj40mJ6!2%zjG2DZgBA0`I2#y$!FUmo#cUZeeV@BY2}9gt0N( zgRtLZ%>^7SEe|HkitqT;!QZG72pxo!uzrEm@Jxm883{yTQlZ4hjC z`S-&m!^7hZPywpiw&TalHJT|!o_jG{LHYe?WPb6}WeBd)@i^lFL)cAK7af&!u8>F* zV_PQN?UZ2c5iof<-`dA`S8^YwvW_B8Ys3m6d9l-7_PutVxBa<|)hRXRb^7AA*>Wbr zW|_{yyzA8A%3N=D&{oHE8k!+zSHlspy%X89e9f15ITkb^{9CFex~uXX6pFb+Q{gxK zjL-8h*!h4d+=@ve!De_~T8Q2&e@s$23R{=f2tsM$hBI3;@tYs^!co8dxmhZmtdW5g z*5*l+8$nwf-J5ugUM|Bd@rbpEkJ1SR28{{FCg^1^*_Mu~<<+RBOa48<^+0dF$edsG z7v0)|4x6J1L6@32e1U$Ho|Tsry9DPvLR10MON?j<=9UyoiQRfFqO>~k^TwiWY0OkJ^dc9icX<(=*o>5aVf7O$v7WqjAd*?$5cO{MOwLmI?znAlC&rXS25Osc+}=k*09Qv6z~ZE+@C>D>S#3w zXBAa=2GM6H%cE%A@kD9^ze9WT1&!Wux7f(rG|OB>7SATWD?kYVLZ9Yt%7-797p1X$ zv~o>bCf11%@tQ12;9NAiN3rlF77ZWM}ak-zd9>C0Hciq zUO*1F$KNj%Pji2m5dFKI&c80G7-~4WXbv=7{U2EA9I`W5oLJcydg@hnmm*n9C?rOT zDUJ(KbohRT?yXVt$*V}`cnv(yH{tF^3J`M4&P5`~<&@(0!xQyET<;(S=_I;(88ge! zpXoT8s(=*-p<;-AdD!p^@bQH1zfQl6|w6JV&f??frlfp zH-#x%Nn+t@*+z+7wXELore!)H4p31E&fn;fGIi46`||T;#9`)Hr6$JKI7=db>qb=B z=TOU}^lahPJp>R=-MQqA#lidZe3H)83Y=(;K9|<@eAUuhJ?~ITBrcO!8-tE!Voxli z%s%ww(gB(b5$`nC(fEcpOUu|xOPkz(Dy+Fh*&U*^`xSPbzHXOb=Er{cIpWv9KtT=I zLB2F4Oa}h!Doe$Ih1@u^V}m)y)*q0}g(H_toK{fX0y@&E(68^{rrh+~Uh7{z*Fn^mH_M%*j5ebV_|4#p}tWS6b#~$?v zb)fV&87rwm9{un&klBmrdSRE#dvXh?GM{aS0$=8<(Ncj zIE)ASjLSX8NLrycB&~xeGtfTAe3QN9M`9nb)79SZP_+M~oKqB7f>y)&!&rxA-DbA~ zm;20{H^DhHC8a1^Z|XRK4$+c2x1YOzcN>!N_QbtgmXP=4nLzp|$4FPzC_8ahAyxNT z1`=PU7-VLZ5RF}G%rr&JWR+o`>jLtlxnfN69t%8XM@4=Vqqu6B;*^>0dyAqB{Iz$l zoVyKLOpXM1x<)3Yu_ z!O>6!2W+1f`&fF46)R!^wum=N$F@BpU9rhhOz6QN*J<@0aM6A`Q9T*vrAGf*RjOY} zk%=woR2QU+j^v0z?iGp3!#~!6yJ~{a*lj6aPXfDVjkP~PK1`@aDc{G<`L*Si>0@%w zZ4{M`2~v6AW=by3HGG=Sv@E5n?JMy;_xBMF#MQRMXU{ouLSIbJm=a(EFB<2NC>^lv zN_#EA1Ov0&*rm{~G3{#=*SwBU(Soz#bA6I)&xF8G409M^yHtKU5H!&bYbjSm4bIZ$u=^aRpcL)Wg*!vug+xt98xa z8lW9S3lg%*iu;s!fIJ(=wGnP``T=7_CsC1BHrOJUdGiv8K*w^?4yC@3hrB@6J;fwV ze>G4ac{NBpKP{ior3=@ZFH&s#8exY#_8^O>{KyuJJtmmN@z%p1t+Dz&!Pv_^G<55) zTr9SJ_O!y_7unr?M#+20E-{+|Dx{BOgjFqdYqcSB>VN-BGWbS;WqqyT|1SdT%~HIG z{e^3zhA02ZTZ7V!Rqks^Z+=x5-Wv#c-4Inhq4)R&Y^R#8pQvt+l!}p7cOF8sJ;5@% z!x+@<^d}@Rp;Shql-G>lpI%S(r1fH+I{fA{ZyHRvX-XLql&#a>ZU*2$_@M2m>~b?Yr^5)scMBWWzw1e?S7shC!M=z@G{Lxjl8Fs4JkU)^)hpU3Y}xUPU6;b&-E8*+A}kv*1dah?Y^*j`a|daK>VWvJCPd)C;CHDWD_2ekNh8UEfjysM1HjD)3%#(B>PCM~agHNceG*P%|&Rn;~^E5rv z2}5$~3Bue2YJRc~=pFguDP{8fB*p(6zF&}u-G2DN^J+iQNn)oq((+>nlH60MeW|aX)_Gc5Oq6cyX17L0Myo!k@nJisS z=d#(`I>M!GwDnC@I_5=d=>y*e=^a~6Jjm>oQXK9Z?qqwu@JtsPe3aNfLjctTGm;OW z^qv7Zwwg++7WKnA1zmMKHwNISeSh@u6@D^tfmd3rO2PDv@g0iHWNj?2$KgcdWagqN z!L>;gf*9Z|y*pRoS-&r9oGxOjZaA*vIsR(b`T2hTQJLZ)p?hKdE8e%)iRt$IX{?Gr zes8qvP~S)AItChvBs>yE&R*e{vwPpVDUN;W0Skh&N|#Pp>;9SGQ?W}8suj{e}SXBS(_w1baiQ=XO zIdi4YevbTFZN3jp9e5i)8Ns*ps51Kh1?0Df2L(ytyQA0(NG`*Q%vGim)0`;~)98C# zDk`QHz54CV^!a~PCJILby$^jmZMp)1pg}!DLn@7$JvQo6C0j7u(}O)Qq-Wnr|CX=^ zi>T>QQow=%W!%qzJRc&Uy&qG>7(IP-EDEuY?xRrK;s&-_1*a(jVWxd_ZtiMJAT{@B^G}lYfkYexA7m0 z5NqFt78Q=`HNo%&)E0$Mi3El(xc%7!Dt$sQ^}$ge3lanrU)Oo#NOaM? zxiHv92OK1B)s{|c2SJrG2p}-7fTGt0FKoy}?Q!H4Jym5(*;;ddlZok%i7L9OGc=fl zeqfjXPtaZk_*jFfA7eAG(_e4{SIM(1Z=_jt5fb4HwEGtX z`=&Y*330ISdQB^)oev1HNGm1;O}E=u)A{uQ^M>8kQ3XqVFv8rOk2FSP+5Xl#_F2L$ z3$4HS+{5xG^w?Qt2mLF>o~m_|<7Q4cWdE6uj3}#3J({jchmvbS{H~})K%%XW1*{vO zn07}TN{sd&>zdslN=R2ljJ6%*>J##J_a2OEydc$C#N~ZVPC8mZa427^BygW66*|gKUUp7tzd@m7O_FtTM%OO}7@Fp8CkZ z^vBMTcZ_ktl_VRzYP>e*pR2p8g73G2^&+-ta^$=KIJkqKGGJwrS<@K)oce-KoPS7PK-~=DJsF@e$^>BFmnTU=JvNVu(RdEU`lVo zbT>q<1mH-u+ahhlLNpXLlVrA}3M9DW06RTv^LZ6oNl7Q&yBkvNJOpKv(YX*h5Y0ErjRlp<6*`1sfY%>^R7lF@Uk z)T@-@b=}DM2VXp*s*r*|@+SG@b~%_@>>M)j*$Qf+uIa3A4728PDxh9)8K}4iA;H*# z&C`;FSe5VJt((Y3P~N$3*?*7~-_+ceCVIYI=PIByfddr2w4MSOknq*q=*tX&4W%|J z&o@<6jv+DJx8cE#>Q`e}*G@nWmh&KW^)pfLYB>5CdZycLGOpT->~Mf8YTJgbw$>2? z20@u}#qmW*7imZVXchBT{lDlqt4J6y3}0O3ILs#i6!bR$`#8n>yT)7q^xt^U#ErS? ztNt+kz<;U(so~cfq*Pk-?px#=?rH|H$#AC}lgLMAq)sj;B$iWCM4@dnx$hW2NSz;8 z@klTL2&kE_$T#8ZE|pQ^3HUiPCey83W%=fEN)5oD=%IlzQih9pF{BKzy!I%R{Y#n zp?d4te*5cZhGRJ;#Y8w=%+ zUi8XCK24IgcynGZl6(c^^q3=kpHS`oxbG^rPu3(eD{lWN$UMkh95D6_{*d228e<0B zBmux+#dal9=(g|mhItOixZ^N`mMo4@3ca6Wmctv3IUL&*hlf6)9K<8mympPh~}#6P2wEI zO4&FJu*AO}1W5}+xaVkyzsI|1WU964%Ti&X5J*F>T$khC@E^mRWyLWB(YXWYoTq_d z4zH=4dp)0;Jml84+!zo@?-5K&U=IzL-FUy=g~ZToCVHM|PQ(@)7UgbVVYR_mdaE8N zO*3h(rk|;O5{9jw6{n1L*8I5#9#!Ruw|{jCSvDu%rT^unjIsPFCRPpje_WlIKMi;& z1j^4C zAbV7k;=^(Pkj|y~@3HDk3MSm^bS0SM{8hmoDOwH4X$9O1g+WCZIqRBLyo7TIJd1KX zHzF)e#3LFu6c)71beuZlyUh$FbP+QXypx5#p3TW4ZNEpLt{#ss@}E+mG6fLE6kj04 zV!!D)|EcRSl{Rz5Nu3;({d|zlCLIE>QLIzgJoQ-Y(tLMRb_2U)Y+P{+a(;gib3%f> za-gp}U1_{}1k;I)LI`>ypk+l%ItFnDvXsB!KS-}-aZ1rLE>-gJfGT6BYp`UoJTdQ? z$i1au{$M(=7~vWiz^4ppYJhppLZ#lQv7z-$r9NMB|rvrSIk%=&kNx0etg9v6*PdzSvFAyu01$y3!2+sk=p zJhwtA3zlbjiGb7?(gM+;n$CKG;y7M4#%$9E=S-Yc^8CTOyA=InN$G%qQwhgD zq{rcCue&E} zY^!r4VcX@);LUXD^DON6%eB-z1jsebIVU#7@@w_VS(#X1!6e+}dE@Q3&HVQLf&iuu z2+z>`YrNf*lkV5Q=-+s`bLR*=fzstCrWLC_UP`h{XYPE9BS=1`_>!CaJ;$s9Tl>Ulnk$FEmhWOM2^{abd~va<{@tSAx&luHK57);_KA}YoWcJU`O5g8M54syXwSbyrw zPS`<-dzP{1pXyW1*K}Awp21i=>oS__LR(fAGO!sDlxW?YVx!?!%Vd;5hZg*?j350X=zSLVh)+$@sQI6XSiaGt2ial!^6GHlHh3IQtGIkizgKE{VQWXky`|(U4Wv(fm;PC5m1G^XY;n`q4oOMt$W5!qjvco7 zRju;#rYF|!GI=Pot1fv_jBc+c?1{Xw9;U+ZOJ`XxC@|SJ9kOWQP&fbP`K)*8{lZ&u&nb>74uEhfoepT|fC9a@ur*>Fm(F4fmh4 z&r!DcFoM%>s*AUg`)S~Z6_MhC#iC_urD<{Fsg+Ga?!CcRcM9Ygvz?r!u7!h5#tjSH zo%7BC(5gn*hi}|xG&ofzVm#A7W1O+b6+f^Kk#B|`CEf^% zww#AE5ojvlW=lwQ>o!;u0!oPvWj2CwDilIGG%PmlY28I$0OegXuSib8Z`JSq+yM_< zD)nK2*=c>9246LtZ{8pW$+@@1E6Iad#_cyrP`3S-X0ruPZm_e_bz7!f0$u*71rHq^ zeggnGR}vSuJf8T1Q8q}QMUmITyi6JZDYw%QR7qE!arVH6E}40!6QE-e|Eo};F)8)8 z=B49rEjP=*fguxXnq!=r`*b~hY*Ux3silV0!zJy@s^NW`RwaG3hP-V*Dm~gF4(FZ= zm^BHMzwU*pq|CS`5gDP{e=4v;oQ8&-gbl6;B;u&e?$2ed>)ELW-o;L)Ez$|vl~Eb? zR18z!qZ-KoUjHN!GLeRVFmJ@0S`qR%yZ!AC&Qc!}D-H6-WcFqGqffk2?VY3?!AY>j zz;wTznKdr)jyn#6OvfNQf4uFu(n(hin3wPie#O``(qPKA6$4+Nwts9CWX7_*Pd(zy zI+(@l0%TH9IXi*$oj^!Eu~dp-9daDv6S!`b7uJWW>x+t3(NK#c$amZqI3gb^xPHVYN<$Oce`;i`wJhBbFl^;h5Ij^N%UxorGR<3~HRW?d3F#5Tnehl#%U zUA|z81`T|}7aDK_v@;J!nH$R>Jpnpetli*!5iw`uRb*sQ{@cNv%i~5H=DQ*+By>ya z6*oxpUT|lJ%xuNu6wZj`&sKZXZt&5HQ2NE*!2DuAksK*6rr%884)Ex|V(VBgCvWv{ z4PW*|RE37Ks$|SA7SAy(<-Vab6B-*FnlE2Bf7zzKy>pp(Kxg~ZF{Y}C z%$*G#T?w6ta~SG9(dvO-1D_^GMs79?xrw1|5_VZ&w`LYn>e{X~h3%k8b9KZ#=vn1^ zX_|j>J!df^y(mCAVA1gpXy>#18pwF-S8#-H)`JL@bx-&!un0*;XF|BtdR~WGl>kQkV7Hk zw|cwo_|kuGes|r)u8P@U+Ofnw^@IbqG23(@h=U#XX{YZrAguqvH^Vk(Wc+dg>p~L? z#r(~J!eC0oFW-4dH+YfQSu1x>6-hX#VIzJ5(-Q0x`~kuBJf*n&n~oA(OzMH_vl>Jz`|5+F;5G$}#>$ zu)a?%6q;lmsB};Fft|7}CE$HYCqx^DZVRpnrV)94a6o+O_0uS$MD2B<9WsH&8I3aT z`SP8G7iMpK9-MH~kP<~RFz2Se4?LlL0a(8Y498#6?GTvmElgTMmj>;y1yWpQXQm#& zLclaUH%+0Fp)-&~lGUR>QL%7-{oGQb?(WAd&rp8E_n~utlQ*yS12*p0^nc~Ske%d6 zAO$M4iNQycp_#O{fbu$-RnUDu_m->J$}0Zgjq|2`HuBzM)q2td@62^{%TM53O_oV% zti%*jar>h+GGrnSl=t1>YDRWB^U%{{q5Y|Z;+g6(Jfj5Gh`t^;n;18S2DV-|$f#B0 zV^2*W0XY|Vts&Yv%@0b26#83dwOchP>}5=;l5I7tPRhnD5sa&rYX1gq$7x|N(`ugEuw}(G8w*1u9u#3%aIW$A397~>)AU5Rmle{F3w!M`$=|k zYe=On>-}Xv2q>x9Y?*3(9ouQz&~yg$Tc|4EFX1!aY6G8>T=@J1O0t(WsrGya{oZ5q z36`bCpGi4fQw#mG<4R$Z*gDdk7mv_jtULDsK9n$0iiwJ1TkwE{G(s?+C$Nf^?c@Az z_irL}=<6iUkMk(pB%?%Io7!yQ`jm@7@DsbVe1@KMe)lrX7HP^%Yxon1=%uiox}`_t zx%@A6!U!5phBq1%U5VB(0c|4N)_2>$rOF{nQ3+vrcTZ4AeoxK(x&td+>=tM*IE4TQ z9jzWKEV`iCFvmW)=nrM6AMW#cFtO)0hDhyjGK?W_Ot{iN zP)(^ghy11k6T2Vu(T<^ZMy(I8hoMNG-^SmYHe)2TlFoJG$Hl)bAB%IiKt6U6dNGdeJlf=H&5@B5}m&w)YT22MyLs)NaW_$Ck}JEsw!IQ*LvgK#7!_ zbO9!EDqIDqAF&xIL(i>se=a2jaRe@7V3&hFpy;+bwfJM~;To8acKNEn?qZlA#$Kx1 zo%x6PhH46jZ*ohJ_MS~OLr6ozSY_YW+kXPdkR++bF)kML;^LN~5tKuv8u&(;OZ8QY zmEhzGh<}0ab{Ws{mVAZ*X^nNlg!TfAChw=&n18fnX5|@B`L!RcrXaHP57oYp#L(W2 z#lCvo$oUehOd@XhIR(H9>PFfg`2X_U>iVPlheo%7O#?Rn>kxVzQZIdSg-tZUr)W2r zg_2s4WaMAm8OrCpKy8M5+oXGK=VX+I4enw$%5b_@a%1dQN+GBCsxVT38l7*2uTnz~jHyH;U_lhVUo!VUD%)eB19cfN2Atp$` zac0NF7^s;ETcS=v^#u^1-w>hh!>sK*(fa}ZBtFV3XCk6)k|nTGIPM;{{OCYif|$N~g{hU&=pJyvk3>OUV!k(N47IOEjS6z-a~(wes>`^a(;vXrOwvrwuArAJW& zWQY9voCJ<(KDK_JJ@{3rp~E|3JRaO{pA1b0OhZ1OJrxWHbZSmV`kA@i8rM|JX4<)A z@|SGA@Q!cbV1ZXUKDF&{UD!PI;ZHgWn&}#{X}E#ayvhvjEA{L*JG^f{I3-J22tTvV zZZ9lYmQZ+^X~RCDlUVkm>zc!`85s?1`;9VeoN#H+d@caW*=GKSC%L$9(g<4_SSMw{ zRdx9_M|Y9h!b3U5KP0ikMlwppz2by`&8&jO$A^u3uFiMZ#{VBCb)rJj5r{57UEl+6 z`ENv3Fm0SRa|4LXJmn0}#xKk9=~$t9#qGN|h|W@9Gop_j9=YH- zzxs67{`%&)8%sp+ttyydJXLrAAGSfBzqiMiU$8S1H945v5`GbuNi)9|o2(qaJvzmC z0Ya=X6w(fnx_8oSqof_59;&M|y}*EJeTHyo}S~Q!g1`oG< zMt?x>r?tvamu7-4W#E=p%1u!A@OE8i()w&`;?h67l#C}H0T2{7jC{7C_IHp;yB%Qffz zTauttr$He^+MC)>urbNjnr_ue^^Jw#&EM{YhRgF)>LdNx??YaTzzScULHS8tU^mPM zlD_%joDJx{0a$g8IVflBI)d(ovQ*TnEA3sQP+eo16>X%l@=bu0laOWYVSXZ44 zDadsKs)3b4A7F^zJJoGPTw;OVbOi@MTSfjAw>&_1=%!9vJiw6wR=P_w-YGjoB|rR? znfkR>>y&|`;LJJ1*Kg<3W7OrFp#=uyWa_9l1m%Z0J1w5kJZ(d@G}2*tmdj z;2x6(8oAjK&`%M^(;cl_paN&sIr5MeYbjtNa;iFu-D{;-BHxsiyG<9Uqpm~r|IRa4#pQoG{s8tcS$hwz<3Y`rq~eK-yaxCP z`^?V;?uT&+o_mn~X&bfdbX5SxxS0(664D|WfKM^bAx-{< zke#D)H1m7C_ccH8Vpjc&xbBXKQ0ctxjxNoucfn337&+KJ^PFxgKYRT0YUnx~nr)Z+ z7J6y^rByXc)99#;ds0*djtGuy7CuDgtl{)JrE5wiN#t^FdvO`8DKoHqpQBRsjna=~ z-R9az#3;uoh}67I{d$+d^Ygeof<>USATr?&oXOyjxAnL^G(;&1jrl}48wR2{Yp(KD zPW#jHO7C~xJmapct^RCCutU+_&DZcGH-@u4zyPnxCuTyom4M@eg|%41XX<5fk6pXl z@wWX{8?vDN`;PvB#kvy*7U5bGBbMnw#kcZ4Lr|m0NOzqYpk_4$cLQl^qqd>j>>$v+TkQYK2p)~kfI^G8oKWalo$%7(U`l^lo?e>ct2>K$+# z-SBB%AoEgB^Wtwr>h;*1ITlgWmI3ED%Phw*;*uLf3faL?()UG*C7C6yEG-vMMo*vh zAt~YV(}B2w&|4#|{4|ynu`)9Z&D#D*0HXggJ0heheK$;4U9a*>8*5$CZvpglaXN+=n{l7&S z#QY={N2W?*6N5J^S9q?OIohRfB)J61&lplS!i<}MEk05^g)Cs+6`faLIJwXR9`(}| zCGFrT;=;R>abyZ%JWPtSMO|&(fX&#|@tmr>8WX%Ii3y&{eyeF8+SqHf4?Zb5wK{Pr zRF=Uihm~~0XghT6yx*JEoEusPwbTB}e?+Swc+hJ9eO!ny9J!m)5~7+Ka1ayczkPZptqq)%yjDc7^u)hnG#%RM((y~gD2!er|LX&>o#_~M0u_@N90}=ly zc-)CJkLMl-SbuT=B7+CUalmj~tSqLX{)$U^1>m+6(J?piF1mQd!s75eme*9Db2n;v`3oQf z3;AMf@4c>&E04LF_|36$Oi-86>OODGw(w`cYx#j(+txeF26wd~`EqwZxv| zsSyyg3{-jbCurXC)g?uSu53T!jJ}E3Zs6D~gmB^3XE*W)IU5Ae5kI6T$7hS2@Xp_a z#ZQO+a~@TuCjUmekcy}jGDOPpGt|hQk_eihDaU|hcT!UIg24Z6Tz(-M9g=jP-$vFl zIcD(ckF&~4iM09UVf1OzLu_V{yVF)n+|tOpuhXvqJC=RtV++~uIWKkJ8}Llf+y=j$ zQF53!L4~pk*B(m_ktm`KgRA)g2%x1ara+$r{jj)^oVyFbp|`ey z%!V|@iHZ}W?%NSLMb=(L+b$`6HtCyZ-p(xm>|bi5J&aUv)Il+(JYKf>!OoKl$#=Bm z7sy%JCpl+fkyDP3HfJXrAPDIdGlVn_bIj{Su7B_`Zn6^@B%8RrhpzJvfIq`|Yu9s~ zVEOLj^gM9vDie}>PcxP37Z~OYAlN99>ZRBB6_>8r`EJ%WF`v;U^2J+$8+s& z4s#UQ0Nt&6`7pcGsw}p4HXz_mL|rx>pV@CN7;zp2%`U=+{#v^bTpw-AoWxmw4^PTt zsGL&jY|Z%Zo6ok_=QAV1u-k;@^zG8C6fW^jX~7nTEs60&pB8~ymf_;%oYM+em+)Ji zLo#JNvrGCcqtvjRt)pQ#{5vIE+r3W6cRr;@Gy*)e>)4|lEUc9;eu5}n>8Gq?e@E2t zw&uW2XOvw8O@2YtzuZxS)%Mk={qj`&e1TUfeaQ`KJkdNI$x)hZJcW4uZmv-mstuG| z;bo1_Oay^eLOp~U#jkEvdKilTxXPo&Rt1&GcB#V86xpof*vdlS`xv3mAb4NrinuU_ z&0Omi%OLN^pJe|pE=L;nW0M^PFOc3y zMtBaO0>%#uma_n6^Ix@EC@C&ukGzIe+&Yv^H@`1L<{wQZUBF#NcmT&)d6B+u3!`*O z*L1Vth8&Abs5O@5kiOjU-I6%phhvc%imgZL1AiG!P2@mD;700VaJ$zDeTjaCbAK~> z6>f`fc4E^N42_e5CSG{HOFClRD0QS zyizskW?%OIsy1rVVL~fL;grwzXL$_8`luY~k1u_v$WVaTo{W+wJMbhRenX7_Fo|cC zpk-x8tA)un|C4k4j$c6;-(9K<#Jf)V34aR)L-(QUc^(-e-PfLfudB{3lByijjGCV&DAXneX=TVWf)l z3XXKvck4;UE^c>*Kd)a9Q@@%9D0hiJYm7XCoPKBjU8{*yj%I0x{pOCowRFYp&iWi+ zoYL2gYZuk<5Mbp^v1FgZLaK2$wIplSaB~e)IA{Jb2o@vRTBhMSaJn^3IaVMWEW4?J z#qJ*%FVHO#!MKHc8-^@IHJR@>A0;%~KFo6KH)0t6qT1EmCSW(6aymQsV(kt;LQc@PLG2Dyh%sAE&p)O?i?k=RU9|`YT8!cqwJIoXzcRXs z-NC6hQ3-Lx2is{*Ca}Mv5B;Lwmg3Knh@elOe{#_+1!hou=L2xS%l;pGJ&XfGH4!1$ zb^3tIU~ju>rii1`%6}HnzPUxMLkV;XYJ)RqDXQYooA3lpEYxvI#)OhBqv*f$XWKJY z>J)Gh+1Od9Ed3>4!uPCAS0JL#w~Nc|;FeMg6Rdwc=qR<}hjLn9-PcK|jmpZT+k4Re z>Q-bc+an=tK?_t{SbJYDX=UO(?^if?jgcPyol+_)dLd~_RYllKi9MEFl2Nu^vVZd8 z+W3B1b)UzLW}2wSDbl@eHLtA0AHy<4=Qj@uT=SN;>`_|DX4awVN?Y^#q!K-cARQ^p zJU$9IEpLXD2Q-HJh0r6FY2KEUIPl3t6Vno=BQ+HL_9jgS%s~uM(G&3EzshF=$GY(! zcPooBETgJhI5n7|&J5Q9FJ^-tnfJA4#A|ioEiku{jaER}-a^Z!#8I0+J`}77MdyWQ zFtU@&w}s}a2#_+%dr_r_9bMH#7G_&e-sxqo2p1(kRg_8W@Y1#NSrgk2hB{?lGnP6t zs%ME<7Oj#zf4SoY4{c8D7uTF&ZyGIUCF_|@7}kJRZ>=B2dk6K_8aTb z51ag(`ES*HWPTIoa{;V`=!Et!2|VTGE}H%03Of4-t-izbrlossnq$$s;JaTT(MAm( zVo}f3!tM(5AEqNhkN`+l%9aPWRJpF9GGT1?v;+3?f*qX+gv>p_W$28)emhoaAhJ5u ztkQR?CDj5pCIZ`QKY}`dieZpPIGiA|DEZP$$I7h4A z`%7l}^`e?A@#!jCnFr%RK%fw(|DZMvUj>_wp0hwj!`+yu5QFz+Z0d9cLf21GC28ZMe51nGCzK@ zi4)2>5Jk_hkNCU(bi6L_s$08?{(I$aNNJ#>E%0PDwN)!pq~w8D%bh9!iq8&MFf_b3FSHKD=Rh{7=P-*ET0=A8kYIrubJ8jL3UHXyIJNR;d)*#pK{hXDls_vwEQUC z5B5Y&#gNg>i|ylZ(AbgV8ufk<(4>-o64vlx%hcvqT6d=W*U^JF@0?*e`YpUL1_J=* z@Hd`;!OQK_?X>B1bM_Xrixhw~A$M@0%^zEe0-?3B_ zvfvO%|Hq7M5Vam$FMc>#d1pPmLz6+9^-n_6Z#=~=UD;nprHzSaWyu5NcpsOb&7kCP zq%)oKHOaUxKZdbD(Xs9LS#4DN^B%OVTgFbu#-6jb|C@Mz++?5QYot%;@hv_79A-uP zY?VD4i0zfF>SL19A{cOiqfCXl%fpeuG^0;~aH1?l4%K*tz+s-IR5iRI_wWe8KqVBh z=(O29GjlmpBIMq|YHVjZqjU&LAbEdM!X238c6S`8_|sbTt&#z0y$LXnG-5sHdT0Sg zYg4g^H_j7{K;e8s970O zMd)Ns*sUBmsiJsw=(SFI4Mt48QQ(S7h-RK1aZ%$5AHWB+@jkw7VOl9sW9HOUI)mCZ zq9wG+T;~+0gn#p{&kSQ|TN<|z)iNo4w=$VwP*Jo{Z4V(AN{(p6tjQTEhtI57z$hUz z)=ifbxoeX65c*%t#t*NPBJQWMZ|?5XYYVW?U9m-9Fid{upO&$l{74?wQCinu_x1XA z>1^QYi1Rofi)_M7UeHW5Qy#hbBd3yRA=)=_zTZDTQbn!xeTyVt@{3t#T(939~tH zJbM^vy8B2U&}|vc$-wP?0y^x~-|y2WeVJ6|RTO>T4m02x1660^x_{30zTrdl%&ddC z%xP%WJ|<8J`a(^z8rEg?BZpepFBy2{h)pZtL5xREA&gQM97C5nRBG>z(y9Ad)D*h_ z3G;zO=antY$_zgcyS>)=4q{qY1!o~i&(LSQ|HxRwP>I~7Wfw5=U3FP#PDQuCwksse zC9WHLT2dJxM!KKCgq9!M@i;;q#Q@=BW(VJ3(#N2h>0w>7;aVwKhdpn_skntMfMZ&}aC5 zoZGQ-_JXst=4VP+DzFk#i!FmvLev!t+GuB~jWBKU>DP9CY?jqkb6^5~LJZ`h0iw^C zAUhuI@DrKWtXwIv$jV10jI+ql0J8q z-AB9<o)jabGRSxrKbLwaWP7p^vv8NdUoR%xuU)C^RnYm3MYFc?nVdcBg-@3t#5r znlB{c;Z0Gt`99!@K;L?_nNhiADq&fsoDu}$4j>OC5MmsC+N(taxc~2X zboQ8hxpeYe+L?ds$_egkHPTyqnQ6^18rv}RFe5Qq>aq(>lW5_A*AX!C=Tv4c|0*C*_>t%!9x#{Jo8LGBGk}@uAbU+QG3sEH^Dfbfi zwmDaZI*!QS%-v3#cH4g_eqvQm7U$4Y4-o`Fi;;DI>h_L*<=8!{KEAQD+q^7Ki9DGP zrS9{vH@0yP4`<*4sBPNifcz8;s{4G#A*X4bXCE(m|8%4C_F8Vnh+c(kHeBU&0q*CR z0{ei4ht2y;UO4=Ekg+8G>MNb@b;tAI)w3BplQ)5o*>?@1FDeYXJ29NSmRK@s#yk;1~d-%`*&X+#E3En^ej{$@kR&+MhW zYW{AO$bA2vpr3#PEz}1MA zpb0Y9M~Y!z^Q}PK-|xsNPYH5sw{Y={NaYZ6I1^BS#ahmeFRy*JUlH@@^WYsKt{$bz zFV_k1XtVqN9xoF=VBIxO2gy5xizB?Xt`O!0LVe*A)Hx1HQ9%bxi(JzngUdrTYoQvHa#h(Vdy)V!{_-f(7}YPrXdNF zr8wcP1$ARVx07OaKaBL8?rDT$M#d_cDr>ri%ttb6HD%EhIxs-@~_Diy+ zFUGLyjdQ)66kK}q;}4C6{?h!GJdT3PZ1YmOn_JcUr!S*zg20-URSdhVz&@w+e-eR@ zBIfVA)$S6qAT?4lzx=7Vzi58{B6#|JJ)KOJrRAFCmWhGk>T(u}%0H4JEM_9Uo>7E& zi7GgiXDD8_uf@3^=a6O3j*v{FY;eXr?Ix47q_i(yi9|^9iM=?S{I~89LPlOHTH+$R zdn0bm;`)J4cnTpBF+vG2|A!u44|!jRkSo1I)yQhqHj7niLteInZAYs)V)Ym4d!4|J z0UbhJp-oveRR);C*-5@r(&BJ$cD96m=Jrl%TvrO)zQ4<1C#_CitMZf*dq2M>&`~M> zhO_`XQEdgK1Iw7zThiOvY?i!#I^#i3z&=mV5gof+MH*WK{`4FshddBxv1>-?lTFnf zK}hNUe101J(aU(Y-S$69j)zI8FkJZY81^B2+GGiM#~T31?EuP};1|aRlW=AytS$nG zMC}%)Iz@YCiaUq(hju-|y%ZLZj~>$b2Y^HEB?hBoyi<3!2V~m5vN$JfLrX$$i=?MZ zB-O%BTFiBhfQE9kWj8#om5p+xUQL?oYly(Pd8?S+3omU+NSBZDdY`eIFPlaWn^}~~ zU4GiwTB*aW@-Z9< zCIpn~9kkEB&*-_2=A%+Z&(!yl-kbf7lNtt8BPIgOmfbG_s1~@*WVgf}9h-si_vK`? z3U}t+o7bN7fMFgxTNU)kGETymxNu-&e)PGe$X?^aZ0@(-mEw6P4HRmJ2 zi0~$sa9UL?*Zz*y+2D2&MY7!1rB}Jc_;O`?_Y~YN6pn(?`R*pVQEw~P`2z(h$5x1%de)}hR zE_cQ4{Xo}1yrFuzedL0HBwnkIn}{WpTw)nS4;1{;FkcR8D879I#!nbVfg1}Rn~DWW zb&GS5*BLnif(fH>%X$cQHABbC0nDiXIs=8u@AO1!1uEn2f|Ri;uzi15-`(Ki#_oHx zvb@h~B;EHhkS!Br*k$-+af;VM!D^*&>lKm%qw7=f7{qNK?Zh;HM|NLtIz!IKY#d!q zjpBvt$1UT||F5{4XSDM*{(MonQKVlByO?Y){y-H=UgskSn9 zBFSjj1t?C3(ueR7`~{GF$`_WPhJAmzG;08;=bPDpp@QkMf3(mC>FacdERdR|U`ejy zMkEvj^!*x*egfH6K!n_tV(!WW8B3}@s7X)>VB{LNhig5tN(fOwEF?AmlOVme`HTAmTgi`_?uNYp?%ZKgD!QKL4QH5u%~kK^p?q*AkSa$r#~3t}OrW zi;9dSY>G%lNPK@bL`rz$E7ny-1*pOKrD(R$e;|q}`rtTitj{baRKqp3t4 zKV#8`DwGyE3Jw!zrcw6qQmQrNLOgp3I$@TUg@r-BA;0rX0wY~HD$Ee~rc}mhxT)le3Qf;( zPLcD|O?&-l%Tt6?(Wzt$ofPb8Ih5P%s2Hc!xesmVm~4ZIqqtC_7x;Gt@u|E0W)3#- zPXm<1S0UW>Z;yem=PLlmzEv%X&-ubEt1@z$ys+V>3jums^}3PRk0b&*tdp9iqgOFg zzdfb0iiAd*W?i7#Fq!SinYeCr=T2Gx)L*+bGP(tlhTFA+o1U#Q!<{K$k&5pQpwx|cl8Mj)z;x!I^WjP15US1BL?7`x zYF8))$9lk6AC$foVa$J&9{+(#-r&z&5!%SWc(Y;fG|%7)5aX*EQ}4c~Q*^A~Qy$fB z&9E$K2KN7leDTLlT(V(8tuVpQy;Q5Wy<&qz>z|?gv4?y2s{*SmG~f0oF*3HYDI1C% zr&yaj+Co0A)~k%?iO5uLrvdyzpy7m^W}*jO*VHIu@JKxt9~^hl!E;84S?%MdXq8|< z!@=Slh}S7|8`zflU}J?_5+&h~x9cr{{_#^)X@(G^isey@vw=8|!QWNRYE#wOWA|dk z(cL34E2598DcOt_4yBR@u!uS7pDQ>x{E_7f-}dHjBxUOhBC{#PabAl__4RG5P=t1P zSr+H_+*cQzRmCt$S~0{y`b8-5FfR6yt$hF@^_Ptp0k)%J{GyCvh7egC>+9b6j)Z^v zGuMstX8)K~P=x4&BoOUxN84|ro}XcpZi|g8{B@hHehlF(BThGmj})@_V8g(Xm9H;; zJL^PgiCWdY2^BZ8KUZ0uUnuANomatC_PPRF+n6x%+Z*XRqLR-`CVh;e#>YOeCnBi6 zsnsX>d^2JnZWyjkh-+3*L$$e9g%(OU*il-QFsS|wyDyfAc@H#g-}a&ml-35ZO4qHcjOXzZCyNXvUe14tAc?whsV<7@=;E6ABMJtIq zq-1G|j+_%LQ7SngI_S@$7gNIhl;AHWdm-%{ zvwSM+BX&_L(n#yt7a0$T-@=sjo{wsq zlZRvLgE<8(v+8^MfN^%Cqr~UscjN{Mc1qZTelkK4!`&oil!da0flg`Vhk-{5ti?mR zcWR#zglZmrrg|QARm3{b?Ia#!n|sVPj0yrfK$g9F`};_6pUXxdwKa9Q%t5gYiVzdI z-eRS&m@%0pckqS$VpDDS5SkQ}9W0tdzwoE9m3o13d-nUiT{`;b05rg%WJRW+oz^u> z+Uy+-ugu-|H==xA62x+?PY{^&NURuQsFZ#p`uF9_%SR5S#eHCSXf zAM*8xDv`@`YHN9fbl7It zpfk**fOIq2!-@dV%_|w;GLyDj_EJVdFaq`#a<8-b&F4<$PJ`KzDcVx>K|IqGTWJ88 zWApk}$KNn5hRSmJQaBdHqz?k8K=;X~p?^{_(v&{F*yU6_Da0}dv5Y-?;#OPH1^As# z4c?jGg8L!8encJ$g>1HC=XK@}Qy61@M9f{AmxDbT4-wInlPSlHwhL@q=1a@s%R()D>XMzB0i!%VF@$^V$Y zx0ToC|2fHP&o4gH$AK8?LRlnZ;gmvVtmV6W#Tb$v18wzVmcE$=QFY6ZSML%f;t=8w z%8jzqcewNFENEQ*Vcm9jP$0U5IX-w!=E$ht^Hz=npllEw7x~e+Q{{Qj6{wChy~}v!8O*fYo%Zno^_6;vIjWr~~aem-4OpQ33`o zQ|*sR?ipCXY~@Re7j^eWFgV%9QR`})dK#8O6{1bc52)#J%Kr08YzzqWg&n6KUd9sG z0hNGodtpeK&I)BMo>@C2=Z(MQsoL2K0l8k%i__0h;FG#w>Fw5UGQf5!o1M$zrZc`M zmHUKwa1v6S2}Io+sMq!L03P^je`}B_zVg06->AVqH%&rXLJBBSS-SbxRn%51AM)Qa zo|H_@EoI61PJ>j_*SN+x93z{d_9-PMdgJRo-uR&>Q%ZyrXEuI8Wl(Yx#^Y?jx;A*6QYAP~tYR>kz~Fip48PPW;RxA$plY|u+)PCJC#mdh`; zxn7q&>NyL^5{ZvKmu@kobj4$bZ2jsqYp_^wvjeaQ!}4ew$0~Gwncw$ou?*K=o_5+z z(tUjJNI^IGK57mKxeuN*QyUu!hSQa&|KrJLl&CeRHGE!{q-l*(-xiF_j~*am15iv} zA2z-o(ugkZvrb336#PkNA8Fa7;aQMVt!dQ@ZT+X@E}7*F&30ld_dI-$|2boADwU%bQA(PyARLdKCl+6Rs-Q2q;<(!*5PQGtYX%fo&_@jJ5tZEVh{ zW3&*>mDIYBw(|6goaxkO=vFkg>H}gB52ZE02z_{)sp>ibzU>N}jSvpe~HjwYz{eVOMwf;Uhqqn2T}=m~Ab` zO!lCGH9_cHKKKh6;^g5e<8TyT4VQp-2liJjQI zvFoZ&z1kTmUv9W;o8SzedKghx#T8ac2TJ%$Z{nap?5}LmloKFnP6q_gPco~P{T?m+eWb8hZoJz zPcd6VMh9%zHE#**%fAluNZtVy^|ES}Ut6HW%RjZ7Lf=o%LL!$r#}|u>NF6Ic%L`D` z_LN<>bPJ}1j=2bZbDJ`D*59;{#HAMV_N@IfbFE|54`AE`5;TVGN;XTaH}jQShpcXG zFTxOC;@0eBPs=1BURiY^FCZUS=xmf)VpKQqfc@$CsG7Ozz=0jBQ9h~8cTh3Xh?2AKUh)l6Z zU%sqiy4K0BNdL`~mJHm|DSi`~wa`kjvU1uG7`cYqgYaofgU9!bk>Mw}VJbp-JJnnMH`Z@G6dG0wLQV|oGr(O4GfOAK?7`xj?lBhtJ4mQhM zznOVh-7FUN+wY=oj(Jpen&WWCVBlfbKm$kL$g0OlS8K!*m3Yk&*P-QBNhd4%Qke=4 zzw=RKndQ3~GBEAMbN|*d*k1q@%h2MKeZ&WrqSR8$OtdKn{}yh%b3qntd} zt2Kh5@>jRd;CDsgq1ZEdY1ZBK*`TuWXCGm4?|Qr?q+?Bo3(r(^eb=SU<*2p! z@t^kjU$*~}9cO%thE=Rjv#PelFp;p>Xu zV28Hh+cNp{K!AJ&+>R_hi|PQSA{?*EnMcN|m&2fNlG?At`^ zV}F^!;+3-wc{RPsF}HLTFNYD{b$;Ag1<}ZQ<~$B`gZeQRY<6}l`c#+Im$GffOi&J(ZGc&At=Y-( z2l1VYhGheu6CXwKwa-Gsy}kAtuBl#uBg5v9qdnt$+hFcCqKyeEHcXht-0c^qJ13Tk&Q()|dvcj;9q6{*#d6zk7E@riWXN&l;4-d#;n z=lg`C`5)wW2?rmOcsyd?1GDxxtl}n-ZEV1%BkCtUz0(GYfhIMX(Jx`EBoWNXc+F=n z@!$P|PfQ6edkRj)jmoviSCKj`K|oe*LA){bJyEU3UbRPgc6)$hbYQFWvpXWuDZ~Vl zqgbj`CNPxt1d*52{jD~XDB4?`#uNeczWxYIBD%WpIiNq;7vDkLxk>pOGhyKBTl2r6 z&~Y6KDE{uK;ZAtiw8n7`ZyI*o@MQ=aBap;5-VQpIcYg`UT&**@!wBBW!;ngLmt-pQ zEN@^zoQmf`T>2Kwt)nj6+3T$`B7|Zt)p(yJWml5c-QX0PECwgJ;jeO*8mNVN6G&Fs z2RqJ#e=cqkRAFTNAL+t@=f8!C@4PK`Ao(|E$9qK-?_+ozrT*V>P!)8g4h_o#_2TQR z*>_{LD6J_ucgr#uJ^%}RRZhh2%TdZEn>%9*SAw5uSJChoRhb(1_8XW?3Z}B!0)`(j85UuE_@^=MtCI97jxuJidOuURC6if3c|2j78n(TWBFDHU@< zV9*18ssJBh%;o%8QJW0&K3_S0m0{9_tnCY23s|u3CMB#?XYEz)3u3Re6@ryVHK{YWe zD5GItoxaT}f8Jmm^e+Kd`kd*!NK|ufg|6Ja&_)FN6`|$f?i;$(!^7o<3mm%>3}?rh z^BxJRE(_P3l!hKc079^_ofHa>`@OZxd{_rAETI~U*ivSRWC)LK&AX}YS;yz=xJ<{a zh?Oxr>bqK6Po{{b@Rc80RDL^~(mo#DRn4Z_)Pf1~emg`>SWEsV#d(-aS(v47`$uhL zOG0>=Y*QIS7bKan(!4b`r%BPTTeb-xqeM?fzknF!7FkCNnZ#iVl4pDccBeA!$Ym|s zQO2U~-iY?4HlNWF((+`)eF{y&%FQ;f=KFN)kO&reX_<_>WZG;K*VF3o?tI&Ra~c=< zx_0j?+PCq6O4zJH%AY(ta-+^$jbiuF^-v1L4pA2I9Rz&1i65ju$A2|^OwTJv;E#Kb z%pt;)oQiITIzEq(Y60<^$t}>Jy1M}jw|NY3a*Cx9Rq~1N9s=_Z1{Fs)%+@_}>{^8I zm>ptg$3)yaTx1JH1kMigtk5l_ind9+B%VD-b8^#H6Es5EX@kR;{qK6ZIQ87b(oKZtl2=U1CQU}MSJI@W9|tip zyZ{xRewis$d0J9p2!)-W4M%&H?$h|9fQ@4Q1#v4084?^v$PQOD@>>QATuFwzybkSH z>Nr8`ihnZJek(-uP0~p~s)m;D%I*!C1vX!h4~7(}Vxm{{y--$?A9C};+K!84`IJpL zo8H}LB2zOfj>`9yv|oK5nx$jSM{h-nx^bV714YCF$K)RuC~)CvWV5iK>P)1ZGR9G+ zZvU*%>=$Z;^Mf#}`KxB*FWl##OX1sy;W0}>{P}?TPy$MNvaJ)zq)MyM&+S}&aZ-iZ z{DTzPz!RsHtN^DUhg(V=U@wPV^x$1K*Z4AaR!ztE*NUQ9ITMMh0oFYa9^Y{kE)ABZ zn;_k*xM%%xS<|Oudw+@7qUXiM_~nzjCCTwf0C5nv#C~4xxUlrednTSelhgE_>tt8! z964@~*{7+t9@fCgmRtHhvXi(cBA5B4msmji?~TfAP`D(`;}1s3nUc7KJIVDmqotse z!RI=`OCq)jatUfIkwGL`A%Q*1UF=Hl{$e+yS+VJ9psQmaeksYuZ<~V56i?!#3e0%z z9&ubwJmBX<4W__Gx%npAb-r2$9NdcoYSi2rW?$oI2Ldu-!CqRhGX5%~FY8h}#D~#UT4BGE^K`5@J$Nj4%iTBGpr4{ECQ(vmV2|d?>&SLkx0qoMMKhWH6boI zOS(@C+i%)r65O&xh8=$)e3_eSKR|)o`7euVBXDBY;pe*%ZNE=gTVG{lS2t5Qrg4?^ zcZbo1Ft&CR2#TT^HsW!TZ8Tw#x~XX85u!*q*m<7%uut8!>l)t5xT6-!`SowBjUbnp z?vrZMz(Aft1aYRozbR$7z*u%W=65KP!3$srk&mWj!N&eF2uyO*3^i zWRDI(GAU~v+%%wE(oz{z`J#3-Rs7eYRd~=ZiCduUtZVK{u1NQ>iFl8by2EG@27POzndZ5 zPQlKzRea$2v3FZT++hk(?m3C$S#3?SdWTwTg)^O;n0kl1-W2ugmsO^Btd zQos=#FYA;6!Yn(xT0G^j6`j;gdt%*wYmD1s=wV>Awi}zyNuoW&h1hyT`)jblUwdxI z((zV8c{+p2HC%+7J8!~xDZiYsleC5K4E=9yzd!13+;v-OD7CnZPJV`odPj=!FPjWy zm%?FvGKT8@Qzj$15;WX571(*uJ~$>8>y!+tUC>kBN+>TcKB~bx)dIT0c-U?@J02H2 zdTuD3@8+q`}CQIM$o0Q-Q{h+ftHNg5!lBcl0q5Npx*i79GAty36}QvZlEF zKZCt9DU5biPUUjSGMK#O`Ob*kUpyU6=9f1!==$NV_8KpZaR{oGJ!hBFJF#{xiI6ap9nmL7~Q%HBAY*K!IL7fm10gFut>| z7+;*j17rQL<76pP98m=UoGZ zqU5!{5dWOp55!(agK{2>7dst;sP>FNP}m#Wl2rr1q;L>S9zmTSCEm`?7$<4ByntkD zY4SOdpSXtKO(I0e9S(B83T^`7(K;825}<7rn3I`ee7~~(y8YDzP=KNZCgFZdyYvoX z@?REppRwFBXRKiqqR&K2a`R0A0^O7p_)95YRpk9CQY>ec1lD^ZFScKnEnfBJg!_0$ z6|~0xu3y1=DQuPJXVV0J7Z9-@GOzS*hpRUmLC?9#)J6Q*(* z?vm{7lH$m<%iKBjiVf_4h%;aFt2rlj27aoD@YnobHMa~3{s}wg26m~9E@+;;mE;ob zj5gyj5AGG*@EoY48(Z4^`Z3hSf1dwy)HD9qw%e7*o^Bt#0QVWOmgTp1)(9%oBSfq&{lvOZbrWnR*uA4@wQW_CU08eT$NMtJ&eJNn=jV(^}5X zhf~Lfh+|S)+2o&G_1jO)GV5#_N3-9>z?<(IV5EYw_)G#MWFud3)a9omRA1Qbba@6- zbfX2#juEKOQhX7qMZBhG@>k6{GVkQUUgv(!bArLA2|VpG1MPaClNKWDJ)AEMO7uJ3 zn&-pS@w-(Xw4Mk>IO2(%)7HhjonP!O!oGgQZlI#7QaUM3-4tR4YmfJZ3Vo>Clq1cQ z%U5IXu8~dwm56EQ$EF^A+}rz>uyk{1@Pzw$G4GL*=cdl{kb5SAZ6=!Ewzc`A{WSdT zj#MkI!#cs2I;n!c6zlLWJ|FvP+RSnY=xw2rWg5*l{BgXuF(ngqK{iSBL{ad%7*r9X z+^0g9PesM0!p3%jMNecicyB5Pv8VDMp(`+YUW&~pLJS{ht~imVft#;z&>@CPWLb&y zYEMO|tIR6v4dI#K3z?c#UyyH_NGF&rCO3I*W3nu#^t;h(ip=|uA}*8X?||)(enwAS zt1WemP5ZltS-j&2h8jMd#af4u);fj?!%3lzYoGgsWjI|971kElrI+JAo6$WcN!*ru z&ig(OLAIl0EYW8l{8=*-`a?Y*uWW9V6Nu(Dp6LM|U1clwr!>{#okMk^ixsJ?Vi>Sj z+Xo)%WA;?b@toUAaS3@Jn2+1m0}-d_j|BeeMxXxvE$^s#bVNF^h)2EXsVg$K(~imS z0`{DHh!RQaS{dmosBdO&IhI}mE1Z$gpZjG!e1kNdTTC=&kqsM9oQeB~Q z^y<;{7iX^D1z0u>_;dSS41tM97H$VjKAhB)N?63b=KX2p>e-jRy6$BhejI1$%lLba zU8k_yODOc{vxHHs1G6PBU%4p8$hSFZr@f#1HWV18%&d! z$>1xtaJ%?CJq?}Y>Ht0}^{1jE^3GrTE_gM$+X`Td#nZm+R_7eC1MDODxo#E3QLKg{ zi{W*zzuQEEeUB+fgU$`|T`;QM(Km5nVVrxI$l33NPTazcO)R`a)J(eB^NuJ!S2I3~ zkY;O5hZ>@V$-TX4ey1GH+Q5_&+)NO$cz|AIi}O!3aY{VlBax<(`XO7`Hgd{Bvuu;7 zET_@V|2jGgzoyY8A>Anq1`HJtq`SLAN;*e(BZ87r(%lULqjMnP z0O@$o@7=#}&OXm`?)&?_u7@gk$7$@4!nvxc>oH&Z#ehbfrugBP z!~^Hij&t%c3NhA_5US!~dAyhU4AEj7OHQ-&@PX<;CcfDt)W^RPcWh zI(1`e%(*}sHaw+TzDe!Qq9NEhpZ*E zehY?LiZcRP7>46To-T!VPiA$Um#=;GCp$k{duzO)>Wdv#d6XWjjcRdvkD)}DUy0`P zHnnNRdROc9`cQvLO-SG0-VWp-V?SweJ(zc-KBQ zn4j^b_B8E4;I@StpwP#~WSEQ@WskoWRGG@8aS}fOwvVz4BUt_{;GgOKd|%IN$6bZh zXbhZg=-Ixyls?G_n8pM$Uxyu~xy!Fg-W$KxY$jLTL+O4FxM$IRJ_QlR z2?He)^L|`lo#!DK0qxfHsYr11k_kvtQ7$e|U-vMGv|NGjd)Oz$){2_7QC(=`kDQBM!F+f5N8>v>H=ef`6+ zneQACGr`zN_*Wf+v;F(ey?%Os(Q$a-e$C8sMj>z6hX^>@8Sr7TyWf0eSGvibSpNxP zKOPHw1A0fHD$?h_IztlBXW@5y-FAQd(R0m;T}KOlGBD+t{8HU!()Jqwcp^?6&?_oc zgbw8i*FGH5A0WM+4jZEG@xUgvz78XV)wr#>{9$!_Q5`34N-o&RcJ9gGOEuzkiaefY z0%&tU=T}T@tz+;8OCi^mp?g;O7#Bzay*EUHGs$S3A^~~zjV!EOST9wCjEQ~owb%ZN z`f|)4jThuvg6zJ7WfH!RH)|3>hfqYu!Bfj(ne@NvP>Fz4==NX+tSguh1PI3(f;G1!f%!znxE0Qm`9rPF2c%hw#rQqA5y&37mDB7Y$L3UYs$CX`b2(IjWarZyC860 z!O_(YhE{wDta47EsP3I;&>{AW;4Ak@fHt{^7YWJB2WOf1#q8lcfrJ#WEP1JJMC<4p z@QiFnq!rJti!c8ZJF&IVL+0z4j=}uT8&|7&z6by80MCZqaTU?t%cf>@c;hW)ZV?@O z@L?T)kVTf(YPbY2X~0FL0wha}n_bMk-3Mx4FypaT|3ds2 z#tCMp{5$M39Md}~cwAM16oJkQ8<7(qj~UgH^0ReOtiRFJA37{K=y_E7h#e`af0O=8 z9OtiZ5SQaABTGvz3e;4HEa6y9VeuG>2y@B&_#g4?>*9J)@K1A=m>ym2PWz5ls*Kr} z$o*ZyRih&@srlqdi79aJk`hW!$V*O#Mb*1C;`YSccs{$b+wCf>@fc3vM<2TA^f8^t zmF~aEC@AHlJwQOae71UhVdtjo-pxj9qY)3uC;lQ7sVZD2hMCNAI=|%Fn?lF5yRan& zO2-J8iE&v=aH;CBl~paY^qY^ea@}?O0T^)udvjNuuAecf&ama7Cf&LfG4E054-x$Q z)PVaL+*Sx|nA5&ZlXnDF8%N|Y2njJ|_rKr8FZ=ptvDHPE!*&-`)QDCPF|%6J8ix&> zCqNk(PqWWQaaUJ5@`p%Dbrf?ohLdg`1DVN|lM0a^$3!~}p%}6!F0q}|PyHDpgsjO6 zmNpAj1o}3-kN;EviY>RAaVPm;*8rxePz}C6A01V13NwDxexA;>m>i&oKAtqfyCxs( z$GTBC}$v>&|7ccnVO|T}3^`V$4oV$&z75g2%4Xxi_6 zO<BTBC#8lsi8g5L=B>YWu>=Nwh1M2X-52Vja}A)3NYc-X@(S=Y1TN*TTR`;9wLRpj zlk-1-;WpDvn;^SNa2(vJA0He!J??Fnr)u8v1#*Wusi2POz%DBL{W6K&_4AXL?=KK1 zX#|U0HXHW7(P8loKgYx~&Hs{zncU#O2YekTt=^&IFcQPv6)Z6gzZrB5dfRjE7#lS-$ zjJtar+6jtjtUqn;TH0asVch9zqbOqONJFJKEb=IPA4Z93;j8}FVWh=6W}}UslP;1( zL4le~-Pqc(Lv8nKBm5++te|Mi&bF z^nb9Pg16ho-l77NQNZ@?3m1_OXM9AGDv(Ly6Ph_)=PAU4Z|;>&-l2br5dMV)$9^=5 zvlP&8`ssrm{eR4!ER7+>LcV_9r7mn4=tf zO@4?b;}w+zM%^>vlKx^l-e z*t01E~-ImD?oOr@rc}k*i^HLr`b0vh*PO$+U=G>Xx?! zNBIGH)q%0Iov&KG`rop=I#ZzQ zu&*nJHyY_9-;KRJVb4pSLCl~-av81 zGzCCq5gkgiiGR#05-xp4g~QjJjw-f0DL? zm5f!Q`4nDZSm3aC5zo_RAB@&b?mqi;&AU4Gyf{Vqa=+-YP$O&siUo}>C|VD5KW2eVk|Z^R`c+8-n6mfFWhU7Yv7nyxE4w++=|PcdslY{qw!>t8A*h0Z zDq5qWI7mLVmG2v5R?fz_IBWgdcJ%l4;}ZV|%7@acnR8@`hE7hv1W-2b!nw~1Yl+HL z$}gECQ7Qk|gmx~Bt$|4JAKAtZKg}tANe_9A8($S!OU)aG$ccjA4+j$_{WCtY6hHf8 z_~Y!?qq@x3mJCW)eR=eYQ}|6*5ts+evv+)N7aQ*tTyvA&X047bj5RpfE%9;+NQwkf zzx~v&Ae`+NB%vDNUiStFOUC?_g0@2IYI^GLNXXp{TTADweZvdY#NVCJ;?kCfd?u`Y zZSier65;%7GI&Rb_V431u&k$o?}p8#S)=Oo=5**McNhG=94FzcN0>bYw;ib27ft_v2Zyd=cUUfc<@%)oc@BD?3|+03>R+~#18-{zg=?F!T+7|0hJA{PI7fR#{c2iVvNVD zWc-`#`}R%XRh7hBh&5HmN37_%PSoa4temtd2qg0R5)J}Vk3TDbo%;#c`VB*_O#wcL^uJO+sy7|^KE#-@_{oH6JM|0)$W?*zj8|dT`2)s|Q zsNrg>7X;!}v3VYbqE|bST$hi(6UXhAdzIrUs}l}}J=4xCJ z=C(Ao$?gvETSN;AFyNsync;WIFdV~ZqTw@CgABP5l>?kqg5ybTh{W@)jjE7zPS(Er zAL`WYTFhCk3$(QAU!k22lL{aHMcVw?mgw}(vnat;NM)sTdXhzKhy#G7|2^`U_FHwy zeGj26h#Z;a(*u1JlJ=_vY0$D68bWkErW#i62_fBY?Tj3Eq^OC z#BA_`{y0TwkiWeMn#M?go7g}oVssRwSqvjzpq@sCA%49xd;3%mYf`#SiN5esG^&YQ zspff;tgNH(AOGDt7=a~s{qT1pQ4Z+|oBQELL_=PNJI*KBhyFIHT000RvhvZze*iAg zwfEtq8yd8$m9MH5JBY>;2N!>&&f(Nk9Bqf|(b|u5r!hT0&x6cya)Veve9T45FAJN!y)?@!3i1)I4<`2Cx@Uf$~tdK9w6BNJ$N@_2GsDIPR zT1lOZeq83JtRT$_MCj#fTE6#MXzpW=z5hd+(lnJo#6=?@M=z1SY_vGrNo-gWR>(## z%K>GWq%VF}u)fOq2KpO%PBI;|+ul^6D1c#Zig$OYf~mqkAxiY=;eFHaBU@ z&g|Xq3WxVuJU+x20In^9Lu2~FA-6td=e$z0+4zB3pRcW-Ut@wyMAI z{2Vum4*fQ_ajen+#(v3eOl9~Bl$&W*GwuTS6j*=#Kzi(+F;QK=-|jG+MTaM8biGiN zsXJMhTI7+i`|L4k-LHXt%?xw4@!1jHC3#r}^Aici{Y{MV4{{%2z-!OZASokkZ)g#l zjrEBtNV~sgu+bVtZXza(DH7IWAMYa|hEyBa_|0wrt5ru)gp-%!Ml>AZ&O+uX8>+~Y zotq(P9D!t9R5L=|*o~?XeHy1FzAFYkmc=Ef@??Xvz=vEJ@9RMDsbHjjKaX68sPXtS zuVx*m-FLk>T{+K!FHt6C#71?VT%q6k3@JqP*z1!84ni?z5%8okOf6SPEAp;7&9W!6@SQ<^l3H zX|xLug|kd%e|)HMXM#w@?vP8L7I6wuzgCh7PK^vos^0)yQ@sn9!J}04z#2plfHMi2 zKGzL;7S$md^6#6T3l7WU`t+8S&2Z;95cDqDW(IX9V<;UjeD9Dul#{?WkM_s|=ls=9 zks-Z?Gz$-rn`VX>(IYE znQG99aW6l?6`Nc2rMWXINK2}!eROd9{Q8V`D-h5iXOyp)gTMZ;tVNCsC&#I)tdA>k zU`YhCkOB>S?SqR`q0u1mOP}cfx0%MLJU$CeP>M9Z8cA`sxlowgS?qkb+D36g)UU&c zw|tn|X%etb7DLMFPxCQ3$~O|5bW$pV$FMK93b%*U$3yr8$MNQv9$UP8#9UCU%98|O zY!o~D(*g8Q4QuR%By1BaTLl}}bkH(eg&^jet35*>(4P{_PW_p2kS|Iw`Mr_J+br$6 zu%YH&pl6Br8*}>c%YP;OA;t;5W=8@j#n!@Uq_AE?itX*2+enw~gWpM!@-B1Yl(h3P z^rRnX4D3?qR5LZ24Q+xp!YUu1OW_h39RJb8-s}Y;+{v*ZAr#dmrk(daYZJY&P#s_S z4G3l4M$}+)=so3K?ELX(4#O@pp~*)x8Su^GvyCd6)kj?r2xd(0^7fH^ni!4453Nh* z1pJi1DMXu}doMO}nn6?J^OXr}32s1kWYBjSSAsUBU}Itn?4_s7fY}5{eN6{XJF*^M zp)cQld$P;~NSRa5I;kTZu*E+bE&3-Dn2mJ|>RSYXDCj?AC>Enh@K5*4>GkIJVFPZi zcGS7NZg56!+dQ^^_=8nxSJ(t{d!r3ACR>0vr-=>=K`sagn>08&d*^M`MpdrrM>{Kr zylV!~FIFqDFTx?R>-YJXS?8s|Yp?PVOxHRAsgX?6@%u$}W8Y0MEl*nkfDTwl) z_rODO{;e+F*5{hKL8%#JcB4|`S+PEg>pD9!=vamft+8eMX4(D3n%tZu8%kX9`Jt_ykD(KrHRX-Ya7~sA_D8ygz4U-4vdU9qu|mby=?d za-IIuwz_=j7f|AawAo{F3vT;0?wj-scf#Abd^ z$O?P*P15pNZu>kroy;&>bN+Fe9ZgS}n@-#VSRp#d-?x|+@1yJT=kX&D;;E6R! z%%^w$3xlT_mOi2WT$>uwdNsmvvF%AVJ$rjJtnll{7qU{7dkz+g3Wqc^|Omc)(Ufu6_9(g`<`V`s<^R4Yn_nra?x@M+5KS zj&&T6s06@wx--wsJ${>dm#UxEBNj|Pav*+;9~t$jm|aU?`zoi&F5Xpxqo3{9UXbiL zixl#E>heG+U}2l5n$<{@`EL*sNMk2*T3wzAhfEtKKONt-8BlcM@44sPoG^VVp@^NR zU!e>zF*2ps2MbecR)VOuiJYtuS2`t^Vm0#xs4QER^x5;lgKvVD(y(%d+>3%kkY9dm zG(Gz^NHa!Wa~9KaR=`l#lNu8?O(tp8R8zFlW67b-hz%Se`;F@ur%}EMvM0rF*|nbk zmvRm18wx{LVwWx9w_X_F0O!XHTJd~^`e8jlCm9F3E2$h-%i9>fP@g14^{MB+4=oiw zso%#K%kQN^0URzA?}FiHqcZMdzS`js=>tH`@wugD{_%3pMO+KZcAvg1H-%WnD>ijT zr&OU;oa(2x=C!z7d4(az3?6TcwnTieJ1bv*@cWF_2M)JJ07@1mmEB^%VL(rd-vmrY z8Gc^FGRLj_q{XEL&Z(Ai$mjR?+5%uNMNl)ZG@<-DHMv6mv906^@qHpqZ3YRiMi5-? zHmRYDX#M-+{F?CO%+WKV7}R);*`q0Eg10qn;fFAhrK_-4J88V)kKr!nHRaT`Snw5u zUrr{27v3kpp;Ytcs2pE;a-hg{ZJ?Uj?b#C$APWS7&!TRCf(4m_23Q&QmpPh~<5t-W z+fhfJnQlPI`6Yfq)1|0GWz9bo`#@e)TTggnLEzDhtv0uJG!>vDWAB5a89q;Aq&<~p zdjyKs1o!c1pNiA>-cg?`2r|2QX>*dHV3*Zl_H$(9&b4=h(R*ncHqbKT`?YH39jQmq zR!5!S{**WRs}F3=IcW4*vygoLw>$oK5Z7=r9=EFR(7AK5U(f8YO6xsfA3m0N8Xo$c z?^;Oz<V4jWP`#6?BgqrWJwXbU6`pogjR)&eEW|_7w6)Z zz?fwPxXkj`PjfnzZQV#yF-P;@-7>+f$xFXke&&5wQtZTcbMt9+BJOZi*hq4GIc)Cct=mX!He|(o{-xJ6 zj9Y=!_;LzS9KIu)>Z63FiAH4ZBh%ma=->a-zYj@L`-WQ@GF84$9G|kNhthf0LtL6S zofxQ>v&q3Ht>M{Rcr%@b%o%U&%8Lo7CI>IRe7IXcOzjTehqNf}9s#yvI@gklV<;cE zp&XYSCaD-QbvnUR{A?+4&Z?j^!R2^D(R{%W_#`Lmg!TH?i8=14w8YugNH&#(oEDv| z2^POK`z=7@q`UEiS!b|!-cm+i`1uB@^C;{j@HLD(M)G_vo~V?wl66h$B`|JShO@Ts zT6iBhbo4-T(Y7CDs~<-zBp#Ld&pl&es0LKcx#f4yn&4On2xP_NVg1sw&`TVgC2qD6 zm5g-0#uCGUiOt{$2B4lI5&DwY&b5=*Mc05G{eeNN8&pv4lyK=`-7rlO(tgl8 zV43%gj#B~kMr|00M%WK(;@vp1)F~nb2HJO4NJ@<`KBNs`>tV}s*ongZgRkxE#ddpH zX`RjW_bYV;g>ZZILMBRJa!5A4W{UCCH>vw_pf4&{;_y16b(I3!hW4Ezfj2BPA>D={ zi|yR!u-t3)eV?)huJy>{!mX{d*q6WskB;4J=l6e@&_DNvSPIy2c9_@seTAYSvORH@ zm=wIa?JOI;af9qiHNPEY_oo0INK9z>$?Is!QPSlCvbEIl?+R%1Cjysqm$7lQYE7p5 z7sdqq_`8fsi+Jk8QRJe$i3;^S|7tp}TgkX!{HLS0AX6M`g}1k2x8a{?rUmZ?cB}f& z5i4&6;)S6lDb)uY%A83Q6oYJj^qSvyisi04nHTb%Kdu9B=0fMPZD>xNN=fLFp>|J~%(sk_;}V6#wo>%U(436^?q$NNc)nO{2@< z>$%M~DZDdI?hy2Lkszi$UzF+Z9vf|@i=o|u+Ev%=usE)WoKK;Cn`jRE#%lXmiA;d@ zHKpgG@8=nd>T<5EWD7t8#Arj7cR|otBpL8_BFr4cQ|y9PJJR=@)?G%xYO;8Ra@q8epF?L|nbt!Sj!=xuVu-Uu86W z*X~o@pHqEUn&)y@YJ?|KHs2ai)hq%_{IUg3%{t2z4@0}))s9%yTK}rLfJ^j(rPEJe z$y&wkSaO{qM=QLb!(t3yr*^5yt!8n&i_q1yIYiRx2g{u2&HQTPvQ- z%c)q1u1q6pTR=6@jCYDtqUVHd?Vid`tB||1o~_~EUDt&c+0B`-7tdW4pRdd%R7{t% z-^f~w0Z!<*3N@b+K2Iy2@3a#5QM)e&*r`p5Y+apnOhb(0FLbdt%@wP-U}QF#S^PNk z@YZ^Avw^O$=`tXl&Ti2McCQw%FNAyOUXEY=AVI40IfmMNwa9eCh%Iz-bcerLj6CM_ z@Mt8Hi=1{BWL5RKAvNTPYGf`w%6xqtgjVhL?wjZ2k@NST!9r07aD$Ok6?8g4J=^UW zC7 zDmg%HefzaLr@f@Y<9n1G=Oaaz1~j_}P9GO~3D}e3xU;iv1v+?X9!e=2Y4QjJ5_ z%d4lFj9yi#V&bc?f2il7r+V8m#Lf{ocWhGW3<5D66U~{eDsq-srAUNK#04>smlCG= zYby7_t73#hnSWPJ--suId4pP1af%`yIF0V47$WOEXo8mu=;R>$<_Et%*RE#gTSyv< z-_2MUT1Pa`oPFVsRI9D&LDIo9?fe42#H_}LQMXMXbkW7CFU=(?kP8OF#Sd~0YY-VO zO005~mIU)$KLvNO#PFL-Y4U7b(wP%mNM^@Vo@JBE8J3|;XW2Qr_*mpx3asdv&*xdJSiF*$6t8y zCp0cZy77S}@YfZ-#ok%x?V{T4m<>LrgQGCi$jm&MXoqw&BMDXI=1r{^-bUW$F@Mb( zHPPFt(jJNpYjvK&7WS%e@kCXJWW^xYD+?s&r-eDFpVSIRrTlPDgpR3djuQmZwvw-L zc86=PXb3++?RIWXevqMA!kAn7j26TDQ2119L3Pkd-!q-g+q}X!N&pm}*{`%adWMdv zXXMEq|5k+rI#liH@n8*booUJX^}X)E&Zr|z&8|q;IO+!1bedf0goJY)Qz1{hx=YN& zu>Yz&B0(BThX>cZVKiZV`|0lk{Z5Yfrmk?~bXHXQd~T=XxeV#KR3fh1aKqYRn9*x? z%4k&av%CIe)yn!;yTjkyUzQ5`;vDBn-+|TGMT} zd~@*XQypZe=l#4Mi`LnklZ8-)N{aY(_fX%6W;HP3E2T}sX}$wt94Whc`9v**+*mkpatI%a8UVbm@2KzLgph+xd zw%3tx7b@)N8)09^vezA>pCg;F(ua}ry>mBD_F89TbK$TI@N5Td_}4uBwn5OUil?3o z&&*EbPZzp0zX4y7WzO#tlw6d1?(38Up^uzqTSdaA6-T)qHz8gRkrnB$uQTwdK#X~g zn%Yv-rB+yMlx}d{m`opAv2Y9@^#d4bar#t-Hg!-kkF=e;OeOrJ)6xU!?ot&@{gz;f zI29<5z{K@lX2p!DsQ(>W@|#@j-h|$EPfOAUi~^#&K!H)3*a1fXk)y-nu&E2AYo@y_ zz$$eNFK5OMP+I+-$4AR&=ffVH7{k;hm4-veh~+B)V#=2dMmP;0L&+JzJ$o zkclx0n>wVVbbMg2|1eCqnFbNg%lO?ef>f zL)bR`AF#g(rw6%_H%k)a3Mv>AC*d?p@)&|Sn{eqfRovW^bKhsID;<%(@+}C_(7>y^ zi1D01=&7Ncd-bLyc6Ra8S~(2?6h%F9R+H7x%BMK_vIwBCwGKX58P;e&eT}v4@ls{Vp*Y*hdNBNUNGiE&zhCJSSpl=yc64~N%&+zEi*TwXjIA_0O+ z!}uH#Q~z}J8*1dZ@r7pGjEkYdLSruuNu8(Ko5G^xOK-ow9V}5W@!fIy)mir_3pw;4 z@Dp`35b;J%*3bqN%wg>HE-|d788`ewjjr5zf2Q_AU`TM*sp=c@!81-ME$`Xns{!&V zUuyoPLZrF&uLj&cAccETc(Kwx5reCqKD-?JGJ=Tdc~6zR2{utX7sEYC{*bo=fIWRV8_A9@R?Im(=YgKcN-FSL3vWM2n^ex@!qNk@XhsQgI!rKK_pUn0?Rh^ zLk#qA)1ydLm0p90>x*~vbY3wMHXEjVQ21H-8t1EE!4ho{b5WAYhI4(6rM=>nM%GVz zxEQY-Yr68~h;wk`v4NY{cxYo>&lU&CETF4#p@p|Lf-MH(7KUeZo4~0F6z&&ck;ntq zhGudFWKPlX)^pRyDR7AP#q(RiOp;wiXO_}-^Ms5{9C8LDMveW9S z>E@_odEVY(GK6XuNL0^BC0-Etc=6c1H1BrI&uCnj_(sokHO}A^`A5aG?gw{KhDQIp zg+#z58D*eyYg5zDJ@{6~tHrpw<>dANO|cFaH595xILJRVnGJ_Q^Bu0cD5gce3V$YHJHy$MC5YaXOZ+o5UHr z^NS|Nx{X`@qKtg?1qr5;lbXtnh927!a8I@yz#u|SJ>_r%-YwoVEMyo;D88uRY+0;hxfxwxK~ zQMVLeg~A0}?g{bJb$o04aeQ&LP~WOIo6~{G=+^|}bGSe6Jd>A_@_yHg+XpK@qsY-8 zuFSn6K=nLMy+nE6jxOAbR^J17j)@73>|cj49&7E8MUKT9+9v9tb&(oOkX>>B6Nj2} zpJ`a*QO6c(0h2?-1NWhARBHalAQp3|*&>e!b>8Per>y119K`F9Gfl3vUn_}^=1})6mx_94lE$K3LO!W5qvTYq#OzGq)*qeH4mE<6Dmyg!GyI`m+td*90PtRQO@>`*^{ z7oDl^e>Ige_hCGJeG8&O_#YoXepr#_$o-F`Y}*fSO|t@u7vhju$-VVe}k?$}aLO);=MAEoT)Q;J`MV(9$-IFD~)& z$OaWyXO06%O^rQqM*7gmA24P5h%ebBssIs?r)(J{`8t!#F)$Fu2XC=jdw1IB?YYXJ zAMxvD3CR_eS;Sit>Ami|()KPe5WtF6Tdi(1mVE6L71(AScC#10m@$3>20%q#W1b5V zw^#N4*8*;Oe`A%_nfRpV+(oM%dy1EnsFWIt_{s{GymWeT)DjkxEPPQiBMlwmJNg4L zxC&*aMiL4SjK(mr!yvkkOF<>(`-$uYyZ8tnGyx1X1(k*Yrh26{XAQuK=Q719uu{!u znLbc-X&LFD`qrFHwR{)2-+?tI@(bh4=ru+3(tkes!`D+zkvYkyl3wGW+Iky!&LF$j zd8ST&gFy3+TJ-;ZTX3ZvSNgA981BmXm&;)43fA0%^}W9_f-J&s^%MBrQnvnr*i)w7^Z;G)L67n!c7ia4(vV!7RYR&8-v=V*M=Q35@)>yZqb@ zpXCt?7Lkw7?Y90S#KwPtO9xr7LSgYqI4~jQyyp>F1Rfo*`-wZV;8T+yr$XUE#ID)j zhKpC>_pfUxtH;>`(W>_b+XuaY_K^6$j?hj^2tIh}S(VCj*f*fM6u?ouCX2m57-xoz z!B?(ZsB0-O`mKY4a>?u*Cr?S4bDt)r+Ng3Cp9i`M)T@t=12<(QVw4u54{K}|lm*zQ z%@=vjs0`j16ZhKRobKVfG&q!Erdr#fanJ=gF_WHPQj#jjDDqqnK1?|47VNflX1^R5 r39FyD-J)xf51W=eF&X)*dVlKA&C1#=+!pZV0q|3lgUkMqHVFJ5r^Qrw literal 0 HcmV?d00001 From 6e91d0283cc523a00a12d2e451dd8e07cacfc8bb Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 16:13:39 -0700 Subject: [PATCH 03/36] prettier --- extensions/Corbnorb/noise.js | 5337 ++++++++++++++++++---------------- 1 file changed, 2760 insertions(+), 2577 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index cdc4950a1f..9f3b7b5129 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -5,241 +5,240 @@ // Original: Auburn // License: MPL-2.0 +(function (Scratch) { + "use strict"; -let noises = new Object(); + let noises = new Object(); -const BlockType = Scratch.BlockType; -const ArgumentType = Scratch.ArgumentType; + const BlockType = Scratch.BlockType; + const ArgumentType = Scratch.ArgumentType; -(function (Scratch) { - 'use strict'; + class PerlinNoise { + constructor() { + this.noiseSeed = 0; + this.worleySeed = 0; + this.time = performance.now(); + } - class PerlinNoise { - constructor() { - this.noiseSeed = 0; - this.worleySeed = 0; - this.time = performance.now(); - } + getInfo() { + return { + id: "noise", + name: "Noise", + color1: "#b5074c", + color2: "#990841", + docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", + blocks: [ + { + opcode: "initNoise", + blockType: BlockType.COMMAND, + text: "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]", + arguments: { + ID: { + type: ArgumentType.STRING, + defaultValue: "myNoise", + }, + SEED: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + TYPE: { + type: ArgumentType.STRING, + menu: "NOISE_TYPE", + defaultValue: "Perlin", + }, + OCTAVES: { + type: ArgumentType.NUMBER, + defaultValue: "1", + }, + FREQUENCY: { + type: ArgumentType.NUMBER, + defaultValue: "0.01", + }, + FRACTAL: { + type: ArgumentType.STRING, + menu: "FRACTAL_TYPE", + defaultValue: "FBm", + }, + INVERTED: { + type: ArgumentType.STRING, + menu: "INVERTED_MENU", + defaultValue: "false", + }, + EASING: { + type: ArgumentType.STRING, + menu: "EASING_TYPE", + defaultValue: "Linear", + }, + }, + }, + { + opcode: "getNoise", + blockType: BlockType.REPORTER, + text: "get noise id:[ID] at x:[X] y:[Y] z:[Z]", + arguments: { + ID: { + type: ArgumentType.STRING, + defaultValue: "myNoise", + }, + X: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + Y: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + Z: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + }, + }, + ], + menus: { + NOISE_TYPE: { + acceptReporters: false, + items: [ + "OpenSimpex2", + "OpenSimpex2S", + "Cellular", + "Perlin", + "Value Cubic", + "Value", + ], + }, + FRACTAL_TYPE: { + acceptReporters: false, + items: ["None", "FBm", "Ridged", "Ping Pong"], + }, + INVERTED_MENU: { + acceptReporters: true, + items: ["true", "false"], + }, + EASING_TYPE: { + acceptReporters: false, + items: ["Linear", "Squared", "Cubed", "Root"], + }, + }, + }; + } + + initNoise(args) { + noises[args.ID] = [new FastNoiseLite(args.SEED), 0, 0]; + switch (args.TYPE) { + case "OpenSimplex2": + noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); + break; + case "OpenSimplex2S": + noises[args.ID][0].SetNoiseType( + FastNoiseLite.NoiseType.OpenSimplex2S + ); + break; + case "Cellular": + noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Cellular); + break; + case "Perlin": + noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Perlin); + break; + case "Value Cubic": + noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.ValueCubic); + break; + case "Value": + noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Value); + break; + } + switch (args.FRACTAL) { + case "None": + noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.None); + break; + case "FBm": + noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.FBm); + break; + case "Ridged": + noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.Ridged); + break; + case "Ping Pong": + noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.PingPong); + break; + } + noises[args.ID][2] = args.EASING; + noises[args.ID][0].SetFrequency(args.FREQUENCY); + noises[args.ID][0].SetFractalOctaves(args.OCTAVES); + noises[args.ID][1] = args.INVERTED; + } - getInfo() { - return { - id: 'noise', - name: 'Noise', - color1: '#b5074c', - color2: '#990841', - docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", - blocks: [ - { - opcode: 'initNoise', - blockType: BlockType.COMMAND, - text: 'create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]', - arguments: { - ID: { - type: ArgumentType.STRING, - defaultValue: 'myNoise', - }, - SEED: { - type: ArgumentType.NUMBER, - defaultValue: '0' - }, - TYPE: { - type: ArgumentType.STRING, - menu: 'NOISE_TYPE', - defaultValue: 'Perlin', - }, - OCTAVES: { - type: ArgumentType.NUMBER, - defaultValue: '1', - }, - FREQUENCY: { - type: ArgumentType.NUMBER, - defaultValue: '0.01', - }, - FRACTAL: { - type: ArgumentType.STRING, - menu: 'FRACTAL_TYPE', - defaultValue: 'FBm', - }, - INVERTED: { - type: ArgumentType.STRING, - menu: 'INVERTED_MENU', - defaultValue: 'false', - }, - EASING: { - type: ArgumentType.STRING, - menu: 'EASING_TYPE', - defaultValue: 'Linear', - } - } - }, - { - opcode: 'getNoise', - blockType: BlockType.REPORTER, - text: 'get noise id:[ID] at x:[X] y:[Y] z:[Z]', - arguments: { - ID: { - type: ArgumentType.STRING, - defaultValue: 'myNoise', - }, - X: { - type: ArgumentType.NUMBER, - defaultValue: '0', - }, - Y: { - type: ArgumentType.NUMBER, - defaultValue: '0', - }, - Z: { - type: ArgumentType.NUMBER, - defaultValue: '0', - }, - }, - }, - ], - menus: { - NOISE_TYPE: { - acceptReporters: false, - items: ['OpenSimpex2', 'OpenSimpex2S', 'Cellular', 'Perlin', 'Value Cubic', 'Value'], - }, - FRACTAL_TYPE: { - acceptReporters: false, - items: ['None', 'FBm', 'Ridged', 'Ping Pong'], - }, - INVERTED_MENU: { - acceptReporters: true, - items: ['true', 'false'], - }, - EASING_TYPE: { - acceptReporters: false, - items: ['Linear', 'Squared', 'Cubed', 'Root'], - } - } - }; + getNoise(args) { + if (args.ID in noises) { + let value = noises[args.ID][0].GetNoise(args.X, args.Y, args.Z); + value = noises[args.ID][1] == "true" ? value : -value; + value = (value + 1) / 2; + switch (noises[args.ID][2]) { + case "Linear": + break; + case "Squared": + value = Math.pow(value, 2); + break; + case "Cubed": + value = Math.pow(value, 3); + break; + case "Root": + value = Math.sqrt(Math.abs(value)); + break; } + value = value * 2 - 1; + return value; + } + return 0; + } + } - initNoise(args) - { - noises[args.ID] = [new FastNoiseLite(args.SEED), 0, 0]; - switch(args.TYPE) { - case "OpenSimplex2": - noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); - break; - case "OpenSimplex2S": - noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2S); - break; - case "Cellular": - noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Cellular); - break; - case "Perlin": - noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Perlin); - break; - case "Value Cubic": - noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.ValueCubic); - break; - case "Value": - noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Value); - break; - } - switch(args.FRACTAL) { - case "None": - noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.None); - break; - case "FBm": - noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.FBm); - break; - case "Ridged": - noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.Ridged); - break; - case "Ping Pong": - noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.PingPong); - break; - } - noises[args.ID][2] = args.EASING; - noises[args.ID][0].SetFrequency(args.FREQUENCY); - noises[args.ID][0].SetFractalOctaves(args.OCTAVES); - noises[args.ID][1] = args.INVERTED; - } - - getNoise(args) - { - if(args.ID in noises) - { - let value = noises[args.ID][0].GetNoise(args.X, args.Y, args.Z); - value = noises[args.ID][1] == 'true' ? value : -value; - value = (value + 1) / 2; - switch(noises[args.ID][2]) { - case "Linear": - break; - case "Squared": - value = Math.pow(value, 2); - break; - case "Cubed": - value = Math.pow(value, 3); - break; - case "Root": - value = Math.sqrt(Math.abs(value)); - break; - } - value = (value * 2) - 1; - return value; - } - return 0; - } - - } - - Scratch.extensions.register(new PerlinNoise()); -})(window.Scratch = window.Scratch || {}); - - - -class FastNoiseLite { + class FastNoiseLite { static NoiseType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2S: "OpenSimplex2S", - Cellular: "Cellular", - Perlin: "Perlin", - ValueCubic: "ValueCubic", - Value: "Value", + OpenSimplex2: "OpenSimplex2", + OpenSimplex2S: "OpenSimplex2S", + Cellular: "Cellular", + Perlin: "Perlin", + ValueCubic: "ValueCubic", + Value: "Value", }); static RotationType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", }); static FractalType = Object.freeze({ - None: "None", - FBm: "FBm", - Ridged: "Ridged", - PingPong: "PingPong", - DomainWarpProgressive: "DomainWarpProgressive", - DomainWarpIndependent: "DomainWarpIndependent", + None: "None", + FBm: "FBm", + Ridged: "Ridged", + PingPong: "PingPong", + DomainWarpProgressive: "DomainWarpProgressive", + DomainWarpIndependent: "DomainWarpIndependent", }); static CellularDistanceFunction = Object.freeze({ - Euclidean: "Euclidean", - EuclideanSq: "EuclideanSq", - Manhattan: "Manhattan", - Hybrid: "Hybrid", + Euclidean: "Euclidean", + EuclideanSq: "EuclideanSq", + Manhattan: "Manhattan", + Hybrid: "Hybrid", }); static CellularReturnType = Object.freeze({ - CellValue: "CellValue", - Distance: "Distance", - Distance2: "Distance2", - Distance2Add: "Distance2Add", - Distance2Sub: "Distance2Sub", - Distance2Mul: "Distance2Mul", - Distance2Div: "Distance2Div", + CellValue: "CellValue", + Distance: "Distance", + Distance2: "Distance2", + Distance2Add: "Distance2Add", + Distance2Sub: "Distance2Sub", + Distance2Mul: "Distance2Mul", + Distance2Div: "Distance2Div", }); static DomainWarpType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2Reduced: "OpenSimplex2Reduced", - BasicGrid: "BasicGrid", + OpenSimplex2: "OpenSimplex2", + OpenSimplex2Reduced: "OpenSimplex2Reduced", + BasicGrid: "BasicGrid", }); static TransformType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", - DefaultOpenSimplex2: "DefaultOpenSimplex2", + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + DefaultOpenSimplex2: "DefaultOpenSimplex2", }); /* Private */ @@ -259,7 +258,8 @@ class FastNoiseLite { _FractalBounding = 1 / 1.75; - _CellularDistanceFunction = FastNoiseLite.CellularDistanceFunction.EuclideanSq; + _CellularDistanceFunction = + FastNoiseLite.CellularDistanceFunction.EuclideanSq; _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; _CellularJitterModifier = 1.0; @@ -272,9 +272,9 @@ class FastNoiseLite { * @constructor */ constructor(seed) { - if (seed !== undefined) { - this._Seed = seed; - } + if (seed !== undefined) { + this._Seed = seed; + } } /** @@ -284,7 +284,7 @@ class FastNoiseLite { * @param {number} seed */ SetSeed(seed) { - this._Seed = seed; + this._Seed = seed; } /** @@ -294,7 +294,7 @@ class FastNoiseLite { * @param {number} frequency */ SetFrequency(frequency) { - this._Frequency = frequency; + this._Frequency = frequency; } /** @@ -304,8 +304,8 @@ class FastNoiseLite { * @param {FastNoiseLite.NoiseType} noiseType */ SetNoiseType(noiseType) { - this._NoiseType = noiseType; - this._UpdateTransformType3D(); + this._NoiseType = noiseType; + this._UpdateTransformType3D(); } /** @@ -316,9 +316,9 @@ class FastNoiseLite { * @param {FastNoiseLite.RotationType3D} rotationType3D */ SetRotationType3D(rotationType3D) { - this._RotationType3D = rotationType3D; - this._UpdateTransformType3D(); - this._UpdateWarpTransformType3D(); + this._RotationType3D = rotationType3D; + this._UpdateTransformType3D(); + this._UpdateWarpTransformType3D(); } /** @@ -328,7 +328,7 @@ class FastNoiseLite { * @param {FastNoiseLite.FractalType} fractalType */ SetFractalType(fractalType) { - this._FractalType = fractalType; + this._FractalType = fractalType; } /** @@ -338,8 +338,8 @@ class FastNoiseLite { * @param {number} octaves */ SetFractalOctaves(octaves) { - this._Octaves = octaves; - this._CalculateFractalBounding(); + this._Octaves = octaves; + this._CalculateFractalBounding(); } /** @@ -349,7 +349,7 @@ class FastNoiseLite { * @param {number} lacunarity */ SetFractalLacunarity(lacunarity) { - this._Lacunarity = lacunarity; + this._Lacunarity = lacunarity; } /** @@ -359,8 +359,8 @@ class FastNoiseLite { * @param {number} gain */ SetFractalGain(gain) { - this._Gain = gain; - this._CalculateFractalBounding(); + this._Gain = gain; + this._CalculateFractalBounding(); } /** @@ -370,7 +370,7 @@ class FastNoiseLite { * @param {number} weightedStrength */ SetFractalWeightedStrength(weightedStrength) { - this._WeightedStrength = weightedStrength; + this._WeightedStrength = weightedStrength; } /** @@ -380,7 +380,7 @@ class FastNoiseLite { * @param {number} pingPongStrength */ SetFractalPingPongStrength(pingPongStrength) { - this._PingPongStrength = pingPongStrength; + this._PingPongStrength = pingPongStrength; } /** @@ -390,7 +390,7 @@ class FastNoiseLite { * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction */ SetCellularDistanceFunction(cellularDistanceFunction) { - this._CellularDistanceFunction = cellularDistanceFunction; + this._CellularDistanceFunction = cellularDistanceFunction; } /** @@ -400,7 +400,7 @@ class FastNoiseLite { * @param {FastNoiseLite.CellularReturnType} cellularReturnType */ SetCellularReturnType(cellularReturnType) { - this._CellularReturnType = cellularReturnType; + this._CellularReturnType = cellularReturnType; } /** @@ -410,7 +410,7 @@ class FastNoiseLite { * @param {number} cellularJitter */ SetCellularJitter(cellularJitter) { - this._CellularJitterModifier = cellularJitter; + this._CellularJitterModifier = cellularJitter; } /** @@ -420,8 +420,8 @@ class FastNoiseLite { * @param {FastNoiseLite.DomainWarpType} domainWarpType */ SetDomainWarpType(domainWarpType) { - this._DomainWarpType = domainWarpType; - this._UpdateWarpTransformType3D(); + this._DomainWarpType = domainWarpType; + this._UpdateWarpTransformType3D(); } /** @@ -431,7 +431,7 @@ class FastNoiseLite { * @param {number} domainWarpAmp */ SetDomainWarpAmp(domainWarpAmp) { - this._DomainWarpAmp = domainWarpAmp; + this._DomainWarpAmp = domainWarpAmp; } /** @@ -442,102 +442,102 @@ class FastNoiseLite { * @return {number} Noise output bounded between -1...1 */ GetNoise(x, y, z) { - /** - * @description 2D noise at given position using current settings - * @param {number} x - * @param {number} y - * @return {number} Noise output bounded between -1...1 - */ - let R2 = (x, y) => { - x *= this._Frequency; - y *= this._Frequency; - - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: - const SQRT3 = 1.7320508075688772935274463415059; - const F2 = 0.5 * (SQRT3 - 1); - let t = (x + y) * F2; - x += t; - y += t; - break; - default: - break; - } - - switch (this._FractalType) { - default: - return this._GenNoiseSingleR2(this._Seed, x, y); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR2(x, y); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR2(x, y); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR2(x, y); - } - }; - - /** - * @description 3D noise at given position using current settings - * @param {number} x - * @param {number} y - * @param {number} z - * @return {number} Noise output bounded between -1...1 - */ - let R3 = (x, y, z) => { - x *= this._Frequency; - y *= this._Frequency; - z *= this._Frequency; - - switch (this._TransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: { - let xy = x + y; - let s2 = xy * -0.211324865405187; - z *= 0.577350269189626; - x += s2 - z; - y += s2 - z; - z += xy * 0.577350269189626; - break; - } - case FastNoiseLite.TransformType3D.ImproveXZPlanes: { - let xz = x + z; - let s2 = xz * -0.211324865405187; - y *= 0.577350269189626; - x += s2 - y; - z += s2 - y; - y += xz * 0.577350269189626; - break; - } - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - const R3 = 2.0 / 3.0; - let r = (x + y + z) * R3; - x = r - x; - y = r - y; - z = r - z; - break; - default: - break; - } + /** + * @description 2D noise at given position using current settings + * @param {number} x + * @param {number} y + * @return {number} Noise output bounded between -1...1 + */ + let R2 = (x, y) => { + x *= this._Frequency; + y *= this._Frequency; - switch (this._FractalType) { - default: - return this._GenNoiseSingleR3(this._Seed, x, y, z); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR3(x, y, z); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR3(x, y, z); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR3(x, y, z); - } - }; + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: + const SQRT3 = 1.7320508075688772935274463415059; + const F2 = 0.5 * (SQRT3 - 1); + let t = (x + y) * F2; + x += t; + y += t; + break; + default: + break; + } - if (arguments.length === 2) { - return R2(x, y); + switch (this._FractalType) { + default: + return this._GenNoiseSingleR2(this._Seed, x, y); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR2(x, y); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR2(x, y); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR2(x, y); + } + }; + + /** + * @description 3D noise at given position using current settings + * @param {number} x + * @param {number} y + * @param {number} z + * @return {number} Noise output bounded between -1...1 + */ + let R3 = (x, y, z) => { + x *= this._Frequency; + y *= this._Frequency; + z *= this._Frequency; + + switch (this._TransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: { + let xy = x + y; + let s2 = xy * -0.211324865405187; + z *= 0.577350269189626; + x += s2 - z; + y += s2 - z; + z += xy * 0.577350269189626; + break; + } + case FastNoiseLite.TransformType3D.ImproveXZPlanes: { + let xz = x + z; + let s2 = xz * -0.211324865405187; + y *= 0.577350269189626; + x += s2 - y; + z += s2 - y; + y += xz * 0.577350269189626; + break; + } + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + const R3 = 2.0 / 3.0; + let r = (x + y + z) * R3; + x = r - x; + y = r - y; + z = r - z; + break; + default: + break; } - if (arguments.length === 3) { - return R3(x, y, z); + switch (this._FractalType) { + default: + return this._GenNoiseSingleR3(this._Seed, x, y, z); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR3(x, y, z); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR3(x, y, z); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR3(x, y, z); } + }; + + if (arguments.length === 2) { + return R2(x, y); + } + + if (arguments.length === 3) { + return R3(x, y, z); + } } /** @@ -545,146 +545,146 @@ class FastNoiseLite { * @param {Vector2|Vector3} coord */ DomainWrap(coord) { - switch (this._FractalType) { - default: - this._DomainWarpSingle(coord); - break; - case FastNoiseLite.FractalType.DomainWarpProgressive: - this._DomainWarpFractalProgressive(coord); - break; - case FastNoiseLite.FractalType.DomainWarpIndependent: - this._DomainWarpFractalIndependent(coord); - break; - } + switch (this._FractalType) { + default: + this._DomainWarpSingle(coord); + break; + case FastNoiseLite.FractalType.DomainWarpProgressive: + this._DomainWarpFractalProgressive(coord); + break; + case FastNoiseLite.FractalType.DomainWarpIndependent: + this._DomainWarpFractalIndependent(coord); + break; + } } // prettier-ignore _Gradients2D = [ - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, - -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, - ]; + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, + -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, + ]; // prettier-ignore _RandVecs2D = [ - -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, - -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, - -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, - -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, - -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, - 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, - 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, - -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, - 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, - 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, - -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, - 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, - -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, - -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, - 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, - -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, - 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, - 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, - 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, - -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, - 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, - 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, - 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, - -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, - 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, - -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, - 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, - -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, - 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, - -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, - 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, - 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, - ]; + -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, + -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, + -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, + -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, + -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, + 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, + 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, + -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, + 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, + 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, + -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, + 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, + -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, + -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, + 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, + -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, + 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, + 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, + 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, + -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, + 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, + 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, + 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, + -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, + 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, + -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, + 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, + -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, + 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, + -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, + 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, + 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, + ]; // prettier-ignore _Gradients3D = [ - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 - ]; + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 + ]; // prettier-ignore _RandVecs3D = [ - -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, - 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, - -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, - -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, - 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, - -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, - 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, - 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, - -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, - 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, - -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, - -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, - 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, - 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, - -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, - 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, - 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, - -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, - -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, - -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, - -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, - 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, - 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, - 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, - -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, - -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, - -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, - 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, - 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, - 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, - 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, - -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 - ]; + -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, + 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, + -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, + -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, + 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, + -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, + 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, + 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, + -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, + 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, + -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, + -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, + 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, + 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, + -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, + 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, + 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, + -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, + -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, + -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, + -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, + 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, + 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, + 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, + -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, + -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, + -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, + 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, + 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, + 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, + 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, + -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 + ]; _PrimeX = 501125321; _PrimeY = 1136930381; @@ -698,7 +698,7 @@ class FastNoiseLite { * @returns {number} */ static _Lerp(a, b, t) { - return a + t * (b - a); + return a + t * (b - a); } /** @@ -707,7 +707,7 @@ class FastNoiseLite { * @returns {number} */ static _InterpHermite(t) { - return t * t * (3 - 2 * t); + return t * t * (3 - 2 * t); } /** @@ -716,7 +716,7 @@ class FastNoiseLite { * @returns {number} */ static _InterpQuintic(t) { - return t * t * t * (t * (t * 6 - 15) + 10); + return t * t * t * (t * (t * 6 - 15) + 10); } /** @@ -729,8 +729,8 @@ class FastNoiseLite { * @returns {number} */ static _CubicLerp(a, b, c, d, t) { - let p = d - c - (a - b); - return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; + let p = d - c - (a - b); + return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; } /** @@ -739,22 +739,22 @@ class FastNoiseLite { * @returns {number} */ static _PingPong(t) { - t -= Math.trunc(t * 0.5) * 2; - return t < 1 ? t : 2 - t; + t -= Math.trunc(t * 0.5) * 2; + return t < 1 ? t : 2 - t; } /** * @private */ _CalculateFractalBounding() { - let gain = Math.abs(this._Gain); - let amp = gain; - let ampFractal = 1.0; - for (let i = 1; i < this._Octaves; i++) { - ampFractal += amp; - amp *= gain; - } - this._FractalBounding = 1 / ampFractal; + let gain = Math.abs(this._Gain); + let amp = gain; + let ampFractal = 1.0; + for (let i = 1; i < this._Octaves; i++) { + ampFractal += amp; + amp *= gain; + } + this._FractalBounding = 1 / ampFractal; } /** @@ -765,9 +765,9 @@ class FastNoiseLite { * @returns {number} */ _HashR2(seed, xPrimed, yPrimed) { - let hash = seed ^ xPrimed ^ yPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; + let hash = seed ^ xPrimed ^ yPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; } /** @@ -778,10 +778,10 @@ class FastNoiseLite { * @param {number} zPrimed * @returns {number} */ - _HashR3(seed, xPrimed, yPrimed, zPrimed){ - let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; + _HashR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; } /** @@ -792,11 +792,11 @@ class FastNoiseLite { * @returns {number} */ _ValCoordR2(seed, xPrimed, yPrimed) { - let hash = this._HashR2(seed, xPrimed, yPrimed); + let hash = this._HashR2(seed, xPrimed, yPrimed); - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); } /** @@ -807,12 +807,12 @@ class FastNoiseLite { * @param {number} zPrimed * @returns {number} */ - _ValCoordR3(seed, xPrimed, yPrimed, zPrimed){ - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + _ValCoordR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); } /** @@ -825,14 +825,14 @@ class FastNoiseLite { * @returns {number} */ _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - hash ^= hash >> 15; - hash &= 127 << 1; + let hash = this._HashR2(seed, xPrimed, yPrimed); + hash ^= hash >> 15; + hash &= 127 << 1; - let xg = this._Gradients2D[hash]; - let yg = this._Gradients2D[hash | 1]; + let xg = this._Gradients2D[hash]; + let yg = this._Gradients2D[hash | 1]; - return xd * xg + yd * yg; + return xd * xg + yd * yg; } /** @@ -847,15 +847,15 @@ class FastNoiseLite { * @returns {number} */ _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - hash ^= hash >> 15; - hash &= 63 << 2; + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + hash ^= hash >> 15; + hash &= 63 << 2; - let xg = this._Gradients3D[hash]; - let yg = this._Gradients3D[hash | 1]; - let zg = this._Gradients3D[hash | 2]; + let xg = this._Gradients3D[hash]; + let yg = this._Gradients3D[hash | 1]; + let zg = this._Gradients3D[hash | 2]; - return xd * xg + yd * yg + zd * zg; + return xd * xg + yd * yg + zd * zg; } /** @@ -866,22 +866,22 @@ class FastNoiseLite { * @returns {number} */ _GenNoiseSingleR2(seed, x, y) { - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R2(seed, x, y); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR2(seed, x, y); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR2(seed, x, y); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR2(seed, x, y); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR2(seed, x, y); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR2(seed, x, y); - default: - return 0; - } + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R2(seed, x, y); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR2(seed, x, y); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR2(seed, x, y); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR2(seed, x, y); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR2(seed, x, y); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR2(seed, x, y); + default: + return 0; + } } /** @@ -892,73 +892,77 @@ class FastNoiseLite { * @param {number} z * @returns {number} */ - _GenNoiseSingleR3(seed, x, y, z){ - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R3(seed, x, y, z); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR3(seed, x, y, z); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR3(seed, x, y, z); - default: - return 0; - } + _GenNoiseSingleR3(seed, x, y, z) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R3(seed, x, y, z); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR3(seed, x, y, z); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR3(seed, x, y, z); + default: + return 0; + } } /** * @private */ _UpdateTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: + this._TransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; default: - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: - this._TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - break; - default: - this._TransformType3D = FastNoiseLite.TransformType3D.None; - break; - } - break; - } + this._TransformType3D = FastNoiseLite.TransformType3D.None; + break; + } + break; + } } /** * @private */ _UpdateWarpTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._WarpTransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._WarpTransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; default: - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - break; - default: - this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; - break; - } - break; - } + this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; + break; + } + break; + } } /** @@ -967,21 +971,25 @@ class FastNoiseLite { * @param {number} y * @returns {number} */ - _GenFractalFBmR2(x,y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR2(seed++, x, y); - sum += noise * amp; - amp *= FastNoiseLite._Lerp(1.0, Math.min(noise + 1, 2) * 0.5, this._WeightedStrength); + _GenFractalFBmR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR2(seed++, x, y); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + Math.min(noise + 1, 2) * 0.5, + this._WeightedStrength + ); - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; } /** @@ -991,22 +999,26 @@ class FastNoiseLite { * @param {number} z * @returns {number} */ - _GenFractalFBmR3(x,y,z){ - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; + _GenFractalFBmR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR3(seed++, x, y, z); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + (noise + 1) * 0.5, + this._WeightedStrength + ); - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR3(seed++, x, y, z); - sum += noise * amp; - amp *= FastNoiseLite._Lerp(1.0, (noise + 1) * 0.5, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; } /** @@ -1015,21 +1027,21 @@ class FastNoiseLite { * @param {number} y * @returns {number} */ - _GenFractalRidgedR2(x,y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + _GenFractalRidgedR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; } /** @@ -1039,22 +1051,22 @@ class FastNoiseLite { * @param {number} z * @returns {number} */ - _GenFractalRidgedR3(x,y,z){ - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + _GenFractalRidgedR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; } /** @@ -1063,23 +1075,23 @@ class FastNoiseLite { * @param {number} y * @returns {number} */ - _GenFractalPingPongR2(x,y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + _GenFractalPingPongR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; } /** @@ -1089,24 +1101,24 @@ class FastNoiseLite { * @param {number} z * @returns {number} */ - _GenFractalPingPongR3(x,y,z){ - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + _GenFractalPingPongR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; } /** @@ -1116,62 +1128,76 @@ class FastNoiseLite { * @param {number} y * @returns {number} */ - _SingleOpenSimplex2R2(seed,x,y) { - const SQRT3 = 1.7320508075688772935274463415059; - const G2 = (3 - SQRT3) / 6; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let n0, n1, n2; - - let a = 0.5 - x0 * x0 - y0 * y0; - - if (a <= 0) { - n0 = 0; + _SingleOpenSimplex2R2(seed, x, y) { + const SQRT3 = 1.7320508075688772935274463415059; + const G2 = (3 - SQRT3) / 6; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let n0, n1, n2; + + let a = 0.5 - x0 * x0 - y0 * y0; + + if (a <= 0) { + n0 = 0; + } else { + n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); + } + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + + if (c <= 0) { + n2 = 0; + } else { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + n2 = + c * + c * + (c * c) * + this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); + } + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; } else { - n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); + n1 = + b * + b * + (b * b) * + this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); } - - let c = 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - - if (c <= 0) { - n2 = 0; - } else { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - n2 = c * c * (c * c) * this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); - } - - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = b * b * (b * b) * this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); - } + } else { + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = b * b * (b * b) * this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); - } + n1 = + b * + b * + (b * b) * + this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); } - return (n0 + n1 + n2) * 99.83685446303647; + } + return (n0 + n1 + n2) * 99.83685446303647; } /** @@ -1182,114 +1208,115 @@ class FastNoiseLite { * @param {number} z * @returns {number} */ - _SingleOpenSimplex2R3(seed,x,y,z){ - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let yNSign = Math.trunc((-1.0 - y0) | 1); - let xNSign = Math.trunc((-1.0 - x0) | 1); - let zNSign = Math.trunc((-1.0 - z0) | 1); - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let value = 0; - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - - for (let l = 0; ; l++) { - if (a > 0) { - value += a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); - } + _SingleOpenSimplex2R3(seed, x, y, z) { + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let yNSign = Math.trunc((-1.0 - y0) | 1); + let xNSign = Math.trunc((-1.0 - x0) | 1); + let zNSign = Math.trunc((-1.0 - z0) | 1); + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let value = 0; + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + + for (let l = 0; ; l++) { + if (a > 0) { + value += + a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); + } - if (ax0 >= ay0 && ax0 >= az0) { - let b = a + ax0 + ax0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i - xNSign * this._PrimeX, - j, - k, - x0 + xNSign, - y0, - z0 - ); - } - } else if (ay0 > ax0 && ay0 >= az0) { - let b = a + ay0 + ay0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i, - j - yNSign * this._PrimeY, - k, - x0, - y0 + yNSign, - z0 - ); - } - } else { - let b = a + az0 + az0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i, - j, - k - zNSign * this._PrimeZ, - x0, - y0, - z0 + zNSign - ); - } - } + if (ax0 >= ay0 && ax0 >= az0) { + let b = a + ax0 + ax0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i - xNSign * this._PrimeX, + j, + k, + x0 + xNSign, + y0, + z0 + ); + } + } else if (ay0 > ax0 && ay0 >= az0) { + let b = a + ay0 + ay0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j - yNSign * this._PrimeY, + k, + x0, + y0 + yNSign, + z0 + ); + } + } else { + let b = a + az0 + az0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j, + k - zNSign * this._PrimeZ, + x0, + y0, + z0 + zNSign + ); + } + } - if (l === 1) { - break; - } + if (l === 1) { + break; + } - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; - a += 0.75 - ax0 - (ay0 + az0); + a += 0.75 - ax0 - (ay0 + az0); - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; - seed = ~seed; - } - return value * 32.69428253173828125; + seed = ~seed; + } + return value * 32.69428253173828125; } /** @@ -1299,123 +1326,155 @@ class FastNoiseLite { * @param {number} y * @returns {number} */ - _SingleOpenSimplex2SR2(seed,x,y) { - // 2D OpenSimplex2S case is a modified 2D simplex noise. - - const SQRT3 = 1.7320508075688772935274463415059; - const G2 = (3 - SQRT3) / 6; - - /* - * --- Skew moved to TransformNoiseCoordinate method --- - * final FNLfloat F2 = 0.5f * (SQRT3 - 1); - * FNLfloat s = (x + y) * F2; - * x += s; y += s; - */ - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - let i1 = i + this._PrimeX; - let j1 = j + this._PrimeY; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; - let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); - let a1 = 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); - let x1 = x0 - (1 - 2 * G2); - let y1 = y0 - (1 - 2 * G2); - value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); - - // Nested conditionals were faster than compact bit logic/arithmetic. - let xmyi = xi - yi; - if (t > G2) { - if (xi + xmyi > 1) { - let x2 = x0 + (3 * G2 - 2); - let y2 = y0 + (3 * G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i + (this._PrimeX << 1), j + this._PrimeY, x2, y2); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * a2 * (a2 * a2) * this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } - } + _SingleOpenSimplex2SR2(seed, x, y) { + // 2D OpenSimplex2S case is a modified 2D simplex noise. + + const SQRT3 = 1.7320508075688772935274463415059; + const G2 = (3 - SQRT3) / 6; + + /* + * --- Skew moved to TransformNoiseCoordinate method --- + * final FNLfloat F2 = 0.5f * (SQRT3 - 1); + * FNLfloat s = (x + y) * F2; + * x += s; y += s; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + let i1 = i + this._PrimeX; + let j1 = j + this._PrimeY; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; + let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); + let a1 = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); + let x1 = x0 - (1 - 2 * G2); + let y1 = y0 - (1 - 2 * G2); + value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); + + // Nested conditionals were faster than compact bit logic/arithmetic. + let xmyi = xi - yi; + if (t > G2) { + if (xi + xmyi > 1) { + let x2 = x0 + (3 * G2 - 2); + let y2 = y0 + (3 * G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2( + seed, + i + (this._PrimeX << 1), + j + this._PrimeY, + x2, + y2 + ); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); + } + } - if (yi - xmyi > 1) { - let x3 = x0 + (3 * G2 - 1); - let y3 = y0 + (3 * G2 - 2); - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR2(seed, i + this._PrimeX, j + (this._PrimeY << 1), x3, y3); - } - } else { - let x3 = x0 + (G2 - 1); - let y3 = y0 + G2; - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * a3 * (a3 * a3) * this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); - } - } + if (yi - xmyi > 1) { + let x3 = x0 + (3 * G2 - 1); + let y3 = y0 + (3 * G2 - 2); + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2( + seed, + i + this._PrimeX, + j + (this._PrimeY << 1), + x3, + y3 + ); + } } else { - if (xi + xmyi < 0) { - let x2 = x0 + (1 - G2); - let y2 = y0 - G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * a2 * (a2 * a2) * this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); - } - } else { - let x2 = x0 + (G2 - 1); - let y2 = y0 + G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * a2 * (a2 * a2) * this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); - } - } + let x3 = x0 + (G2 - 1); + let y3 = y0 + G2; + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); + } + } + } else { + if (xi + xmyi < 0) { + let x2 = x0 + (1 - G2); + let y2 = y0 - G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); + } + } else { + let x2 = x0 + (G2 - 1); + let y2 = y0 + G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); + } + } - if (yi < xmyi) { - let x2 = x0 - G2; - let y2 = y0 - (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * a2 * (a2 * a2) * this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * a2 * (a2 * a2) * this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } - } + if (yi < xmyi) { + let x2 = x0 - G2; + let y2 = y0 - (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); + } } + } - return value * 18.24196194486065; + return value * 18.24196194486065; } /** @@ -1426,313 +1485,321 @@ class FastNoiseLite { * @param {number} z * @returns {number} */ - _SingleOpenSimplex2SR3 (seed, x, y, z) { - // 3D OpenSimplex2S case uses two offset rotated cube grids. + _SingleOpenSimplex2SR3(seed, x, y, z) { + // 3D OpenSimplex2S case uses two offset rotated cube grids. + + /* + * --- Rotation moved to TransformNoiseCoordinate method --- + * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); + * FNLfloat r = (x + y + z) * R3; // Rotation, not skew + * x = r - x; y = r - y; z = r - z; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let k = Math.floor(z); + let xi = x - i; + let yi = y - j; + let zi = z - k; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + let seed2 = seed + 1293373; + + let xNMask = Math.trunc(-0.5 - xi); + let yNMask = Math.trunc(-0.5 - yi); + let zNMask = Math.trunc(-0.5 - zi); + + let x0 = xi + xNMask; + let y0 = yi + yNMask; + let z0 = zi + zNMask; + let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; + let value = + a0 * + a0 * + (a0 * a0) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x0, + y0, + z0 + ); - /* - * --- Rotation moved to TransformNoiseCoordinate method --- - * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); - * FNLfloat r = (x + y + z) * R3; // Rotation, not skew - * x = r - x; y = r - y; z = r - z; - */ + let x1 = xi - 0.5; + let y1 = yi - 0.5; + let z1 = zi - 0.5; + let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; + value += + a1 * + a1 * + (a1 * a1) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + this._PrimeZ, + x1, + y1, + z1 + ); - let i = Math.floor(x); - let j = Math.floor(y); - let k = Math.floor(z); - let xi = x - i; - let yi = y - j; - let zi = z - k; + let xAFlipMask0 = ((xNMask | 1) << 1) * x1; + let yAFlipMask0 = ((yNMask | 1) << 1) * y1; + let zAFlipMask0 = ((zNMask | 1) << 1) * z1; + let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; + let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; + let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; + + let skip5 = false; + let a2 = xAFlipMask0 + a0; + if (a2 > 0) { + let x2 = x0 - (xNMask | 1); + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x2, + y0, + z0 + ); + } else { + let a3 = yAFlipMask0 + zAFlipMask0 + a0; + + if (a3 > 0) { + let x3 = x0; + let y3 = y0 - (yNMask | 1); + let z3 = z0 - (zNMask | 1); + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x3, + y3, + z3 + ); + } - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - let seed2 = seed + 1293373; - - let xNMask = Math.trunc(-0.5 - xi); - let yNMask = Math.trunc(-0.5 - yi); - let zNMask = Math.trunc(-0.5 - zi); - - let x0 = xi + xNMask; - let y0 = yi + yNMask; - let z0 = zi + zNMask; - let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; - let value = - a0 * - a0 * - (a0 * a0) * + let a4 = xAFlipMask1 + a1; + if (a4 > 0) { + let x4 = (xNMask | 1) + x1; + value += + a4 * + a4 * + (a4 * a4) * this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x0, - y0, - z0 + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + this._PrimeZ, + x4, + y1, + z1 ); + skip5 = true; + } + } - let x1 = xi - 0.5; - let y1 = yi - 0.5; - let z1 = zi - 0.5; - let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; + let skip9 = false; + let a6 = yAFlipMask0 + a0; + if (a6 > 0) { + let x6 = x0; + let y6 = y0 - (yNMask | 1); value += - a1 * - a1 * - (a1 * a1) * - this._GradCoordR3(seed2, i + this._PrimeX, j + this._PrimeY, k + this._PrimeZ, x1, y1, z1); - - let xAFlipMask0 = ((xNMask | 1) << 1) * x1; - let yAFlipMask0 = ((yNMask | 1) << 1) * y1; - let zAFlipMask0 = ((zNMask | 1) << 1) * z1; - let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; - let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; - let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; - - let skip5 = false; - let a2 = xAFlipMask0 + a0; - if (a2 > 0) { - let x2 = x0 - (xNMask | 1); - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x2, - y0, - z0 - ); - } else { - let a3 = yAFlipMask0 + zAFlipMask0 + a0; - - if (a3 > 0) { - let x3 = x0; - let y3 = y0 - (yNMask | 1); - let z3 = z0 - (zNMask | 1); - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x3, - y3, - z3 - ); - } - - let a4 = xAFlipMask1 + a1; - if (a4 > 0) { - let x4 = (xNMask | 1) + x1; - value += - a4 * - a4 * - (a4 * a4) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + this._PrimeZ, - x4, - y1, - z1 - ); - skip5 = true; - } + a6 * + a6 * + (a6 * a6) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x6, + y6, + z0 + ); + } else { + let a7 = xAFlipMask0 + zAFlipMask0 + a0; + if (a7 > 0) { + let x7 = x0 - (xNMask | 1); + let y7 = y0; + let z7 = z0 - (zNMask | 1); + value += + a7 * + a7 * + (a7 * a7) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x7, + y7, + z7 + ); } - let skip9 = false; - let a6 = yAFlipMask0 + a0; - if (a6 > 0) { - let x6 = x0; - let y6 = y0 - (yNMask | 1); - value += - a6 * - a6 * - (a6 * a6) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x6, - y6, - z0 - ); - } else { - let a7 = xAFlipMask0 + zAFlipMask0 + a0; - if (a7 > 0) { - let x7 = x0 - (xNMask | 1); - let y7 = y0; - let z7 = z0 - (zNMask | 1); - value += - a7 * - a7 * - (a7 * a7) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x7, - y7, - z7 - ); - } - - let a8 = yAFlipMask1 + a1; - if (a8 > 0) { - let x8 = x1; - let y8 = (yNMask | 1) + y1; - value += - a8 * - a8 * - (a8 * a8) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - x8, - y8, - z1 - ); - skip9 = true; - } + let a8 = yAFlipMask1 + a1; + if (a8 > 0) { + let x8 = x1; + let y8 = (yNMask | 1) + y1; + value += + a8 * + a8 * + (a8 * a8) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + x8, + y8, + z1 + ); + skip9 = true; } - - let skipD = false; - let aA = zAFlipMask0 + a0; - if (aA > 0) { - let xA = x0; - let yA = y0; - let zA = z0 - (zNMask | 1); - value += - aA * - aA * - (aA * aA) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - xA, - yA, - zA - ); - } else { - let aB = xAFlipMask0 + yAFlipMask0 + a0; - if (aB > 0) { - let xB = x0 - (xNMask | 1); - let yB = y0 - (yNMask | 1); - value += - aB * - aB * - (aB * aB) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - xB, - yB, - z0 - ); - } - - let aC = zAFlipMask1 + a1; - if (aC > 0) { - let xC = x1; - let yC = y1; - let zC = (zNMask | 1) + z1; - value += - aC * - aC * - (aC * aC) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - xC, - yC, - zC - ); - skipD = true; - } + } + + let skipD = false; + let aA = zAFlipMask0 + a0; + if (aA > 0) { + let xA = x0; + let yA = y0; + let zA = z0 - (zNMask | 1); + value += + aA * + aA * + (aA * aA) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + xA, + yA, + zA + ); + } else { + let aB = xAFlipMask0 + yAFlipMask0 + a0; + if (aB > 0) { + let xB = x0 - (xNMask | 1); + let yB = y0 - (yNMask | 1); + value += + aB * + aB * + (aB * aB) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + xB, + yB, + z0 + ); } - if (!skip5) { - let a5 = yAFlipMask1 + zAFlipMask1 + a1; - if (a5 > 0) { - let x5 = x1; - let y5 = (yNMask | 1) + y1; - let z5 = (zNMask | 1) + z1; - value += - a5 * - a5 * - (a5 * a5) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + (zNMask & (this._PrimeZ << 1)), - x5, - y5, - z5 - ); - } + let aC = zAFlipMask1 + a1; + if (aC > 0) { + let xC = x1; + let yC = y1; + let zC = (zNMask | 1) + z1; + value += + aC * + aC * + (aC * aC) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + xC, + yC, + zC + ); + skipD = true; } - - if (!skip9) { - let a9 = xAFlipMask1 + zAFlipMask1 + a1; - if (a9 > 0) { - let x9 = (xNMask | 1) + x1; - let y9 = y1; - let z9 = (zNMask | 1) + z1; - value += - a9 * - a9 * - (a9 * a9) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - x9, - y9, - z9 - ); - } + } + + if (!skip5) { + let a5 = yAFlipMask1 + zAFlipMask1 + a1; + if (a5 > 0) { + let x5 = x1; + let y5 = (yNMask | 1) + y1; + let z5 = (zNMask | 1) + z1; + value += + a5 * + a5 * + (a5 * a5) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + (zNMask & (this._PrimeZ << 1)), + x5, + y5, + z5 + ); } - - if (!skipD) { - let aD = xAFlipMask1 + yAFlipMask1 + a1; - if (aD > 0) { - let xD = (xNMask | 1) + x1; - let yD = (yNMask | 1) + y1; - value += - aD * - aD * - (aD * aD) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX << 1)), - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - xD, - yD, - z1 - ); - } + } + + if (!skip9) { + let a9 = xAFlipMask1 + zAFlipMask1 + a1; + if (a9 > 0) { + let x9 = (xNMask | 1) + x1; + let y9 = y1; + let z9 = (zNMask | 1) + z1; + value += + a9 * + a9 * + (a9 * a9) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + x9, + y9, + z9 + ); } + } + + if (!skipD) { + let aD = xAFlipMask1 + yAFlipMask1 + a1; + if (aD > 0) { + let xD = (xNMask | 1) + x1; + let yD = (yNMask | 1) + y1; + value += + aD * + aD * + (aD * aD) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX << 1)), + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + xD, + yD, + z1 + ); + } + } - return value * 9.046026385208288; + return value * 9.046026385208288; } /** @@ -1742,132 +1809,135 @@ class FastNoiseLite { * @param {number} y * @returns {number} */ - _SingleCellularR2(seed,x,y) { - /** - * - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - let xr = Math.round(x); - let yr = Math.round(y); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - - let closestHash = 0; - - let cellularJitter = 0.43701595 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - - switch (this._CellularDistanceFunction) { - default: - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY; - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = Math.abs(vecX) + Math.abs(vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = - Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - } + _SingleCellularR2(seed, x, y) { + /** + * + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + let xr = Math.round(x); + let yr = Math.round(y); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + + let closestHash = 0; + + let cellularJitter = 0.43701595 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + + switch (this._CellularDistanceFunction) { + default: + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY; + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = Math.abs(vecX) + Math.abs(vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + } + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); if ( - this._CellularDistanceFunction === FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue ) { - distance0 = Math.sqrt(distance0); - - if (this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue) { - distance1 = Math.sqrt(distance1); - } + distance1 = Math.sqrt(distance1); } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; - } - + } + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; + } } /** @@ -1878,147 +1948,161 @@ class FastNoiseLite { * @param {number} z * @returns {number} */ - _SingleCellularR3 (seed, x, y, z) { - let xr = Math.round(x); - let yr = Math.round(y); - let zr = Math.round(z); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - let closestHash = 0; - - let cellularJitter = 0.39614353 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - let zPrimedBase = (zr - 1) * this._PrimeZ; - - switch (this._CellularDistanceFunction) { - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; + _SingleCellularR3(seed, x, y, z) { + let xr = Math.round(x); + let yr = Math.round(y); + let zr = Math.round(z); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + let closestHash = 0; + + let cellularJitter = 0.39614353 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + let zPrimedBase = (zr - 1) * this._PrimeZ; + + switch (this._CellularDistanceFunction) { + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = - Math.abs(vecX) + - Math.abs(vecY) + - Math.abs(vecZ) + - (vecX * vecX + vecY * vecY + vecZ * vecZ); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = + Math.abs(vecX) + + Math.abs(vecY) + + Math.abs(vecZ) + + (vecX * vecX + vecY * vecY + vecZ * vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; } - break; - default: - break; - } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + default: + break; + } + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); if ( - this._CellularDistanceFunction === FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue ) { - distance0 = Math.sqrt(distance0); - - if (this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue) { - distance1 = Math.sqrt(distance1); - } - } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; + distance1 = Math.sqrt(distance1); } + } + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; + } } /** @@ -2029,34 +2113,34 @@ class FastNoiseLite { * @returns {number} */ _SinglePerlinR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xd0 = x - x0; - let yd0 = y - y0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y0, xd0, yd0), - this._GradCoordR2(seed, x1, y0, xd1, yd0), - xs - ); - let xf1 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y1, xd0, yd1), - this._GradCoordR2(seed, x1, y1, xd1, yd1), - xs - ); - - return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xd0 = x - x0; + let yd0 = y - y0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y0, xd0, yd0), + this._GradCoordR2(seed, x1, y0, xd1, yd0), + xs + ); + let xf1 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y1, xd0, yd1), + this._GradCoordR2(seed, x1, y1, xd1, yd1), + xs + ); + + return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; } /** @@ -2067,54 +2151,54 @@ class FastNoiseLite { * @param {number} z * @returns {number} */ - _SinglePerlinR3 (seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xd0 = x - x0; - let yd0 = y - y0; - let zd0 = z - z0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - let zd1 = zd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - let zs = FastNoiseLite._InterpQuintic(zd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), - this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), - this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), - this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), - xs - ); - let xf11 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), - this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), - xs - ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; + _SinglePerlinR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xd0 = x - x0; + let yd0 = y - y0; + let zd0 = z - z0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + let zd1 = zd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + let zs = FastNoiseLite._InterpQuintic(zd0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), + this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), + xs + ); + let xf10 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), + this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), + xs + ); + let xf01 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), + this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), + xs + ); + let xf11 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), + this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), + xs + ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; } /** @@ -2125,55 +2209,55 @@ class FastNoiseLite { * @returns {number} */ _SingleValueCubicR2(seed, x, y) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - - let xs = x - x1; - let ys = y - y1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - - return ( - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y0), - this._ValCoordR2(seed, x1, y0), - this._ValCoordR2(seed, x2, y0), - this._ValCoordR2(seed, x3, y0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y1), - this._ValCoordR2(seed, x1, y1), - this._ValCoordR2(seed, x2, y1), - this._ValCoordR2(seed, x3, y1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y2), - this._ValCoordR2(seed, x1, y2), - this._ValCoordR2(seed, x2, y2), - this._ValCoordR2(seed, x3, y2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y3), - this._ValCoordR2(seed, x1, y3), - this._ValCoordR2(seed, x2, y3), - this._ValCoordR2(seed, x3, y3), - xs - ), - ys - ) * - (1 / (1.5 * 1.5)) - ); + let x1 = Math.floor(x); + let y1 = Math.floor(y); + + let xs = x - x1; + let ys = y - y1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), + this._ValCoordR2(seed, x2, y0), + this._ValCoordR2(seed, x3, y0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), + this._ValCoordR2(seed, x2, y1), + this._ValCoordR2(seed, x3, y1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y2), + this._ValCoordR2(seed, x1, y2), + this._ValCoordR2(seed, x2, y2), + this._ValCoordR2(seed, x3, y2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y3), + this._ValCoordR2(seed, x1, y3), + this._ValCoordR2(seed, x2, y3), + this._ValCoordR2(seed, x3, y3), + xs + ), + ys + ) * + (1 / (1.5 * 1.5)) + ); } /** @@ -2185,158 +2269,158 @@ class FastNoiseLite { * @returns {number} */ _SingleValueCubicR3(seed, x, y, z) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - let z1 = Math.floor(z); - - let xs = x - x1; - let ys = y - y1; - let zs = z - z1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - z1 = Math.imul(z1, this._PrimeZ); - - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let z0 = z1 - this._PrimeZ; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let z2 = z1 + this._PrimeZ; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - let z3 = z1 + (this._PrimeZ << 1); - - return ( + let x1 = Math.floor(x); + let y1 = Math.floor(y); + let z1 = Math.floor(z); + + let xs = x - x1; + let ys = y - y1; + let zs = z - z1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + z1 = Math.imul(z1, this._PrimeZ); + + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let z0 = z1 - this._PrimeZ; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let z2 = z1 + this._PrimeZ; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + let z3 = z1 + (this._PrimeZ << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - this._ValCoordR3(seed, x2, y0, z0), - this._ValCoordR3(seed, x3, y0, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - this._ValCoordR3(seed, x2, y1, z0), - this._ValCoordR3(seed, x3, y1, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z0), - this._ValCoordR3(seed, x1, y2, z0), - this._ValCoordR3(seed, x2, y2, z0), - this._ValCoordR3(seed, x3, y2, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z0), - this._ValCoordR3(seed, x1, y3, z0), - this._ValCoordR3(seed, x2, y3, z0), - this._ValCoordR3(seed, x3, y3, z0), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - this._ValCoordR3(seed, x2, y0, z1), - this._ValCoordR3(seed, x3, y0, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - this._ValCoordR3(seed, x2, y1, z1), - this._ValCoordR3(seed, x3, y1, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z1), - this._ValCoordR3(seed, x1, y2, z1), - this._ValCoordR3(seed, x2, y2, z1), - this._ValCoordR3(seed, x3, y2, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z1), - this._ValCoordR3(seed, x1, y3, z1), - this._ValCoordR3(seed, x2, y3, z1), - this._ValCoordR3(seed, x3, y3, z1), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z2), - this._ValCoordR3(seed, x1, y0, z2), - this._ValCoordR3(seed, x2, y0, z2), - this._ValCoordR3(seed, x3, y0, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z2), - this._ValCoordR3(seed, x1, y1, z2), - this._ValCoordR3(seed, x2, y1, z2), - this._ValCoordR3(seed, x3, y1, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z2), - this._ValCoordR3(seed, x1, y2, z2), - this._ValCoordR3(seed, x2, y2, z2), - this._ValCoordR3(seed, x3, y2, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z2), - this._ValCoordR3(seed, x1, y3, z2), - this._ValCoordR3(seed, x2, y3, z2), - this._ValCoordR3(seed, x3, y3, z2), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z3), - this._ValCoordR3(seed, x1, y0, z3), - this._ValCoordR3(seed, x2, y0, z3), - this._ValCoordR3(seed, x3, y0, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z3), - this._ValCoordR3(seed, x1, y1, z3), - this._ValCoordR3(seed, x2, y1, z3), - this._ValCoordR3(seed, x3, y1, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z3), - this._ValCoordR3(seed, x1, y2, z3), - this._ValCoordR3(seed, x2, y2, z3), - this._ValCoordR3(seed, x3, y2, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z3), - this._ValCoordR3(seed, x1, y3, z3), - this._ValCoordR3(seed, x2, y3, z3), - this._ValCoordR3(seed, x3, y3, z3), - xs - ), - ys - ), - zs - ) * - (1 / (1.5 * 1.5 * 1.5)) - ); + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + this._ValCoordR3(seed, x2, y0, z0), + this._ValCoordR3(seed, x3, y0, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + this._ValCoordR3(seed, x2, y1, z0), + this._ValCoordR3(seed, x3, y1, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z0), + this._ValCoordR3(seed, x1, y2, z0), + this._ValCoordR3(seed, x2, y2, z0), + this._ValCoordR3(seed, x3, y2, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z0), + this._ValCoordR3(seed, x1, y3, z0), + this._ValCoordR3(seed, x2, y3, z0), + this._ValCoordR3(seed, x3, y3, z0), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + this._ValCoordR3(seed, x2, y0, z1), + this._ValCoordR3(seed, x3, y0, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + this._ValCoordR3(seed, x2, y1, z1), + this._ValCoordR3(seed, x3, y1, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z1), + this._ValCoordR3(seed, x1, y2, z1), + this._ValCoordR3(seed, x2, y2, z1), + this._ValCoordR3(seed, x3, y2, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z1), + this._ValCoordR3(seed, x1, y3, z1), + this._ValCoordR3(seed, x2, y3, z1), + this._ValCoordR3(seed, x3, y3, z1), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z2), + this._ValCoordR3(seed, x1, y0, z2), + this._ValCoordR3(seed, x2, y0, z2), + this._ValCoordR3(seed, x3, y0, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z2), + this._ValCoordR3(seed, x1, y1, z2), + this._ValCoordR3(seed, x2, y1, z2), + this._ValCoordR3(seed, x3, y1, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z2), + this._ValCoordR3(seed, x1, y2, z2), + this._ValCoordR3(seed, x2, y2, z2), + this._ValCoordR3(seed, x3, y2, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z2), + this._ValCoordR3(seed, x1, y3, z2), + this._ValCoordR3(seed, x2, y3, z2), + this._ValCoordR3(seed, x3, y3, z2), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z3), + this._ValCoordR3(seed, x1, y0, z3), + this._ValCoordR3(seed, x2, y0, z3), + this._ValCoordR3(seed, x3, y0, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z3), + this._ValCoordR3(seed, x1, y1, z3), + this._ValCoordR3(seed, x2, y1, z3), + this._ValCoordR3(seed, x3, y1, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z3), + this._ValCoordR3(seed, x1, y2, z3), + this._ValCoordR3(seed, x2, y2, z3), + this._ValCoordR3(seed, x3, y2, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z3), + this._ValCoordR3(seed, x1, y3, z3), + this._ValCoordR3(seed, x2, y3, z3), + this._ValCoordR3(seed, x3, y3, z3), + xs + ), + ys + ), + zs + ) * + (1 / (1.5 * 1.5 * 1.5)) + ); } /** @@ -2347,21 +2431,29 @@ class FastNoiseLite { * @returns {number} */ _SingleValueR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp(this._ValCoordR2(seed, x0, y0), this._ValCoordR2(seed, x1, y0), xs); - let xf1 = FastNoiseLite._Lerp(this._ValCoordR2(seed, x0, y1), this._ValCoordR2(seed, x1, y1), xs); - - return FastNoiseLite._Lerp(xf0, xf1, ys); + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), + xs + ); + let xf1 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), + xs + ); + + return FastNoiseLite._Lerp(xf0, xf1, ys); } /** @@ -2373,895 +2465,983 @@ class FastNoiseLite { * @returns {number} */ _SingleValueR3(seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - let zs = FastNoiseLite._InterpHermite(z - z0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - xs - ); - let xf11 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - xs - ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs); + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + let zs = FastNoiseLite._InterpHermite(z - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + xs + ); + let xf10 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + xs + ); + let xf01 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + xs + ); + let xf11 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + xs + ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs); } /** * @private */ _DoSingleDomainWarp() { - /** - * - * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector2} coord - * @param {number} x - * @param {number} y - */ - let R2 = (seed, amp, freq, coord, x, y) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 38.283687591552734375, - freq, - coord, - false, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 16.0, - freq, - coord, - true, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); - break; - } - }; - - /** - * - * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector3} coord - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, amp, freq, coord, x, y, z) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 32.69428253173828125, - freq, - coord, - false, - x, - y, - z - ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 7.71604938271605, - freq, - coord, - true, - x, - y, - z - ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); - break; - } - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - return R2(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); + /** + * + * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + let R2 = (seed, amp, freq, coord, x, y) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 38.283687591552734375, + freq, + coord, + false, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 16.0, + freq, + coord, + true, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); + break; } - - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - return R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] + }; + + /** + * + * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, amp, freq, coord, x, y, z) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 32.69428253173828125, + freq, + coord, + false, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 7.71604938271605, + freq, + coord, + true, + x, + y, + z ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); + break; } + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + return R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] + ); + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + return R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } } /** * @private */ _DomainWarpSingle() { - /** - * - * @param {Vector2} coord - */ - let R2 = coord => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - const SQRT3 = 1.7320508075688772935274463415059; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - default: - break; - } + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + const SQRT3 = 1.7320508075688772935274463415059; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + default: + break; + } - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = coord => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - break; - default: - break; + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + break; + default: + break; + } - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - }; + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + }; - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } } _DomainWarpFractalProgressive() { - /** - * - * @param {Vector2} coord - */ - let R2 = coord => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - const SQRT3 = 1.7320508075688772935274463415059; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - default: - break; - } + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + for (let i = 0; i < this._Octaves; i++) { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + const SQRT3 = 1.7320508075688772935274463415059; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + default: + break; + } - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = coord => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - } - break; - default: - break; - } + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } + for (let i = 0; i < this._Octaves; i++) { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + } + break; + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } } /** * @private */ _DomainWarpFractalIndependent() { - /** - * - * @param {Vector2} coord - */ - let R2 = coord => { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - const SQRT3 = 1.7320508075688772935274463415059; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - default: - break; - } - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + const SQRT3 = 1.7320508075688772935274463415059; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + default: + break; + } + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; } - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = coord => { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - } - break; - default: - break; + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; } - - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; } - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); + break; + default: + break; } - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } } /** * @private */ _SingleDomainWarpBasicGrid() { - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord - * @param {number} x - * @param {number} y - */ - - let R2 = (seed, warpAmp, frequency, coord, x, y) => { - let xf = x * frequency; - let yf = y * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); - let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); - - let lx0x = FastNoiseLite._Lerp(this._RandVecs2D[hash0], this._RandVecs2D[hash1], xs); - let ly0x = FastNoiseLite._Lerp(this._RandVecs2D[hash0 | 1], this._RandVecs2D[hash1 | 1], xs); - - hash0 = this._HashR2(seed, x0, y1) & (255 << 1); - hash1 = this._HashR2(seed, x1, y1) & (255 << 1); - - let lx1x = FastNoiseLite._Lerp(this._RandVecs2D[hash0], this._RandVecs2D[hash1], xs); - let ly1x = FastNoiseLite._Lerp(this._RandVecs2D[hash0 | 1], this._RandVecs2D[hash1 | 1], xs); - - coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; - coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; - }; - - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { - let xf = x * frequency; - let yf = y * frequency; - let zf = z * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - let z0 = Math.floor(zf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - let zs = FastNoiseLite._InterpHermite(zf - z0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); - let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); - - let lx0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0], this._RandVecs3D[hash1], xs); - let ly0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 1], this._RandVecs3D[hash1 | 1], xs); - let lz0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 2], this._RandVecs3D[hash1 | 2], xs); - - hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); - - let lx1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0], this._RandVecs3D[hash1], xs); - let ly1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 1], this._RandVecs3D[hash1 | 1], xs); - let lz1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 2], this._RandVecs3D[hash1 | 2], xs); - - let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); - let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); - let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); - - hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); - - lx0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0], this._RandVecs3D[hash1], xs); - ly0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 1], this._RandVecs3D[hash1 | 1], xs); - lz0x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 2], this._RandVecs3D[hash1 | 2], xs); - - hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); - - lx1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0], this._RandVecs3D[hash1], xs); - ly1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 1], this._RandVecs3D[hash1 | 1], xs); - lz1x = FastNoiseLite._Lerp(this._RandVecs3D[hash0 | 2], this._RandVecs3D[hash1 | 2], xs); - - coord.x += FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * warpAmp; - coord.y += FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * warpAmp; - coord.z += FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * warpAmp; - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - R2(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); - } + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + + let R2 = (seed, warpAmp, frequency, coord, x, y) => { + let xf = x * frequency; + let yf = y * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); - } + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); + let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + hash0 = this._HashR2(seed, x0, y1) & (255 << 1); + hash1 = this._HashR2(seed, x1, y1) & (255 << 1); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; + coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { + let xf = x * frequency; + let yf = y * frequency; + let zf = z * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + let z0 = Math.floor(zf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + let zs = FastNoiseLite._InterpHermite(zf - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); + let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); + let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); + let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); + + hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); + + lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); + + lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + coord.x += + FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * + warpAmp; + coord.y += + FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * + warpAmp; + coord.z += + FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * + warpAmp; + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] + ); + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } } /** * @private */ _SingleDomainWarpOpenSimplex2Gradient() { - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y - */ - let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { - const SQRT3 = 1.7320508075688772935274463415059; - const G2 = (3 - SQRT3) / 6; - - x *= frequency; - y *= frequency; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let vx, vy; - vx = vy = 0; - - let a = 0.5 - x0 * x0 - y0 * y0; - if (a > 0) { - let aaaa = a * a * (a * a); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i, j) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i, j); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x0 * xg + y0 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += aaaa * xo; - vy += aaaa * yo; - } + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + */ + let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { + const SQRT3 = 1.7320508075688772935274463415059; + const G2 = (3 - SQRT3) / 6; - let c = 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - if (c > 0) { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - let cccc = c * c * (c * c); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x2 * xg + y2 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += cccc * xo; - vy += cccc * yo; - } + x *= frequency; + y *= frequency; - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i, j + this._PrimeY); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += bbbb * xo; - vy += bbbb * yo; - } + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let vx, vy; + vx = vy = 0; + + let a = 0.5 - x0 * x0 - y0 * y0; + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i, j) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i, j); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x0 * xg + y0 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += aaaa * xo; + vy += aaaa * yo; + } + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + if (c > 0) { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + let cccc = c * c * (c * c); + let xo, yo; + if (outGradOnly) { + let hash = + this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & + (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x2 * xg + y2 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += cccc * xo; + vy += cccc * yo; + } + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i + this._PrimeX, j); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += bbbb * xo; - vy += bbbb * yo; - } + let hash = this._HashR2(seed, i, j + this._PrimeY); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x1 * xg + y1 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; } + vx += bbbb * xo; + vy += bbbb * yo; + } + } else { + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i + this._PrimeX, j); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x1 * xg + y1 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += bbbb * xo; + vy += bbbb * yo; + } + } - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - }; - - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { - x *= frequency; - y *= frequency; - z *= frequency; - - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let xNSign = (-x0 - 1.0) | 1; - let yNSign = (-y0 - 1.0) | 1; - let zNSign = (-z0 - 1.0) | 1; - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let vx, vy, vz; - vx = vy = vz = 0; - - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - for (let l = 0; ; l++) { - if (a > 0) { - let aaaa = a * a * (a * a); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i, j, k) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; - } else { - let hash = this._HashR3(seed, i, j, k); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x0 * xg + y0 * yg + z0 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; - } - vx += aaaa * xo; - vy += aaaa * yo; - vz += aaaa * zo; - } + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { + x *= frequency; + y *= frequency; + z *= frequency; - let b = a; - let i1 = i; - let j1 = j; - let k1 = k; - let x1 = x0; - let y1 = y0; - let z1 = z0; - - if (ax0 >= ay0 && ax0 >= az0) { - x1 += xNSign; - b = b + ax0 + ax0; - i1 -= xNSign * this._PrimeX; - } else if (ay0 > ax0 && ay0 >= az0) { - y1 += yNSign; - b = b + ay0 + ay0; - j1 -= yNSign * this._PrimeY; - } else { - z1 += zNSign; - b = b + az0 + az0; - k1 -= zNSign * this._PrimeZ; - } + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; - if (b > 1) { - b -= 1; - let bbbb = b * b * (b * b); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; - } else { - let hash = this._HashR3(seed, i1, j1, k1); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x1 * xg + y1 * yg + z1 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; - } - vx += bbbb * xo; - vy += bbbb * yo; - vz += bbbb * zo; - } + let xNSign = (-x0 - 1.0) | 1; + let yNSign = (-y0 - 1.0) | 1; + let zNSign = (-z0 - 1.0) | 1; - if (l === 1) break; + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; + let vx, vy, vz; + vx = vy = vz = 0; - a += 0.75 - ax0 - (ay0 + az0); + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + for (let l = 0; ; l++) { + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i, j, k) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i, j, k); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x0 * xg + y0 * yg + z0 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; + } + vx += aaaa * xo; + vy += aaaa * yo; + vz += aaaa * zo; + } + + let b = a; + let i1 = i; + let j1 = j; + let k1 = k; + let x1 = x0; + let y1 = y0; + let z1 = z0; + + if (ax0 >= ay0 && ax0 >= az0) { + x1 += xNSign; + b = b + ax0 + ax0; + i1 -= xNSign * this._PrimeX; + } else if (ay0 > ax0 && ay0 >= az0) { + y1 += yNSign; + b = b + ay0 + ay0; + j1 -= yNSign * this._PrimeY; + } else { + z1 += zNSign; + b = b + az0 + az0; + k1 -= zNSign * this._PrimeZ; + } + + if (b > 1) { + b -= 1; + let bbbb = b * b * (b * b); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i1, j1, k1); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x1 * xg + y1 * yg + z1 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; + } + vx += bbbb * xo; + vy += bbbb * yo; + vz += bbbb * zo; + } - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; + if (l === 1) break; - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; - seed += 1293373; - } + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - coord.z += vz * warpAmp; - }; - - if (arguments.length === 7) { - R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); - } + a += 0.75 - ax0 - (ay0 + az0); - if (arguments.length === 8) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6], - arguments[7] - ); + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed += 1293373; } + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + coord.z += vz * warpAmp; + }; + + if (arguments.length === 7) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + + if (arguments.length === 8) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6], + arguments[7] + ); + } } -} + } -class Vector2 { + class Vector2 { /** * 2d Vector * @param {number} x * @param {number} y */ constructor(x, y) { - this.x = x; - this.y = y; + this.x = x; + this.y = y; } -} + } -class Vector3 { + class Vector3 { /** * 3d Vector * @param {number} x @@ -3269,8 +3449,11 @@ class Vector3 { * @param {number} z */ constructor(x, y, z) { - this.x = x; - this.y = y; - this.z = z; + this.x = x; + this.y = y; + this.z = z; } -} \ No newline at end of file + } + + Scratch.extensions.register(new PerlinNoise()); +})((window.Scratch = window.Scratch || {})); From 225741c58de681fac9d3fb00e8ecbe0db0e3c075 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 16:25:28 -0700 Subject: [PATCH 04/36] eslint fix hopefully --- extensions/Corbnorb/noise.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 9f3b7b5129..a8dd8e09d8 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -454,13 +454,14 @@ switch (this._NoiseType) { case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: + case FastNoiseLite.NoiseType.OpenSimplex2S: { const SQRT3 = 1.7320508075688772935274463415059; const F2 = 0.5 * (SQRT3 - 1); let t = (x + y) * F2; x += t; y += t; break; + } default: break; } @@ -508,13 +509,14 @@ y += xz * 0.577350269189626; break; } - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { const R3 = 2.0 / 3.0; let r = (x + y + z) * R3; x = r - x; y = r - y; z = r - z; break; + } default: break; } @@ -1329,7 +1331,7 @@ _SingleOpenSimplex2SR2(seed, x, y) { // 2D OpenSimplex2S case is a modified 2D simplex noise. - const SQRT3 = 1.7320508075688772935274463415059; + const SQRT3 = 1.7320508075688772; const G2 = (3 - SQRT3) / 6; /* @@ -2633,13 +2635,14 @@ let ys = coord.y; switch (this._DomainWarpType) { case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - const SQRT3 = 1.7320508075688772935274463415059; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; const F2 = 0.5 * (SQRT3 - 1); let t = (xs + ys) * F2; xs += t; ys += t; break; + } default: break; } @@ -2681,13 +2684,14 @@ ys += xz * 0.577350269189626; } break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { const R3 = 2.0 / 3.0; let r = (xs + ys + zs) * R3; // Rotation, not skew xs = r - xs; ys = r - ys; zs = r - zs; break; + } default: break; } @@ -2719,13 +2723,14 @@ let ys = coord.y; switch (this._DomainWarpType) { case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { const SQRT3 = 1.7320508075688772935274463415059; const F2 = 0.5 * (SQRT3 - 1); let t = (xs + ys) * F2; xs += t; ys += t; break; + } default: break; } @@ -2815,13 +2820,14 @@ let ys = coord.y; switch (this._DomainWarpType) { case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - const SQRT3 = 1.7320508075688772935274463415059; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; const F2 = 0.5 * (SQRT3 - 1); let t = (xs + ys) * F2; xs += t; ys += t; break; + } default: break; } @@ -3122,7 +3128,7 @@ * @param {number} y */ let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { - const SQRT3 = 1.7320508075688772935274463415059; + const SQRT3 = 1.7320508075688772; const G2 = (3 - SQRT3) / 6; x *= frequency; From bda1710f6c183c59a313b077455ba41af5b7f145 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 16:28:40 -0700 Subject: [PATCH 05/36] i hate precision loss --- extensions/Corbnorb/noise.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index a8dd8e09d8..ddaa1cc335 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -455,7 +455,7 @@ switch (this._NoiseType) { case FastNoiseLite.NoiseType.OpenSimplex2: case FastNoiseLite.NoiseType.OpenSimplex2S: { - const SQRT3 = 1.7320508075688772935274463415059; + const SQRT3 = 1.7320508075688772; const F2 = 0.5 * (SQRT3 - 1); let t = (x + y) * F2; x += t; @@ -1131,7 +1131,7 @@ * @returns {number} */ _SingleOpenSimplex2R2(seed, x, y) { - const SQRT3 = 1.7320508075688772935274463415059; + const SQRT3 = 1.7320508075688772; const G2 = (3 - SQRT3) / 6; let i = Math.floor(x); @@ -2724,7 +2724,7 @@ switch (this._DomainWarpType) { case FastNoiseLite.DomainWarpType.OpenSimplex2: case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772935274463415059; + const SQRT3 = 1.7320508075688772; const F2 = 0.5 * (SQRT3 - 1); let t = (xs + ys) * F2; xs += t; From 63448a5a0331e0e0f9bcc367137db6c2b77a2432 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 16:36:24 -0700 Subject: [PATCH 06/36] changes --- extensions/Corbnorb/noise.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index ddaa1cc335..546c359b33 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -1,5 +1,5 @@ // Name: Noise -// ID: noise +// ID: noise-corbnorb // Description: Adds many types of noises using FastNoiseLite // By: Corbnorbs // Original: Auburn @@ -8,12 +8,12 @@ (function (Scratch) { "use strict"; - let noises = new Object(); + const noises = Object.create(null); const BlockType = Scratch.BlockType; const ArgumentType = Scratch.ArgumentType; - class PerlinNoise { + class Noise { constructor() { this.noiseSeed = 0; this.worleySeed = 0; @@ -22,7 +22,7 @@ getInfo() { return { - id: "noise", + id: "noise-corbnorb", name: "Noise", color1: "#b5074c", color2: "#990841", @@ -731,7 +731,7 @@ * @returns {number} */ static _CubicLerp(a, b, c, d, t) { - let p = d - c - (a - b); + const p = d - c - (a - b); return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; } @@ -3461,5 +3461,5 @@ } } - Scratch.extensions.register(new PerlinNoise()); + Scratch.extensions.register(new Noise()); })((window.Scratch = window.Scratch || {})); From d0c9e7a4818b29391ed3928fd674ee8919c10190 Mon Sep 17 00:00:00 2001 From: Cubester Date: Wed, 25 Dec 2024 18:38:20 -0500 Subject: [PATCH 07/36] Fix this --- extensions/extensions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/extensions.json b/extensions/extensions.json index 1c461be5f3..d0fa8b0574 100644 --- a/extensions/extensions.json +++ b/extensions/extensions.json @@ -96,6 +96,6 @@ "itchio", "gamejolt", "obviousAlexC/newgroundsIO", - "Corbnorb/noise" + "Corbnorb/noise", "Lily/McUtils" // McUtils should always be the last item. ] From 169b1cfdb41915e9c3d91b49ac8fef01f3a86a95 Mon Sep 17 00:00:00 2001 From: Cubester Date: Wed, 25 Dec 2024 18:42:46 -0500 Subject: [PATCH 08/36] More fixes --- extensions/Corbnorb/noise.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 546c359b33..db3b247ca5 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -1,6 +1,6 @@ // Name: Noise // ID: noise-corbnorb -// Description: Adds many types of noises using FastNoiseLite +// Description: Adds many types of noises using FastNoiseLite. // By: Corbnorbs // Original: Auburn // License: MPL-2.0 @@ -14,16 +14,11 @@ const ArgumentType = Scratch.ArgumentType; class Noise { - constructor() { - this.noiseSeed = 0; - this.worleySeed = 0; - this.time = performance.now(); - } getInfo() { return { id: "noise-corbnorb", - name: "Noise", + name: Scratch.translate("Noise"), color1: "#b5074c", color2: "#990841", docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", @@ -31,7 +26,7 @@ { opcode: "initNoise", blockType: BlockType.COMMAND, - text: "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]", + text: Scratch.translate("create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]"), arguments: { ID: { type: ArgumentType.STRING, @@ -74,7 +69,7 @@ { opcode: "getNoise", blockType: BlockType.REPORTER, - text: "get noise id:[ID] at x:[X] y:[Y] z:[Z]", + text: Scratch.translate("get noise id:[ID] at x:[X] y:[Y] z:[Z]"), arguments: { ID: { type: ArgumentType.STRING, @@ -3462,4 +3457,4 @@ } Scratch.extensions.register(new Noise()); -})((window.Scratch = window.Scratch || {})); +})(Scratch); From 835a7da6c8c66d0c5182870cefcabb97dd914b7e Mon Sep 17 00:00:00 2001 From: Cubester Date: Wed, 25 Dec 2024 18:44:20 -0500 Subject: [PATCH 09/36] Format again --- extensions/Corbnorb/noise.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index db3b247ca5..4d33f978bc 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -14,7 +14,6 @@ const ArgumentType = Scratch.ArgumentType; class Noise { - getInfo() { return { id: "noise-corbnorb", @@ -26,7 +25,9 @@ { opcode: "initNoise", blockType: BlockType.COMMAND, - text: Scratch.translate("create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]"), + text: Scratch.translate( + "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]" + ), arguments: { ID: { type: ArgumentType.STRING, From 6a695cd151b3d63eb03047faa65de36fd6ad0e04 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 16:49:21 -0700 Subject: [PATCH 10/36] casted --- extensions/Corbnorb/noise.js | 6495 +++++++++++++++++----------------- 1 file changed, 3251 insertions(+), 3244 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 546c359b33..45cfb98b06 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -6,3460 +6,3467 @@ // License: MPL-2.0 (function (Scratch) { - "use strict"; - - const noises = Object.create(null); - - const BlockType = Scratch.BlockType; - const ArgumentType = Scratch.ArgumentType; - - class Noise { - constructor() { - this.noiseSeed = 0; - this.worleySeed = 0; - this.time = performance.now(); - } - - getInfo() { - return { - id: "noise-corbnorb", - name: "Noise", - color1: "#b5074c", - color2: "#990841", - docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", - blocks: [ - { - opcode: "initNoise", - blockType: BlockType.COMMAND, - text: "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]", - arguments: { - ID: { - type: ArgumentType.STRING, - defaultValue: "myNoise", - }, - SEED: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - TYPE: { - type: ArgumentType.STRING, - menu: "NOISE_TYPE", - defaultValue: "Perlin", - }, - OCTAVES: { - type: ArgumentType.NUMBER, - defaultValue: "1", - }, - FREQUENCY: { - type: ArgumentType.NUMBER, - defaultValue: "0.01", - }, - FRACTAL: { - type: ArgumentType.STRING, - menu: "FRACTAL_TYPE", - defaultValue: "FBm", - }, - INVERTED: { - type: ArgumentType.STRING, - menu: "INVERTED_MENU", - defaultValue: "false", - }, - EASING: { - type: ArgumentType.STRING, - menu: "EASING_TYPE", - defaultValue: "Linear", + "use strict"; + + const noises = Object.create(null); + + const BlockType = Scratch.BlockType; + const ArgumentType = Scratch.ArgumentType; + + class Noise { + constructor() { + this.noiseSeed = 0; + this.worleySeed = 0; + this.time = performance.now(); + } + + getInfo() { + return { + id: "noise-corbnorb", + name: "Noise", + color1: "#b5074c", + color2: "#990841", + docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", + blocks: [ + { + opcode: "initNoise", + blockType: BlockType.COMMAND, + text: "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL]", + arguments: { + ID: { + type: ArgumentType.STRING, + defaultValue: "myNoise", + }, + SEED: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + TYPE: { + type: ArgumentType.STRING, + menu: "NOISE_TYPE", + defaultValue: "Perlin", + }, + OCTAVES: { + type: ArgumentType.NUMBER, + defaultValue: "1", + }, + FREQUENCY: { + type: ArgumentType.NUMBER, + defaultValue: "0.01", + }, + FRACTAL: { + type: ArgumentType.STRING, + menu: "FRACTAL_TYPE", + defaultValue: "FBm", + }, }, }, - }, - { - opcode: "getNoise", - blockType: BlockType.REPORTER, - text: "get noise id:[ID] at x:[X] y:[Y] z:[Z]", - arguments: { - ID: { - type: ArgumentType.STRING, - defaultValue: "myNoise", - }, - X: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - Y: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - Z: { - type: ArgumentType.NUMBER, - defaultValue: "0", + { + opcode: "getNoise", + blockType: BlockType.REPORTER, + text: "get noise id:[ID] at x:[X] y:[Y] z:[Z] inverted?[INVERTED] easing:[EASING]", + arguments: { + ID: { + type: ArgumentType.STRING, + defaultValue: "myNoise", + }, + X: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + Y: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + Z: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + INVERTED: { + type: ArgumentType.STRING, + menu: "INVERTED_MENU", + defaultValue: "false", + }, + EASING: { + type: ArgumentType.STRING, + menu: "EASING_TYPE", + defaultValue: "Linear", + }, }, }, + ], + menus: { + NOISE_TYPE: { + acceptReporters: false, + items: [ + "OpenSimpex2", + "OpenSimpex2S", + "Cellular", + "Perlin", + "Value Cubic", + "Value", + ], + }, + FRACTAL_TYPE: { + acceptReporters: false, + items: ["None", "FBm", "Ridged", "Ping Pong"], + }, + INVERTED_MENU: { + acceptReporters: true, + items: ["true", "false"], + }, + EASING_TYPE: { + acceptReporters: false, + items: ["Linear", "Squared", "Cubed", "Root"], + }, }, - ], - menus: { - NOISE_TYPE: { - acceptReporters: false, - items: [ - "OpenSimpex2", - "OpenSimpex2S", - "Cellular", - "Perlin", - "Value Cubic", - "Value", - ], - }, - FRACTAL_TYPE: { - acceptReporters: false, - items: ["None", "FBm", "Ridged", "Ping Pong"], - }, - INVERTED_MENU: { - acceptReporters: true, - items: ["true", "false"], - }, - EASING_TYPE: { - acceptReporters: false, - items: ["Linear", "Squared", "Cubed", "Root"], - }, - }, - }; - } - - initNoise(args) { - noises[args.ID] = [new FastNoiseLite(args.SEED), 0, 0]; - switch (args.TYPE) { - case "OpenSimplex2": - noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); - break; - case "OpenSimplex2S": - noises[args.ID][0].SetNoiseType( - FastNoiseLite.NoiseType.OpenSimplex2S - ); - break; - case "Cellular": - noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Cellular); - break; - case "Perlin": - noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Perlin); - break; - case "Value Cubic": - noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.ValueCubic); - break; - case "Value": - noises[args.ID][0].SetNoiseType(FastNoiseLite.NoiseType.Value); - break; - } - switch (args.FRACTAL) { - case "None": - noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.None); - break; - case "FBm": - noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.FBm); - break; - case "Ridged": - noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.Ridged); - break; - case "Ping Pong": - noises[args.ID][0].SetFractalType(FastNoiseLite.FractalType.PingPong); - break; - } - noises[args.ID][2] = args.EASING; - noises[args.ID][0].SetFrequency(args.FREQUENCY); - noises[args.ID][0].SetFractalOctaves(args.OCTAVES); - noises[args.ID][1] = args.INVERTED; - } - - getNoise(args) { - if (args.ID in noises) { - let value = noises[args.ID][0].GetNoise(args.X, args.Y, args.Z); - value = noises[args.ID][1] == "true" ? value : -value; - value = (value + 1) / 2; - switch (noises[args.ID][2]) { - case "Linear": + }; + } + + initNoise(args) { + const id = args.ID; + const seed = args.SEED; + const fractal = args.FRACTAL; + const frequency = args.FREQUENCY; + const octaves = args.OCTAVES; + noises[id] = new FastNoiseLite(seed); + switch (args.TYPE) { + case "OpenSimplex2": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); break; - case "Squared": - value = Math.pow(value, 2); + case "OpenSimplex2S": + noises[id].SetNoiseType( + FastNoiseLite.NoiseType.OpenSimplex2S + ); break; - case "Cubed": - value = Math.pow(value, 3); + case "Cellular": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Cellular); break; - case "Root": - value = Math.sqrt(Math.abs(value)); + case "Perlin": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); break; - } - value = value * 2 - 1; - return value; - } - return 0; - } - } - - class FastNoiseLite { - static NoiseType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2S: "OpenSimplex2S", - Cellular: "Cellular", - Perlin: "Perlin", - ValueCubic: "ValueCubic", - Value: "Value", - }); - static RotationType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", - }); - static FractalType = Object.freeze({ - None: "None", - FBm: "FBm", - Ridged: "Ridged", - PingPong: "PingPong", - DomainWarpProgressive: "DomainWarpProgressive", - DomainWarpIndependent: "DomainWarpIndependent", - }); - static CellularDistanceFunction = Object.freeze({ - Euclidean: "Euclidean", - EuclideanSq: "EuclideanSq", - Manhattan: "Manhattan", - Hybrid: "Hybrid", - }); - static CellularReturnType = Object.freeze({ - CellValue: "CellValue", - Distance: "Distance", - Distance2: "Distance2", - Distance2Add: "Distance2Add", - Distance2Sub: "Distance2Sub", - Distance2Mul: "Distance2Mul", - Distance2Div: "Distance2Div", - }); - static DomainWarpType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2Reduced: "OpenSimplex2Reduced", - BasicGrid: "BasicGrid", - }); - static TransformType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", - DefaultOpenSimplex2: "DefaultOpenSimplex2", - }); - - /* Private */ - _Seed = 1337; - _Frequency = 0.01; - _NoiseType = FastNoiseLite.NoiseType.OpenSimplex2; - _RotationType3D = FastNoiseLite.RotationType3D.None; - _TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - _DomainWarpAmp = 1.0; - - _FractalType = FastNoiseLite.FractalType.None; - _Octaves = 3; - _Lacunarity = 2.0; - _Gain = 0.5; - _WeightedStrength = 0.0; - _PingPongStrength = 2.0; - - _FractalBounding = 1 / 1.75; - - _CellularDistanceFunction = - FastNoiseLite.CellularDistanceFunction.EuclideanSq; - _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; - _CellularJitterModifier = 1.0; - - _DomainWarpType = FastNoiseLite.DomainWarpType.OpenSimplex2; - _WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - - /** - * @description Create new FastNoiseLite object with optional seed - * @param {number} [seed] - * @constructor - */ - constructor(seed) { - if (seed !== undefined) { - this._Seed = seed; - } - } - - /** - * @description Sets seed used for all noise types - * @remarks Default: 1337 - * @default 1337 - * @param {number} seed - */ - SetSeed(seed) { - this._Seed = seed; - } - - /** - * @description Sets frequency for all noise types - * @remarks Default: 0.01 - * @default 0.01 - * @param {number} frequency - */ - SetFrequency(frequency) { - this._Frequency = frequency; - } - - /** - * @description Sets noise algorithm used for GetNoise(...) - * @remarks Default: OpenSimplex2 - * @default FastNoiseLite.NoiseType.OpenSimplex2 - * @param {FastNoiseLite.NoiseType} noiseType - */ - SetNoiseType(noiseType) { - this._NoiseType = noiseType; - this._UpdateTransformType3D(); - } - - /** - * @description Sets domain rotation type for 3D Noise and 3D DomainWarp. - * @description Can aid in reducing directional artifacts when sampling a 2D plane in 3D - * @remarks Default: None - * @default FastNoiseLite.RotationType3D.None - * @param {FastNoiseLite.RotationType3D} rotationType3D - */ - SetRotationType3D(rotationType3D) { - this._RotationType3D = rotationType3D; - this._UpdateTransformType3D(); - this._UpdateWarpTransformType3D(); - } - - /** - * @description Sets method for combining octaves in all fractal noise types - * @remarks Default: None - * @default FastNoiseLite.FractalType.None - * @param {FastNoiseLite.FractalType} fractalType - */ - SetFractalType(fractalType) { - this._FractalType = fractalType; - } - - /** - * @description Sets octave count for all fractal noise types - * @remarks Default: 3 - * @default 3 - * @param {number} octaves - */ - SetFractalOctaves(octaves) { - this._Octaves = octaves; - this._CalculateFractalBounding(); - } - - /** - * @description Sets octave lacunarity for all fractal noise types - * @remarks Default: 2.0 - * @default 2.0 - * @param {number} lacunarity - */ - SetFractalLacunarity(lacunarity) { - this._Lacunarity = lacunarity; - } - - /** - * @description Sets octave gain for all fractal noise types - * @remarks Default: 0.5 - * @default 0.5 - * @param {number} gain - */ - SetFractalGain(gain) { - this._Gain = gain; - this._CalculateFractalBounding(); - } - - /** - * @description Sets octave weighting for all none DomainWarp fratal types - * @remarks Default: 0.0 | Keep between 0...1 to maintain -1...1 output bounding - * @default 0.5 - * @param {number} weightedStrength - */ - SetFractalWeightedStrength(weightedStrength) { - this._WeightedStrength = weightedStrength; - } - - /** - * @description Sets strength of the fractal ping pong effect - * @remarks Default: 2.0 - * @default 2.0 - * @param {number} pingPongStrength - */ - SetFractalPingPongStrength(pingPongStrength) { - this._PingPongStrength = pingPongStrength; - } - - /** - * @description Sets distance function used in cellular noise calculations - * @remarks Default: EuclideanSq - * @default FastNoiseLite.CellularDistanceFunction.EuclideanSq - * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction - */ - SetCellularDistanceFunction(cellularDistanceFunction) { - this._CellularDistanceFunction = cellularDistanceFunction; - } - - /** - * @description Sets return type from cellular noise calculations - * @remarks Default: Distance - * @default FastNoiseLite.CellularReturnType.Distance - * @param {FastNoiseLite.CellularReturnType} cellularReturnType - */ - SetCellularReturnType(cellularReturnType) { - this._CellularReturnType = cellularReturnType; - } - - /** - * @description Sets the maximum distance a cellular point can move from it's grid position - * @remarks Default: 1.0 - * @default 1.0 - * @param {number} cellularJitter - */ - SetCellularJitter(cellularJitter) { - this._CellularJitterModifier = cellularJitter; - } - - /** - * @description Sets the warp algorithm when using DomainWarp(...) - * @remarks Default: OpenSimplex2 - * @default FastNoiseLite.DomainWarpType.OpenSimplex2 - * @param {FastNoiseLite.DomainWarpType} domainWarpType - */ - SetDomainWarpType(domainWarpType) { - this._DomainWarpType = domainWarpType; - this._UpdateWarpTransformType3D(); - } - - /** - * @description Sets the maximum warp distance from original position when using DomainWarp(...) - * @remarks Default: 1.0 - * @default 1.0 - * @param {number} domainWarpAmp - */ - SetDomainWarpAmp(domainWarpAmp) { - this._DomainWarpAmp = domainWarpAmp; - } - - /** - * @description 2D/3D noise at given position using current settings - * @param {number} x X coordinate - * @param {number} y Y coordinate - * @param {number} [z] Z coordinate - * @return {number} Noise output bounded between -1...1 - */ - GetNoise(x, y, z) { - /** - * @description 2D noise at given position using current settings - * @param {number} x - * @param {number} y - * @return {number} Noise output bounded between -1...1 - */ - let R2 = (x, y) => { - x *= this._Frequency; - y *= this._Frequency; - - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (x + y) * F2; - x += t; - y += t; + case "Value Cubic": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.ValueCubic); break; - } - default: + case "Value": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Value); break; } - - switch (this._FractalType) { - default: - return this._GenNoiseSingleR2(this._Seed, x, y); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR2(x, y); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR2(x, y); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR2(x, y); - } - }; - - /** - * @description 3D noise at given position using current settings - * @param {number} x - * @param {number} y - * @param {number} z - * @return {number} Noise output bounded between -1...1 - */ - let R3 = (x, y, z) => { - x *= this._Frequency; - y *= this._Frequency; - z *= this._Frequency; - - switch (this._TransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: { - let xy = x + y; - let s2 = xy * -0.211324865405187; - z *= 0.577350269189626; - x += s2 - z; - y += s2 - z; - z += xy * 0.577350269189626; + switch (fractal) { + case "None": + noises[id].SetFractalType(FastNoiseLite.FractalType.None); break; - } - case FastNoiseLite.TransformType3D.ImproveXZPlanes: { - let xz = x + z; - let s2 = xz * -0.211324865405187; - y *= 0.577350269189626; - x += s2 - y; - z += s2 - y; - y += xz * 0.577350269189626; + case "FBm": + noises[id].SetFractalType(FastNoiseLite.FractalType.FBm); break; - } - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { - const R3 = 2.0 / 3.0; - let r = (x + y + z) * R3; - x = r - x; - y = r - y; - z = r - z; + case "Ridged": + noises[id].SetFractalType(FastNoiseLite.FractalType.Ridged); break; - } - default: + case "Ping Pong": + noises[id].SetFractalType(FastNoiseLite.FractalType.PingPong); break; } - - switch (this._FractalType) { - default: - return this._GenNoiseSingleR3(this._Seed, x, y, z); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR3(x, y, z); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR3(x, y, z); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR3(x, y, z); - } - }; - - if (arguments.length === 2) { - return R2(x, y); + noises[id].SetFrequency(frequency); + noises[id].SetFractalOctaves(octaves); } - - if (arguments.length === 3) { - return R3(x, y, z); + + getNoise(args) { + const id = args.ID; + const easing = args.EASING; + const inverted = args.INVERTED; + if (id in noises) { + let value = noises[id].GetNoise(args.X, args.Y, args.Z); + value = inverted == "true" ? value : -value; + value = (value + 1) / 2; + switch (easing) { + case "Linear": + break; + case "Squared": + value = Math.pow(value, 2); + break; + case "Cubed": + value = Math.pow(value, 3); + break; + case "Root": + value = Math.sqrt(Math.abs(value)); + break; + } + value = value * 2 - 1; + return value; + } + return 0; } } - - /** - * @description 2D/3D warps the input position using current domain warp settings - * @param {Vector2|Vector3} coord - */ - DomainWrap(coord) { - switch (this._FractalType) { - default: - this._DomainWarpSingle(coord); - break; - case FastNoiseLite.FractalType.DomainWarpProgressive: - this._DomainWarpFractalProgressive(coord); - break; - case FastNoiseLite.FractalType.DomainWarpIndependent: - this._DomainWarpFractalIndependent(coord); - break; + + class FastNoiseLite { + static NoiseType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2S: "OpenSimplex2S", + Cellular: "Cellular", + Perlin: "Perlin", + ValueCubic: "ValueCubic", + Value: "Value", + }); + static RotationType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + }); + static FractalType = Object.freeze({ + None: "None", + FBm: "FBm", + Ridged: "Ridged", + PingPong: "PingPong", + DomainWarpProgressive: "DomainWarpProgressive", + DomainWarpIndependent: "DomainWarpIndependent", + }); + static CellularDistanceFunction = Object.freeze({ + Euclidean: "Euclidean", + EuclideanSq: "EuclideanSq", + Manhattan: "Manhattan", + Hybrid: "Hybrid", + }); + static CellularReturnType = Object.freeze({ + CellValue: "CellValue", + Distance: "Distance", + Distance2: "Distance2", + Distance2Add: "Distance2Add", + Distance2Sub: "Distance2Sub", + Distance2Mul: "Distance2Mul", + Distance2Div: "Distance2Div", + }); + static DomainWarpType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2Reduced: "OpenSimplex2Reduced", + BasicGrid: "BasicGrid", + }); + static TransformType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + DefaultOpenSimplex2: "DefaultOpenSimplex2", + }); + + /* Private */ + _Seed = 1337; + _Frequency = 0.01; + _NoiseType = FastNoiseLite.NoiseType.OpenSimplex2; + _RotationType3D = FastNoiseLite.RotationType3D.None; + _TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + _DomainWarpAmp = 1.0; + + _FractalType = FastNoiseLite.FractalType.None; + _Octaves = 3; + _Lacunarity = 2.0; + _Gain = 0.5; + _WeightedStrength = 0.0; + _PingPongStrength = 2.0; + + _FractalBounding = 1 / 1.75; + + _CellularDistanceFunction = + FastNoiseLite.CellularDistanceFunction.EuclideanSq; + _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; + _CellularJitterModifier = 1.0; + + _DomainWarpType = FastNoiseLite.DomainWarpType.OpenSimplex2; + _WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + + /** + * @description Create new FastNoiseLite object with optional seed + * @param {number} [seed] + * @constructor + */ + constructor(seed) { + if (seed !== undefined) { + this._Seed = seed; + } } - } - - // prettier-ignore - _Gradients2D = [ - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, - -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, - ]; - - // prettier-ignore - _RandVecs2D = [ - -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, - -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, - -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, - -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, - -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, - 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, - 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, - -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, - 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, - 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, - -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, - 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, - -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, - -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, - 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, - -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, - 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, - 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, - 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, - -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, - 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, - 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, - 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, - -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, - 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, - -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, - 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, - -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, - 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, - -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, - 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, - 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, - ]; - - // prettier-ignore - _Gradients3D = [ - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 - ]; - - // prettier-ignore - _RandVecs3D = [ - -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, - 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, - -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, - -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, - 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, - -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, - 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, - 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, - -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, - 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, - -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, - -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, - 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, - 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, - -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, - 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, - 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, - -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, - -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, - -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, - -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, - 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, - 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, - 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, - -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, - -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, - -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, - 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, - 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, - 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, - 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, - -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 - ]; - - _PrimeX = 501125321; - _PrimeY = 1136930381; - _PrimeZ = 1720413743; - - /** - * @private - * @param {number} a - * @param {number} b - * @param {number} t - * @returns {number} - */ - static _Lerp(a, b, t) { - return a + t * (b - a); - } - - /** - * @private - * @param {number} t - * @returns {number} - */ - static _InterpHermite(t) { - return t * t * (3 - 2 * t); - } - - /** - * @private - * @param t - * @returns {number} - */ - static _InterpQuintic(t) { - return t * t * t * (t * (t * 6 - 15) + 10); - } - - /** - * @private - * @param {number} a - * @param {number} b - * @param {number} c - * @param {number} d - * @param {number} t - * @returns {number} - */ - static _CubicLerp(a, b, c, d, t) { - const p = d - c - (a - b); - return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; - } - - /** - * @private - * @param {number} t - * @returns {number} - */ - static _PingPong(t) { - t -= Math.trunc(t * 0.5) * 2; - return t < 1 ? t : 2 - t; - } - - /** - * @private - */ - _CalculateFractalBounding() { - let gain = Math.abs(this._Gain); - let amp = gain; - let ampFractal = 1.0; - for (let i = 1; i < this._Octaves; i++) { - ampFractal += amp; - amp *= gain; - } - this._FractalBounding = 1 / ampFractal; - } - - /** - * @private - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @returns {number} - */ - _HashR2(seed, xPrimed, yPrimed) { - let hash = seed ^ xPrimed ^ yPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @returns {number} - */ - _HashR3(seed, xPrimed, yPrimed, zPrimed) { - let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; - } - - /** - * @private - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @returns {number} - */ - _ValCoordR2(seed, xPrimed, yPrimed) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @returns {number} - */ - _ValCoordR3(seed, xPrimed, yPrimed, zPrimed) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} xd - * @param {number} yd - * @returns {number} - */ - _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - hash ^= hash >> 15; - hash &= 127 << 1; - - let xg = this._Gradients2D[hash]; - let yg = this._Gradients2D[hash | 1]; - - return xd * xg + yd * yg; - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @param {number} xd - * @param {number} yd - * @param {number} zd - * @returns {number} - */ - _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - hash ^= hash >> 15; - hash &= 63 << 2; - - let xg = this._Gradients3D[hash]; - let yg = this._Gradients3D[hash | 1]; - let zg = this._Gradients3D[hash | 2]; - - return xd * xg + yd * yg + zd * zg; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenNoiseSingleR2(seed, x, y) { - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R2(seed, x, y); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR2(seed, x, y); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR2(seed, x, y); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR2(seed, x, y); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR2(seed, x, y); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR2(seed, x, y); - default: - return 0; + + /** + * @description Sets seed used for all noise types + * @remarks Default: 1337 + * @default 1337 + * @param {number} seed + */ + SetSeed(seed) { + this._Seed = seed; } - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenNoiseSingleR3(seed, x, y, z) { - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R3(seed, x, y, z); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR3(seed, x, y, z); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR3(seed, x, y, z); - default: - return 0; + + /** + * @description Sets frequency for all noise types + * @remarks Default: 0.01 + * @default 0.01 + * @param {number} frequency + */ + SetFrequency(frequency) { + this._Frequency = frequency; } - } - - /** - * @private - */ - _UpdateTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; - default: + + /** + * @description Sets noise algorithm used for GetNoise(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.NoiseType.OpenSimplex2 + * @param {FastNoiseLite.NoiseType} noiseType + */ + SetNoiseType(noiseType) { + this._NoiseType = noiseType; + this._UpdateTransformType3D(); + } + + /** + * @description Sets domain rotation type for 3D Noise and 3D DomainWarp. + * @description Can aid in reducing directional artifacts when sampling a 2D plane in 3D + * @remarks Default: None + * @default FastNoiseLite.RotationType3D.None + * @param {FastNoiseLite.RotationType3D} rotationType3D + */ + SetRotationType3D(rotationType3D) { + this._RotationType3D = rotationType3D; + this._UpdateTransformType3D(); + this._UpdateWarpTransformType3D(); + } + + /** + * @description Sets method for combining octaves in all fractal noise types + * @remarks Default: None + * @default FastNoiseLite.FractalType.None + * @param {FastNoiseLite.FractalType} fractalType + */ + SetFractalType(fractalType) { + this._FractalType = fractalType; + } + + /** + * @description Sets octave count for all fractal noise types + * @remarks Default: 3 + * @default 3 + * @param {number} octaves + */ + SetFractalOctaves(octaves) { + this._Octaves = octaves; + this._CalculateFractalBounding(); + } + + /** + * @description Sets octave lacunarity for all fractal noise types + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} lacunarity + */ + SetFractalLacunarity(lacunarity) { + this._Lacunarity = lacunarity; + } + + /** + * @description Sets octave gain for all fractal noise types + * @remarks Default: 0.5 + * @default 0.5 + * @param {number} gain + */ + SetFractalGain(gain) { + this._Gain = gain; + this._CalculateFractalBounding(); + } + + /** + * @description Sets octave weighting for all none DomainWarp fratal types + * @remarks Default: 0.0 | Keep between 0...1 to maintain -1...1 output bounding + * @default 0.5 + * @param {number} weightedStrength + */ + SetFractalWeightedStrength(weightedStrength) { + this._WeightedStrength = weightedStrength; + } + + /** + * @description Sets strength of the fractal ping pong effect + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} pingPongStrength + */ + SetFractalPingPongStrength(pingPongStrength) { + this._PingPongStrength = pingPongStrength; + } + + /** + * @description Sets distance function used in cellular noise calculations + * @remarks Default: EuclideanSq + * @default FastNoiseLite.CellularDistanceFunction.EuclideanSq + * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction + */ + SetCellularDistanceFunction(cellularDistanceFunction) { + this._CellularDistanceFunction = cellularDistanceFunction; + } + + /** + * @description Sets return type from cellular noise calculations + * @remarks Default: Distance + * @default FastNoiseLite.CellularReturnType.Distance + * @param {FastNoiseLite.CellularReturnType} cellularReturnType + */ + SetCellularReturnType(cellularReturnType) { + this._CellularReturnType = cellularReturnType; + } + + /** + * @description Sets the maximum distance a cellular point can move from it's grid position + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} cellularJitter + */ + SetCellularJitter(cellularJitter) { + this._CellularJitterModifier = cellularJitter; + } + + /** + * @description Sets the warp algorithm when using DomainWarp(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.DomainWarpType.OpenSimplex2 + * @param {FastNoiseLite.DomainWarpType} domainWarpType + */ + SetDomainWarpType(domainWarpType) { + this._DomainWarpType = domainWarpType; + this._UpdateWarpTransformType3D(); + } + + /** + * @description Sets the maximum warp distance from original position when using DomainWarp(...) + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} domainWarpAmp + */ + SetDomainWarpAmp(domainWarpAmp) { + this._DomainWarpAmp = domainWarpAmp; + } + + /** + * @description 2D/3D noise at given position using current settings + * @param {number} x X coordinate + * @param {number} y Y coordinate + * @param {number} [z] Z coordinate + * @return {number} Noise output bounded between -1...1 + */ + GetNoise(x, y, z) { + /** + * @description 2D noise at given position using current settings + * @param {number} x + * @param {number} y + * @return {number} Noise output bounded between -1...1 + */ + let R2 = (x, y) => { + x *= this._Frequency; + y *= this._Frequency; + switch (this._NoiseType) { case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: - this._TransformType3D = - FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + case FastNoiseLite.NoiseType.OpenSimplex2S: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (x + y) * F2; + x += t; + y += t; break; + } default: - this._TransformType3D = FastNoiseLite.TransformType3D.None; break; } - break; - } - } - - /** - * @private - */ - _UpdateWarpTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; - default: - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR2(this._Seed, x, y); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR2(x, y); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR2(x, y); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR2(x, y); + } + }; + + /** + * @description 3D noise at given position using current settings + * @param {number} x + * @param {number} y + * @param {number} z + * @return {number} Noise output bounded between -1...1 + */ + let R3 = (x, y, z) => { + x *= this._Frequency; + y *= this._Frequency; + z *= this._Frequency; + + switch (this._TransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: { + let xy = x + y; + let s2 = xy * -0.211324865405187; + z *= 0.577350269189626; + x += s2 - z; + y += s2 - z; + z += xy * 0.577350269189626; + break; + } + case FastNoiseLite.TransformType3D.ImproveXZPlanes: { + let xz = x + z; + let s2 = xz * -0.211324865405187; + y *= 0.577350269189626; + x += s2 - y; + z += s2 - y; + y += xz * 0.577350269189626; + break; + } + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + const R3 = 2.0 / 3.0; + let r = (x + y + z) * R3; + x = r - x; + y = r - y; + z = r - z; break; + } default: - this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; break; } - break; + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR3(this._Seed, x, y, z); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR3(x, y, z); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR3(x, y, z); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR3(x, y, z); + } + }; + + if (arguments.length === 2) { + return R2(x, y); + } + + if (arguments.length === 3) { + return R3(x, y, z); + } } - } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalFBmR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR2(seed++, x, y); - sum += noise * amp; - amp *= FastNoiseLite._Lerp( - 1.0, - Math.min(noise + 1, 2) * 0.5, - this._WeightedStrength - ); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; + + /** + * @description 2D/3D warps the input position using current domain warp settings + * @param {Vector2|Vector3} coord + */ + DomainWrap(coord) { + switch (this._FractalType) { + default: + this._DomainWarpSingle(coord); + break; + case FastNoiseLite.FractalType.DomainWarpProgressive: + this._DomainWarpFractalProgressive(coord); + break; + case FastNoiseLite.FractalType.DomainWarpIndependent: + this._DomainWarpFractalIndependent(coord); + break; + } } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalFBmR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR3(seed++, x, y, z); - sum += noise * amp; - amp *= FastNoiseLite._Lerp( - 1.0, - (noise + 1) * 0.5, - this._WeightedStrength - ); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; + + // prettier-ignore + _Gradients2D = [ + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, + -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, + ]; + + // prettier-ignore + _RandVecs2D = [ + -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, + -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, + -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, + -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, + -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, + 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, + 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, + -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, + 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, + 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, + -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, + 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, + -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, + -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, + 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, + -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, + 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, + 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, + 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, + -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, + 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, + 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, + 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, + -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, + 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, + -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, + 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, + -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, + 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, + -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, + 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, + 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, + ]; + + // prettier-ignore + _Gradients3D = [ + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 + ]; + + // prettier-ignore + _RandVecs3D = [ + -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, + 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, + -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, + -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, + 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, + -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, + 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, + 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, + -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, + 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, + -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, + -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, + 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, + 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, + -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, + 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, + 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, + -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, + -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, + -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, + -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, + 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, + 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, + 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, + -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, + -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, + -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, + 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, + 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, + 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, + 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, + -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 + ]; + + _PrimeX = 501125321; + _PrimeY = 1136930381; + _PrimeZ = 1720413743; + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} t + * @returns {number} + */ + static _Lerp(a, b, t) { + return a + t * (b - a); } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalRidgedR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _InterpHermite(t) { + return t * t * (3 - 2 * t); } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalRidgedR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; + + /** + * @private + * @param t + * @returns {number} + */ + static _InterpQuintic(t) { + return t * t * t * (t * (t * 6 - 15) + 10); } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalPingPongR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} c + * @param {number} d + * @param {number} t + * @returns {number} + */ + static _CubicLerp(a, b, c, d, t) { + const p = d - c - (a - b); + return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalPingPongR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _PingPong(t) { + t -= Math.trunc(t * 0.5) * 2; + return t < 1 ? t : 2 - t; } - return sum; - } - - /** - * - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleOpenSimplex2R2(seed, x, y) { - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let n0, n1, n2; - - let a = 0.5 - x0 * x0 - y0 * y0; - - if (a <= 0) { - n0 = 0; - } else { - n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); + + /** + * @private + */ + _CalculateFractalBounding() { + let gain = Math.abs(this._Gain); + let amp = gain; + let ampFractal = 1.0; + for (let i = 1; i < this._Octaves; i++) { + ampFractal += amp; + amp *= gain; + } + this._FractalBounding = 1 / ampFractal; } - - let c = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - - if (c <= 0) { - n2 = 0; - } else { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - n2 = - c * - c * - (c * c) * - this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); + + /** + * @private + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @returns {number} + */ + _HashR2(seed, xPrimed, yPrimed) { + let hash = seed ^ xPrimed ^ yPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; } - - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = - b * - b * - (b * b) * - this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _HashR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; + } + + /** + * @private + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @returns {number} + */ + _ValCoordR2(seed, xPrimed, yPrimed) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _ValCoordR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} xd + * @param {number} yd + * @returns {number} + */ + _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + hash ^= hash >> 15; + hash &= 127 << 1; + + let xg = this._Gradients2D[hash]; + let yg = this._Gradients2D[hash | 1]; + + return xd * xg + yd * yg; + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @param {number} xd + * @param {number} yd + * @param {number} zd + * @returns {number} + */ + _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + hash ^= hash >> 15; + hash &= 63 << 2; + + let xg = this._Gradients3D[hash]; + let yg = this._Gradients3D[hash | 1]; + let zg = this._Gradients3D[hash | 2]; + + return xd * xg + yd * yg + zd * zg; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenNoiseSingleR2(seed, x, y) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R2(seed, x, y); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR2(seed, x, y); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR2(seed, x, y); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR2(seed, x, y); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR2(seed, x, y); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR2(seed, x, y); + default: + return 0; } - } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = - b * - b * - (b * b) * - this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenNoiseSingleR3(seed, x, y, z) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R3(seed, x, y, z); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR3(seed, x, y, z); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR3(seed, x, y, z); + default: + return 0; } } - return (n0 + n1 + n2) * 99.83685446303647; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleOpenSimplex2R3(seed, x, y, z) { - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let yNSign = Math.trunc((-1.0 - y0) | 1); - let xNSign = Math.trunc((-1.0 - x0) | 1); - let zNSign = Math.trunc((-1.0 - z0) | 1); - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let value = 0; - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - - for (let l = 0; ; l++) { - if (a > 0) { - value += - a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); + + /** + * @private + */ + _UpdateTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: + this._TransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; + default: + this._TransformType3D = FastNoiseLite.TransformType3D.None; + break; + } + break; } - - if (ax0 >= ay0 && ax0 >= az0) { - let b = a + ax0 + ax0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i - xNSign * this._PrimeX, - j, - k, - x0 + xNSign, - y0, - z0 - ); - } - } else if (ay0 > ax0 && ay0 >= az0) { - let b = a + ay0 + ay0; - if (b > 1) { - b -= 1; - value += + } + + /** + * @private + */ + _UpdateWarpTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; + default: + this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; + break; + } + break; + } + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalFBmR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR2(seed++, x, y); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + Math.min(noise + 1, 2) * 0.5, + this._WeightedStrength + ); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalFBmR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR3(seed++, x, y, z); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + (noise + 1) * 0.5, + this._WeightedStrength + ); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalRidgedR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalRidgedR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalPingPongR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalPingPongR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleOpenSimplex2R2(seed, x, y) { + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let n0, n1, n2; + + let a = 0.5 - x0 * x0 - y0 * y0; + + if (a <= 0) { + n0 = 0; + } else { + n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); + } + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + + if (c <= 0) { + n2 = 0; + } else { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + n2 = + c * + c * + (c * c) * + this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); + } + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = b * b * (b * b) * - this._GradCoordR3( - seed, - i, - j - yNSign * this._PrimeY, - k, - x0, - y0 + yNSign, - z0 - ); + this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); } } else { - let b = a + az0 + az0; - if (b > 1) { - b -= 1; - value += + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = b * b * (b * b) * - this._GradCoordR3( - seed, - i, - j, - k - zNSign * this._PrimeZ, - x0, - y0, - z0 + zNSign - ); + this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); } } - - if (l === 1) { - break; - } - - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; - - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; - - a += 0.75 - ax0 - (ay0 + az0); - - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; - - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; - - seed = ~seed; + return (n0 + n1 + n2) * 99.83685446303647; } - return value * 32.69428253173828125; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleOpenSimplex2SR2(seed, x, y) { - // 2D OpenSimplex2S case is a modified 2D simplex noise. - - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - /* - * --- Skew moved to TransformNoiseCoordinate method --- - * final FNLfloat F2 = 0.5f * (SQRT3 - 1); - * FNLfloat s = (x + y) * F2; - * x += s; y += s; - */ - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - let i1 = i + this._PrimeX; - let j1 = j + this._PrimeY; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; - let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); - let a1 = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); - let x1 = x0 - (1 - 2 * G2); - let y1 = y0 - (1 - 2 * G2); - value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); - - // Nested conditionals were faster than compact bit logic/arithmetic. - let xmyi = xi - yi; - if (t > G2) { - if (xi + xmyi > 1) { - let x2 = x0 + (3 * G2 - 2); - let y2 = y0 + (3 * G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2( - seed, - i + (this._PrimeX << 1), - j + this._PrimeY, - x2, - y2 - ); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } - } - - if (yi - xmyi > 1) { - let x3 = x0 + (3 * G2 - 1); - let y3 = y0 + (3 * G2 - 2); - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR2( - seed, - i + this._PrimeX, - j + (this._PrimeY << 1), - x3, - y3 - ); - } - } else { - let x3 = x0 + (G2 - 1); - let y3 = y0 + G2; - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); - } - } - } else { - if (xi + xmyi < 0) { - let x2 = x0 + (1 - G2); - let y2 = y0 - G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); - } - } else { - let x2 = x0 + (G2 - 1); - let y2 = y0 + G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); - } - } - - if (yi < xmyi) { - let x2 = x0 - G2; - let y2 = y0 - (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } - } - } - - return value * 18.24196194486065; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleOpenSimplex2SR3(seed, x, y, z) { - // 3D OpenSimplex2S case uses two offset rotated cube grids. - - /* - * --- Rotation moved to TransformNoiseCoordinate method --- - * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); - * FNLfloat r = (x + y + z) * R3; // Rotation, not skew - * x = r - x; y = r - y; z = r - z; - */ - - let i = Math.floor(x); - let j = Math.floor(y); - let k = Math.floor(z); - let xi = x - i; - let yi = y - j; - let zi = z - k; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - let seed2 = seed + 1293373; - - let xNMask = Math.trunc(-0.5 - xi); - let yNMask = Math.trunc(-0.5 - yi); - let zNMask = Math.trunc(-0.5 - zi); - - let x0 = xi + xNMask; - let y0 = yi + yNMask; - let z0 = zi + zNMask; - let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; - let value = - a0 * - a0 * - (a0 * a0) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x0, - y0, - z0 - ); - - let x1 = xi - 0.5; - let y1 = yi - 0.5; - let z1 = zi - 0.5; - let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; - value += - a1 * - a1 * - (a1 * a1) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + this._PrimeY, - k + this._PrimeZ, - x1, - y1, - z1 - ); - - let xAFlipMask0 = ((xNMask | 1) << 1) * x1; - let yAFlipMask0 = ((yNMask | 1) << 1) * y1; - let zAFlipMask0 = ((zNMask | 1) << 1) * z1; - let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; - let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; - let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; - - let skip5 = false; - let a2 = xAFlipMask0 + a0; - if (a2 > 0) { - let x2 = x0 - (xNMask | 1); - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x2, - y0, - z0 - ); - } else { - let a3 = yAFlipMask0 + zAFlipMask0 + a0; - - if (a3 > 0) { - let x3 = x0; - let y3 = y0 - (yNMask | 1); - let z3 = z0 - (zNMask | 1); - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x3, - y3, - z3 - ); - } - - let a4 = xAFlipMask1 + a1; - if (a4 > 0) { - let x4 = (xNMask | 1) + x1; - value += - a4 * - a4 * - (a4 * a4) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + this._PrimeZ, - x4, - y1, - z1 - ); - skip5 = true; - } - } - - let skip9 = false; - let a6 = yAFlipMask0 + a0; - if (a6 > 0) { - let x6 = x0; - let y6 = y0 - (yNMask | 1); - value += - a6 * - a6 * - (a6 * a6) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x6, - y6, - z0 - ); - } else { - let a7 = xAFlipMask0 + zAFlipMask0 + a0; - if (a7 > 0) { - let x7 = x0 - (xNMask | 1); - let y7 = y0; - let z7 = z0 - (zNMask | 1); - value += - a7 * - a7 * - (a7 * a7) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x7, - y7, - z7 - ); - } - - let a8 = yAFlipMask1 + a1; - if (a8 > 0) { - let x8 = x1; - let y8 = (yNMask | 1) + y1; - value += - a8 * - a8 * - (a8 * a8) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - x8, - y8, - z1 - ); - skip9 = true; - } - } - - let skipD = false; - let aA = zAFlipMask0 + a0; - if (aA > 0) { - let xA = x0; - let yA = y0; - let zA = z0 - (zNMask | 1); - value += - aA * - aA * - (aA * aA) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - xA, - yA, - zA - ); - } else { - let aB = xAFlipMask0 + yAFlipMask0 + a0; - if (aB > 0) { - let xB = x0 - (xNMask | 1); - let yB = y0 - (yNMask | 1); - value += - aB * - aB * - (aB * aB) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - xB, - yB, - z0 - ); - } - - let aC = zAFlipMask1 + a1; - if (aC > 0) { - let xC = x1; - let yC = y1; - let zC = (zNMask | 1) + z1; - value += - aC * - aC * - (aC * aC) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - xC, - yC, - zC - ); - skipD = true; - } - } - - if (!skip5) { - let a5 = yAFlipMask1 + zAFlipMask1 + a1; - if (a5 > 0) { - let x5 = x1; - let y5 = (yNMask | 1) + y1; - let z5 = (zNMask | 1) + z1; - value += - a5 * - a5 * - (a5 * a5) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + (zNMask & (this._PrimeZ << 1)), - x5, - y5, - z5 - ); - } - } - - if (!skip9) { - let a9 = xAFlipMask1 + zAFlipMask1 + a1; - if (a9 > 0) { - let x9 = (xNMask | 1) + x1; - let y9 = y1; - let z9 = (zNMask | 1) + z1; - value += - a9 * - a9 * - (a9 * a9) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - x9, - y9, - z9 - ); - } - } - - if (!skipD) { - let aD = xAFlipMask1 + yAFlipMask1 + a1; - if (aD > 0) { - let xD = (xNMask | 1) + x1; - let yD = (yNMask | 1) + y1; - value += - aD * - aD * - (aD * aD) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX << 1)), - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - xD, - yD, - z1 - ); - } - } - - return value * 9.046026385208288; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleCellularR2(seed, x, y) { + /** - * + * @private * @param {number} seed * @param {number} x * @param {number} y + * @param {number} z * @returns {number} */ - let xr = Math.round(x); - let yr = Math.round(y); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - - let closestHash = 0; - - let cellularJitter = 0.43701595 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - - switch (this._CellularDistanceFunction) { - default: - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY; - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = Math.abs(vecX) + Math.abs(vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = - Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; + _SingleOpenSimplex2R3(seed, x, y, z) { + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let yNSign = Math.trunc((-1.0 - y0) | 1); + let xNSign = Math.trunc((-1.0 - x0) | 1); + let zNSign = Math.trunc((-1.0 - z0) | 1); + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let value = 0; + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + + for (let l = 0; ; l++) { + if (a > 0) { + value += + a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); } - break; - } - - if ( - this._CellularDistanceFunction === - FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue - ) { - distance0 = Math.sqrt(distance0); - - if ( - this._CellularReturnType !== - FastNoiseLite.CellularReturnType.CellValue - ) { - distance1 = Math.sqrt(distance1); - } - } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; - } - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleCellularR3(seed, x, y, z) { - let xr = Math.round(x); - let yr = Math.round(y); - let zr = Math.round(z); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - let closestHash = 0; - - let cellularJitter = 0.39614353 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - let zPrimedBase = (zr - 1) * this._PrimeZ; - - switch (this._CellularDistanceFunction) { - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 + + if (ax0 >= ay0 && ax0 >= az0) { + let b = a + ax0 + ax0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i - xNSign * this._PrimeX, + j, + k, + x0 + xNSign, + y0, + z0 ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = - Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 + } else if (ay0 > ax0 && ay0 >= az0) { + let b = a + ay0 + ay0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j - yNSign * this._PrimeY, + k, + x0, + y0 + yNSign, + z0 ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = - Math.abs(vecX) + - Math.abs(vecY) + - Math.abs(vecZ) + - (vecX * vecX + vecY * vecY + vecZ * vecZ); - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 + } else { + let b = a + az0 + az0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j, + k - zNSign * this._PrimeZ, + x0, + y0, + z0 + zNSign ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; } - xPrimed += this._PrimeX; } - break; - default: - break; - } - - if ( - this._CellularDistanceFunction === - FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue - ) { - distance0 = Math.sqrt(distance0); - - if ( - this._CellularReturnType !== - FastNoiseLite.CellularReturnType.CellValue - ) { - distance1 = Math.sqrt(distance1); + + if (l === 1) { + break; + } + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed = ~seed; } + return value * 32.69428253173828125; } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; - } - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SinglePerlinR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xd0 = x - x0; - let yd0 = y - y0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y0, xd0, yd0), - this._GradCoordR2(seed, x1, y0, xd1, yd0), - xs - ); - let xf1 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y1, xd0, yd1), - this._GradCoordR2(seed, x1, y1, xd1, yd1), - xs - ); - - return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SinglePerlinR3(seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xd0 = x - x0; - let yd0 = y - y0; - let zd0 = z - z0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - let zd1 = zd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - let zs = FastNoiseLite._InterpQuintic(zd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), - this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), - this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), - this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), - xs - ); - let xf11 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), - this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), - xs - ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleValueCubicR2(seed, x, y) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - - let xs = x - x1; - let ys = y - y1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - - return ( - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y0), - this._ValCoordR2(seed, x1, y0), - this._ValCoordR2(seed, x2, y0), - this._ValCoordR2(seed, x3, y0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y1), - this._ValCoordR2(seed, x1, y1), - this._ValCoordR2(seed, x2, y1), - this._ValCoordR2(seed, x3, y1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y2), - this._ValCoordR2(seed, x1, y2), - this._ValCoordR2(seed, x2, y2), - this._ValCoordR2(seed, x3, y2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y3), - this._ValCoordR2(seed, x1, y3), - this._ValCoordR2(seed, x2, y3), - this._ValCoordR2(seed, x3, y3), - xs - ), - ys - ) * - (1 / (1.5 * 1.5)) - ); - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleValueCubicR3(seed, x, y, z) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - let z1 = Math.floor(z); - - let xs = x - x1; - let ys = y - y1; - let zs = z - z1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - z1 = Math.imul(z1, this._PrimeZ); - - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let z0 = z1 - this._PrimeZ; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let z2 = z1 + this._PrimeZ; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - let z3 = z1 + (this._PrimeZ << 1); - - return ( - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - this._ValCoordR3(seed, x2, y0, z0), - this._ValCoordR3(seed, x3, y0, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - this._ValCoordR3(seed, x2, y1, z0), - this._ValCoordR3(seed, x3, y1, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z0), - this._ValCoordR3(seed, x1, y2, z0), - this._ValCoordR3(seed, x2, y2, z0), - this._ValCoordR3(seed, x3, y2, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z0), - this._ValCoordR3(seed, x1, y3, z0), - this._ValCoordR3(seed, x2, y3, z0), - this._ValCoordR3(seed, x3, y3, z0), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - this._ValCoordR3(seed, x2, y0, z1), - this._ValCoordR3(seed, x3, y0, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - this._ValCoordR3(seed, x2, y1, z1), - this._ValCoordR3(seed, x3, y1, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z1), - this._ValCoordR3(seed, x1, y2, z1), - this._ValCoordR3(seed, x2, y2, z1), - this._ValCoordR3(seed, x3, y2, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z1), - this._ValCoordR3(seed, x1, y3, z1), - this._ValCoordR3(seed, x2, y3, z1), - this._ValCoordR3(seed, x3, y3, z1), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z2), - this._ValCoordR3(seed, x1, y0, z2), - this._ValCoordR3(seed, x2, y0, z2), - this._ValCoordR3(seed, x3, y0, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z2), - this._ValCoordR3(seed, x1, y1, z2), - this._ValCoordR3(seed, x2, y1, z2), - this._ValCoordR3(seed, x3, y1, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z2), - this._ValCoordR3(seed, x1, y2, z2), - this._ValCoordR3(seed, x2, y2, z2), - this._ValCoordR3(seed, x3, y2, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z2), - this._ValCoordR3(seed, x1, y3, z2), - this._ValCoordR3(seed, x2, y3, z2), - this._ValCoordR3(seed, x3, y3, z2), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z3), - this._ValCoordR3(seed, x1, y0, z3), - this._ValCoordR3(seed, x2, y0, z3), - this._ValCoordR3(seed, x3, y0, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z3), - this._ValCoordR3(seed, x1, y1, z3), - this._ValCoordR3(seed, x2, y1, z3), - this._ValCoordR3(seed, x3, y1, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z3), - this._ValCoordR3(seed, x1, y2, z3), - this._ValCoordR3(seed, x2, y2, z3), - this._ValCoordR3(seed, x3, y2, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z3), - this._ValCoordR3(seed, x1, y3, z3), - this._ValCoordR3(seed, x2, y3, z3), - this._ValCoordR3(seed, x3, y3, z3), - xs - ), - ys - ), - zs - ) * - (1 / (1.5 * 1.5 * 1.5)) - ); - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleValueR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp( - this._ValCoordR2(seed, x0, y0), - this._ValCoordR2(seed, x1, y0), - xs - ); - let xf1 = FastNoiseLite._Lerp( - this._ValCoordR2(seed, x0, y1), - this._ValCoordR2(seed, x1, y1), - xs - ); - - return FastNoiseLite._Lerp(xf0, xf1, ys); - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleValueR3(seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - let zs = FastNoiseLite._InterpHermite(z - z0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - xs - ); - let xf11 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - xs - ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs); - } - - /** - * @private - */ - _DoSingleDomainWarp() { + /** - * + * @private * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector2} coord * @param {number} x * @param {number} y + * @returns {number} */ - let R2 = (seed, amp, freq, coord, x, y) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 38.283687591552734375, - freq, - coord, - false, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 16.0, - freq, - coord, - true, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); - break; + _SingleOpenSimplex2SR2(seed, x, y) { + // 2D OpenSimplex2S case is a modified 2D simplex noise. + + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + /* + * --- Skew moved to TransformNoiseCoordinate method --- + * final FNLfloat F2 = 0.5f * (SQRT3 - 1); + * FNLfloat s = (x + y) * F2; + * x += s; y += s; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + let i1 = i + this._PrimeX; + let j1 = j + this._PrimeY; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; + let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); + let a1 = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); + let x1 = x0 - (1 - 2 * G2); + let y1 = y0 - (1 - 2 * G2); + value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); + + // Nested conditionals were faster than compact bit logic/arithmetic. + let xmyi = xi - yi; + if (t > G2) { + if (xi + xmyi > 1) { + let x2 = x0 + (3 * G2 - 2); + let y2 = y0 + (3 * G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2( + seed, + i + (this._PrimeX << 1), + j + this._PrimeY, + x2, + y2 + ); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); + } + } + + if (yi - xmyi > 1) { + let x3 = x0 + (3 * G2 - 1); + let y3 = y0 + (3 * G2 - 2); + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2( + seed, + i + this._PrimeX, + j + (this._PrimeY << 1), + x3, + y3 + ); + } + } else { + let x3 = x0 + (G2 - 1); + let y3 = y0 + G2; + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); + } + } + } else { + if (xi + xmyi < 0) { + let x2 = x0 + (1 - G2); + let y2 = y0 - G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); + } + } else { + let x2 = x0 + (G2 - 1); + let y2 = y0 + G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); + } + } + + if (yi < xmyi) { + let x2 = x0 - G2; + let y2 = y0 - (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); + } + } } - }; - + + return value * 18.24196194486065; + } + /** - * + * @private * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector3} coord * @param {number} x * @param {number} y * @param {number} z + * @returns {number} */ - let R3 = (seed, amp, freq, coord, x, y, z) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( + _SingleOpenSimplex2SR3(seed, x, y, z) { + // 3D OpenSimplex2S case uses two offset rotated cube grids. + + /* + * --- Rotation moved to TransformNoiseCoordinate method --- + * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); + * FNLfloat r = (x + y + z) * R3; // Rotation, not skew + * x = r - x; y = r - y; z = r - z; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let k = Math.floor(z); + let xi = x - i; + let yi = y - j; + let zi = z - k; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + let seed2 = seed + 1293373; + + let xNMask = Math.trunc(-0.5 - xi); + let yNMask = Math.trunc(-0.5 - yi); + let zNMask = Math.trunc(-0.5 - zi); + + let x0 = xi + xNMask; + let y0 = yi + yNMask; + let z0 = zi + zNMask; + let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; + let value = + a0 * + a0 * + (a0 * a0) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x0, + y0, + z0 + ); + + let x1 = xi - 0.5; + let y1 = yi - 0.5; + let z1 = zi - 0.5; + let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; + value += + a1 * + a1 * + (a1 * a1) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + this._PrimeZ, + x1, + y1, + z1 + ); + + let xAFlipMask0 = ((xNMask | 1) << 1) * x1; + let yAFlipMask0 = ((yNMask | 1) << 1) * y1; + let zAFlipMask0 = ((zNMask | 1) << 1) * z1; + let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; + let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; + let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; + + let skip5 = false; + let a2 = xAFlipMask0 + a0; + if (a2 > 0) { + let x2 = x0 - (xNMask | 1); + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR3( seed, - amp * 32.69428253173828125, - freq, - coord, - false, - x, - y, - z + i + (~xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x2, + y0, + z0 ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( + } else { + let a3 = yAFlipMask0 + zAFlipMask0 + a0; + + if (a3 > 0) { + let x3 = x0; + let y3 = y0 - (yNMask | 1); + let z3 = z0 - (zNMask | 1); + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x3, + y3, + z3 + ); + } + + let a4 = xAFlipMask1 + a1; + if (a4 > 0) { + let x4 = (xNMask | 1) + x1; + value += + a4 * + a4 * + (a4 * a4) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + this._PrimeZ, + x4, + y1, + z1 + ); + skip5 = true; + } + } + + let skip9 = false; + let a6 = yAFlipMask0 + a0; + if (a6 > 0) { + let x6 = x0; + let y6 = y0 - (yNMask | 1); + value += + a6 * + a6 * + (a6 * a6) * + this._GradCoordR3( seed, - amp * 7.71604938271605, - freq, - coord, - true, - x, - y, - z + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x6, + y6, + z0 ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); - break; + } else { + let a7 = xAFlipMask0 + zAFlipMask0 + a0; + if (a7 > 0) { + let x7 = x0 - (xNMask | 1); + let y7 = y0; + let z7 = z0 - (zNMask | 1); + value += + a7 * + a7 * + (a7 * a7) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x7, + y7, + z7 + ); + } + + let a8 = yAFlipMask1 + a1; + if (a8 > 0) { + let x8 = x1; + let y8 = (yNMask | 1) + y1; + value += + a8 * + a8 * + (a8 * a8) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + x8, + y8, + z1 + ); + skip9 = true; + } } - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - return R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5] - ); - } - - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - return R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); - } - } - - /** - * @private - */ - _DomainWarpSingle() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; + + let skipD = false; + let aA = zAFlipMask0 + a0; + if (aA > 0) { + let xA = x0; + let yA = y0; + let zA = z0 - (zNMask | 1); + value += + aA * + aA * + (aA * aA) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + xA, + yA, + zA + ); + } else { + let aB = xAFlipMask0 + yAFlipMask0 + a0; + if (aB > 0) { + let xB = x0 - (xNMask | 1); + let yB = y0 - (yNMask | 1); + value += + aB * + aB * + (aB * aB) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + xB, + yB, + z0 + ); + } + + let aC = zAFlipMask1 + a1; + if (aC > 0) { + let xC = x1; + let yC = y1; + let zC = (zNMask | 1) + z1; + value += + aC * + aC * + (aC * aC) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + xC, + yC, + zC + ); + skipD = true; } - default: - break; } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - break; + + if (!skip5) { + let a5 = yAFlipMask1 + zAFlipMask1 + a1; + if (a5 > 0) { + let x5 = x1; + let y5 = (yNMask | 1) + y1; + let z5 = (zNMask | 1) + z1; + value += + a5 * + a5 * + (a5 * a5) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + (zNMask & (this._PrimeZ << 1)), + x5, + y5, + z5 + ); } - default: - break; } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } - } - - _DomainWarpFractalProgressive() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - } - default: - break; + + if (!skip9) { + let a9 = xAFlipMask1 + zAFlipMask1 + a1; + if (a9 > 0) { + let x9 = (xNMask | 1) + x1; + let y9 = y1; + let z9 = (zNMask | 1) + z1; + value += + a9 * + a9 * + (a9 * a9) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + x9, + y9, + z9 + ); } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; } - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - } - break; - default: - break; + + if (!skipD) { + let aD = xAFlipMask1 + yAFlipMask1 + a1; + if (aD > 0) { + let xD = (xNMask | 1) + x1; + let yD = (yNMask | 1) + y1; + value += + aD * + aD * + (aD * aD) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX << 1)), + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + xD, + yD, + z1 + ); } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; } - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); + + return value * 9.046026385208288; } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } - } - - /** - * @private - */ - _DomainWarpFractalIndependent() { + /** - * - * @param {Vector2} coord + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} */ - let R2 = (coord) => { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - } + _SingleCellularR2(seed, x, y) { + /** + * + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + let xr = Math.round(x); + let yr = Math.round(y); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + + let closestHash = 0; + + let cellularJitter = 0.43701595 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + + switch (this._CellularDistanceFunction) { default: + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY; + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = Math.abs(vecX) + Math.abs(vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } break; } - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + + if ( + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue + ) { + distance1 = Math.sqrt(distance1); + } } - }; - + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; + } + } + /** - * - * @param {Vector3} coord + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} */ - let R3 = (coord) => { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; + _SingleCellularR3(seed, x, y, z) { + let xr = Math.round(x); + let yr = Math.round(y); + let zr = Math.round(z); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + let closestHash = 0; + + let cellularJitter = 0.39614353 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + let zPrimedBase = (zr - 1) * this._PrimeZ; + + switch (this._CellularDistanceFunction) { + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; } break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; } break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = + Math.abs(vecX) + + Math.abs(vecY) + + Math.abs(vecZ) + + (vecX * vecX + vecY * vecY + vecZ * vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; } break; default: break; } - - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + + if ( + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue + ) { + distance1 = Math.sqrt(distance1); + } + } + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; } - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); } - } - - /** - * @private - */ - _SingleDomainWarpBasicGrid() { + /** - * + * @private * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord * @param {number} x * @param {number} y + * @returns {number} */ - - let R2 = (seed, warpAmp, frequency, coord, x, y) => { - let xf = x * frequency; - let yf = y * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - + _SinglePerlinR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xd0 = x - x0; + let yd0 = y - y0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + x0 = Math.imul(x0, this._PrimeX); y0 = Math.imul(y0, this._PrimeY); let x1 = x0 + this._PrimeX; let y1 = y0 + this._PrimeY; - - let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); - let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); - - let lx0x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0], - this._RandVecs2D[hash1], - xs - ); - let ly0x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0 | 1], - this._RandVecs2D[hash1 | 1], - xs - ); - - hash0 = this._HashR2(seed, x0, y1) & (255 << 1); - hash1 = this._HashR2(seed, x1, y1) & (255 << 1); - - let lx1x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0], - this._RandVecs2D[hash1], + + let xf0 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y0, xd0, yd0), + this._GradCoordR2(seed, x1, y0, xd1, yd0), xs ); - let ly1x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0 | 1], - this._RandVecs2D[hash1 | 1], + let xf1 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y1, xd0, yd1), + this._GradCoordR2(seed, x1, y1, xd1, yd1), xs ); - - coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; - coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; - }; - + + return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; + } + /** - * + * @private * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord * @param {number} x * @param {number} y * @param {number} z + * @returns {number} */ - let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { - let xf = x * frequency; - let yf = y * frequency; - let zf = z * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - let z0 = Math.floor(zf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - let zs = FastNoiseLite._InterpHermite(zf - z0); - + _SinglePerlinR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xd0 = x - x0; + let yd0 = y - y0; + let zd0 = z - z0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + let zd1 = zd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + let zs = FastNoiseLite._InterpQuintic(zd0); + x0 = Math.imul(x0, this._PrimeX); y0 = Math.imul(y0, this._PrimeY); z0 = Math.imul(z0, this._PrimeZ); let x1 = x0 + this._PrimeX; let y1 = y0 + this._PrimeY; let z1 = z0 + this._PrimeZ; - - let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); - let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); - - let lx0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], + + let xf00 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), + this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), xs ); - let ly0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], + let xf10 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), + this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), xs ); - let lz0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], + let xf01 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), + this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), xs ); - - hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); - - let lx1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], + let xf11 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), + this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), xs ); - let ly1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueCubicR2(seed, x, y) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + + let xs = x - x1; + let ys = y - y1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), + this._ValCoordR2(seed, x2, y0), + this._ValCoordR2(seed, x3, y0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), + this._ValCoordR2(seed, x2, y1), + this._ValCoordR2(seed, x3, y1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y2), + this._ValCoordR2(seed, x1, y2), + this._ValCoordR2(seed, x2, y2), + this._ValCoordR2(seed, x3, y2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y3), + this._ValCoordR2(seed, x1, y3), + this._ValCoordR2(seed, x2, y3), + this._ValCoordR2(seed, x3, y3), + xs + ), + ys + ) * + (1 / (1.5 * 1.5)) ); - let lz1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueCubicR3(seed, x, y, z) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + let z1 = Math.floor(z); + + let xs = x - x1; + let ys = y - y1; + let zs = z - z1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + z1 = Math.imul(z1, this._PrimeZ); + + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let z0 = z1 - this._PrimeZ; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let z2 = z1 + this._PrimeZ; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + let z3 = z1 + (this._PrimeZ << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + this._ValCoordR3(seed, x2, y0, z0), + this._ValCoordR3(seed, x3, y0, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + this._ValCoordR3(seed, x2, y1, z0), + this._ValCoordR3(seed, x3, y1, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z0), + this._ValCoordR3(seed, x1, y2, z0), + this._ValCoordR3(seed, x2, y2, z0), + this._ValCoordR3(seed, x3, y2, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z0), + this._ValCoordR3(seed, x1, y3, z0), + this._ValCoordR3(seed, x2, y3, z0), + this._ValCoordR3(seed, x3, y3, z0), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + this._ValCoordR3(seed, x2, y0, z1), + this._ValCoordR3(seed, x3, y0, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + this._ValCoordR3(seed, x2, y1, z1), + this._ValCoordR3(seed, x3, y1, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z1), + this._ValCoordR3(seed, x1, y2, z1), + this._ValCoordR3(seed, x2, y2, z1), + this._ValCoordR3(seed, x3, y2, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z1), + this._ValCoordR3(seed, x1, y3, z1), + this._ValCoordR3(seed, x2, y3, z1), + this._ValCoordR3(seed, x3, y3, z1), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z2), + this._ValCoordR3(seed, x1, y0, z2), + this._ValCoordR3(seed, x2, y0, z2), + this._ValCoordR3(seed, x3, y0, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z2), + this._ValCoordR3(seed, x1, y1, z2), + this._ValCoordR3(seed, x2, y1, z2), + this._ValCoordR3(seed, x3, y1, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z2), + this._ValCoordR3(seed, x1, y2, z2), + this._ValCoordR3(seed, x2, y2, z2), + this._ValCoordR3(seed, x3, y2, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z2), + this._ValCoordR3(seed, x1, y3, z2), + this._ValCoordR3(seed, x2, y3, z2), + this._ValCoordR3(seed, x3, y3, z2), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z3), + this._ValCoordR3(seed, x1, y0, z3), + this._ValCoordR3(seed, x2, y0, z3), + this._ValCoordR3(seed, x3, y0, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z3), + this._ValCoordR3(seed, x1, y1, z3), + this._ValCoordR3(seed, x2, y1, z3), + this._ValCoordR3(seed, x3, y1, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z3), + this._ValCoordR3(seed, x1, y2, z3), + this._ValCoordR3(seed, x2, y2, z3), + this._ValCoordR3(seed, x3, y2, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z3), + this._ValCoordR3(seed, x1, y3, z3), + this._ValCoordR3(seed, x2, y3, z3), + this._ValCoordR3(seed, x3, y3, z3), + xs + ), + ys + ), + zs + ) * + (1 / (1.5 * 1.5 * 1.5)) ); - - let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); - let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); - let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); - - hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); - - lx0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), xs ); - ly0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], + let xf1 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), xs ); - lz0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], + + return FastNoiseLite._Lerp(xf0, xf1, ys); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + let zs = FastNoiseLite._InterpHermite(z - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), xs ); - - hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); - - lx1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], + let xf10 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), xs ); - ly1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], + let xf01 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), xs ); - lz1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], + let xf11 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), xs ); - - coord.x += - FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * - warpAmp; - coord.y += - FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * - warpAmp; - coord.z += - FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * - warpAmp; - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5] - ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs); + } + + /** + * @private + */ + _DoSingleDomainWarp() { + /** + * + * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + let R2 = (seed, amp, freq, coord, x, y) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 38.283687591552734375, + freq, + coord, + false, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 16.0, + freq, + coord, + true, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); + break; + } + }; + + /** + * + * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, amp, freq, coord, x, y, z) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 32.69428253173828125, + freq, + coord, + false, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 7.71604938271605, + freq, + coord, + true, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); + break; + } + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + return R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] + ); + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + return R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + } + + /** + * @private + */ + _DomainWarpSingle() { + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + } + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + break; + } + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } } - - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); + + _DomainWarpFractalProgressive() { + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + } + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + } + break; + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } } - } - - /** - * @private - */ - _SingleDomainWarpOpenSimplex2Gradient() { + /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y + * @private */ - let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - x *= frequency; - y *= frequency; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let vx, vy; - vx = vy = 0; - - let a = 0.5 - x0 * x0 - y0 * y0; - if (a > 0) { - let aaaa = a * a * (a * a); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i, j) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i, j); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x0 * xg + y0 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; + _DomainWarpFractalIndependent() { + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + } + default: + break; } - vx += aaaa * xo; - vy += aaaa * yo; - } - - let c = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - if (c > 0) { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - let cccc = c * c * (c * c); - let xo, yo; - if (outGradOnly) { - let hash = - this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & - (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x2 * xg + y2 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + } + break; + default: + break; + } + + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; } - vx += cccc * xo; - vy += cccc * yo; + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); } - - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + /** + * @private + */ + _SingleDomainWarpBasicGrid() { + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + + let R2 = (seed, warpAmp, frequency, coord, x, y) => { + let xf = x * frequency; + let yf = y * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); + let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + hash0 = this._HashR2(seed, x0, y1) & (255 << 1); + hash1 = this._HashR2(seed, x1, y1) & (255 << 1); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; + coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { + let xf = x * frequency; + let yf = y * frequency; + let zf = z * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + let z0 = Math.floor(zf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + let zs = FastNoiseLite._InterpHermite(zf - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); + let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); + let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); + let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); + + hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); + + lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); + + lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + coord.x += + FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * + warpAmp; + coord.y += + FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * + warpAmp; + coord.z += + FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * + warpAmp; + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] + ); + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + } + + /** + * @private + */ + _SingleDomainWarpOpenSimplex2Gradient() { + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + */ + let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + x *= frequency; + y *= frequency; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let vx, vy; + vx = vy = 0; + + let a = 0.5 - x0 * x0 - y0 * y0; + if (a > 0) { + let aaaa = a * a * (a * a); let xo, yo; if (outGradOnly) { - let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); + let hash = this._HashR2(seed, i, j) & (255 << 1); xo = this._RandVecs2D[hash]; yo = this._RandVecs2D[hash | 1]; } else { - let hash = this._HashR2(seed, i, j + this._PrimeY); + let hash = this._HashR2(seed, i, j); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); let xg = this._Gradients2D[index1]; let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; + let value = x0 * xg + y0 * yg; let xgo = this._RandVecs2D[index2]; let ygo = this._RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } - vx += bbbb * xo; - vy += bbbb * yo; + vx += aaaa * xo; + vy += aaaa * yo; } - } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + if (c > 0) { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + let cccc = c * c * (c * c); let xo, yo; if (outGradOnly) { - let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); + let hash = + this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & + (255 << 1); xo = this._RandVecs2D[hash]; yo = this._RandVecs2D[hash | 1]; } else { - let hash = this._HashR2(seed, i + this._PrimeX, j); + let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); let xg = this._Gradients2D[index1]; let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; + let value = x2 * xg + y2 * yg; let xgo = this._RandVecs2D[index2]; let ygo = this._RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } - vx += bbbb * xo; - vy += bbbb * yo; + vx += cccc * xo; + vy += cccc * yo; } - } - - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - }; - - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { - x *= frequency; - y *= frequency; - z *= frequency; - - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let xNSign = (-x0 - 1.0) | 1; - let yNSign = (-y0 - 1.0) | 1; - let zNSign = (-z0 - 1.0) | 1; - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let vx, vy, vz; - vx = vy = vz = 0; - - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - for (let l = 0; ; l++) { - if (a > 0) { - let aaaa = a * a * (a * a); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i, j, k) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; - } else { - let hash = this._HashR3(seed, i, j, k); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x0 * xg + y0 * yg + z0 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i, j + this._PrimeY); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x1 * xg + y1 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += bbbb * xo; + vy += bbbb * yo; } - vx += aaaa * xo; - vy += aaaa * yo; - vz += aaaa * zo; - } - - let b = a; - let i1 = i; - let j1 = j; - let k1 = k; - let x1 = x0; - let y1 = y0; - let z1 = z0; - - if (ax0 >= ay0 && ax0 >= az0) { - x1 += xNSign; - b = b + ax0 + ax0; - i1 -= xNSign * this._PrimeX; - } else if (ay0 > ax0 && ay0 >= az0) { - y1 += yNSign; - b = b + ay0 + ay0; - j1 -= yNSign * this._PrimeY; } else { - z1 += zNSign; - b = b + az0 + az0; - k1 -= zNSign * this._PrimeZ; + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i + this._PrimeX, j); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x1 * xg + y1 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += bbbb * xo; + vy += bbbb * yo; + } } - - if (b > 1) { - b -= 1; - let bbbb = b * b * (b * b); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { + x *= frequency; + y *= frequency; + z *= frequency; + + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let xNSign = (-x0 - 1.0) | 1; + let yNSign = (-y0 - 1.0) | 1; + let zNSign = (-z0 - 1.0) | 1; + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let vx, vy, vz; + vx = vy = vz = 0; + + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + for (let l = 0; ; l++) { + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i, j, k) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i, j, k); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x0 * xg + y0 * yg + z0 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; + } + vx += aaaa * xo; + vy += aaaa * yo; + vz += aaaa * zo; + } + + let b = a; + let i1 = i; + let j1 = j; + let k1 = k; + let x1 = x0; + let y1 = y0; + let z1 = z0; + + if (ax0 >= ay0 && ax0 >= az0) { + x1 += xNSign; + b = b + ax0 + ax0; + i1 -= xNSign * this._PrimeX; + } else if (ay0 > ax0 && ay0 >= az0) { + y1 += yNSign; + b = b + ay0 + ay0; + j1 -= yNSign * this._PrimeY; } else { - let hash = this._HashR3(seed, i1, j1, k1); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x1 * xg + y1 * yg + z1 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; + z1 += zNSign; + b = b + az0 + az0; + k1 -= zNSign * this._PrimeZ; + } + + if (b > 1) { + b -= 1; + let bbbb = b * b * (b * b); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i1, j1, k1); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x1 * xg + y1 * yg + z1 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; + } + vx += bbbb * xo; + vy += bbbb * yo; + vz += bbbb * zo; } - vx += bbbb * xo; - vy += bbbb * yo; - vz += bbbb * zo; + + if (l === 1) break; + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed += 1293373; } - - if (l === 1) break; - - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; - - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; - - a += 0.75 - ax0 - (ay0 + az0); - - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; - - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; - - seed += 1293373; + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + coord.z += vz * warpAmp; + }; + + if (arguments.length === 7) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + + if (arguments.length === 8) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6], + arguments[7] + ); } - - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - coord.z += vz * warpAmp; - }; - - if (arguments.length === 7) { - R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); - } - - if (arguments.length === 8) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6], - arguments[7] - ); } } - } - - class Vector2 { - /** - * 2d Vector - * @param {number} x - * @param {number} y - */ - constructor(x, y) { - this.x = x; - this.y = y; + + class Vector2 { + /** + * 2d Vector + * @param {number} x + * @param {number} y + */ + constructor(x, y) { + this.x = x; + this.y = y; + } } - } - - class Vector3 { - /** - * 3d Vector - * @param {number} x - * @param {number} y - * @param {number} z - */ - constructor(x, y, z) { - this.x = x; - this.y = y; - this.z = z; + + class Vector3 { + /** + * 3d Vector + * @param {number} x + * @param {number} y + * @param {number} z + */ + constructor(x, y, z) { + this.x = x; + this.y = y; + this.z = z; + } } - } - - Scratch.extensions.register(new Noise()); -})((window.Scratch = window.Scratch || {})); + + Scratch.extensions.register(new Noise()); + })((window.Scratch = window.Scratch || {})); + \ No newline at end of file From e2ba8e7c42a76ff3b9c16a49a306a7e837f38077 Mon Sep 17 00:00:00 2001 From: Cubester Date: Wed, 25 Dec 2024 18:54:25 -0500 Subject: [PATCH 11/36] Cast --- extensions/Corbnorb/noise.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 4d33f978bc..c68066bc3c 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -120,6 +120,14 @@ } initNoise(args) { + args.ID = Scratch.Cast.toString(args.ID); + args.SEED = Scratch.Cast.toNumber(args.SEED); + args.TYPE = Scratch.Cast.toString(args.TYPE); + args.OCTAVES = Scratch.Cast.toNumber(args.OCTAVES); + args.FREQUENCY = Scratch.Cast.toNumber(args.FREQUENCY); + args.FRACTAL = Scratch.Cast.toString(args.FRACTAL); + args.INVERTED = Scratch.Cast.toString(args.INVERTED); + args.EASING = Scratch.Cast.toString(args.EASING); noises[args.ID] = [new FastNoiseLite(args.SEED), 0, 0]; switch (args.TYPE) { case "OpenSimplex2": @@ -164,6 +172,10 @@ } getNoise(args) { + args.ID = Scratch.Cast.toString(args.ID); + args.X = Scratch.Cast.toNumber(args.X); + args.Y = Scratch.Cast.toNumber(args.Y); + args.Z = Scratch.Cast.toNumber(args.Z); if (args.ID in noises) { let value = noises[args.ID][0].GetNoise(args.X, args.Y, args.Z); value = noises[args.ID][1] == "true" ? value : -value; From befd463fd868faae548325aded0989df718ed0a4 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 17:00:17 -0700 Subject: [PATCH 12/36] license --- extensions/Corbnorb/noise.js | 50 +++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 45cfb98b06..3c3efafb13 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -1,5 +1,5 @@ // Name: Noise -// ID: noise-corbnorb +// ID: corbnorbsnoise // Description: Adds many types of noises using FastNoiseLite // By: Corbnorbs // Original: Auburn @@ -12,6 +12,7 @@ const BlockType = Scratch.BlockType; const ArgumentType = Scratch.ArgumentType; + const Cast = Scratch.Cast; class Noise { constructor() { @@ -22,7 +23,7 @@ getInfo() { return { - id: "noise-corbnorb", + id: "corbnorbsnoise", name: "Noise", color1: "#b5074c", color2: "#990841", @@ -31,7 +32,7 @@ { opcode: "initNoise", blockType: BlockType.COMMAND, - text: "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL]", + text: "create noise id:[ID] type:[TYPE] frequency:[FREQUENCY] fractal:[FRACTAL] octaves:[OCTAVES] seed:[SEED]", arguments: { ID: { type: ArgumentType.STRING, @@ -64,7 +65,7 @@ { opcode: "getNoise", blockType: BlockType.REPORTER, - text: "get noise id:[ID] at x:[X] y:[Y] z:[Z] inverted?[INVERTED] easing:[EASING]", + text: "get noise id:[ID] at x:[X] y:[Y] z:[Z] easing:[EASING] inverted?[INVERTED]", arguments: { ID: { type: ArgumentType.STRING, @@ -124,11 +125,11 @@ } initNoise(args) { - const id = args.ID; - const seed = args.SEED; - const fractal = args.FRACTAL; - const frequency = args.FREQUENCY; - const octaves = args.OCTAVES; + const id = Cast.toString(args.ID); + const seed = Cast.toNumber(args.SEED); + const fractal = Cast.toString(args.FRACTAL); + const frequency = Cast.toNumber(args.FREQUENCY); + const octaves = Cast.toNumber(args.OCTAVES); noises[id] = new FastNoiseLite(seed); switch (args.TYPE) { case "OpenSimplex2": @@ -171,9 +172,9 @@ } getNoise(args) { - const id = args.ID; - const easing = args.EASING; - const inverted = args.INVERTED; + const id = Cast.toString(args.ID); + const easing = Cast.toString(args.EASING); + const inverted = Cast.toString(args.INVERTED); if (id in noises) { let value = noises[id].GetNoise(args.X, args.Y, args.Z); value = inverted == "true" ? value : -value; @@ -194,9 +195,34 @@ value = value * 2 - 1; return value; } + console.log("ISSUE"); return 0; } } + +// MIT License +// +// Copyright(c) 2023 Jordan Peck (jordan.me2@gmail.com) +// Copyright(c) 2023 Contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// class FastNoiseLite { static NoiseType = Object.freeze({ From 4068e2f319b21c06d96ad803c87a4db8b62a8e6b Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 18:00:05 -0700 Subject: [PATCH 13/36] final fixes --- extensions/Corbnorb/noise.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 3c3efafb13..a21db9e9a3 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -98,7 +98,7 @@ ], menus: { NOISE_TYPE: { - acceptReporters: false, + acceptReporters: true, items: [ "OpenSimpex2", "OpenSimpex2S", @@ -109,15 +109,15 @@ ], }, FRACTAL_TYPE: { - acceptReporters: false, + acceptReporters: true, items: ["None", "FBm", "Ridged", "Ping Pong"], }, INVERTED_MENU: { acceptReporters: true, - items: ["true", "false"], + items: [{text: "true", value: true}, {text: "false", value: false}], }, EASING_TYPE: { - acceptReporters: false, + acceptReporters: true, items: ["Linear", "Squared", "Cubed", "Root"], }, }, @@ -152,6 +152,9 @@ case "Value": noises[id].SetNoiseType(FastNoiseLite.NoiseType.Value); break; + default: + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); + break; } switch (fractal) { case "None": @@ -166,6 +169,9 @@ case "Ping Pong": noises[id].SetFractalType(FastNoiseLite.FractalType.PingPong); break; + default: + noises[id].SetFractalType(FastNoiseLite.FractalType.None); + break; } noises[id].SetFrequency(frequency); noises[id].SetFractalOctaves(octaves); @@ -174,10 +180,10 @@ getNoise(args) { const id = Cast.toString(args.ID); const easing = Cast.toString(args.EASING); - const inverted = Cast.toString(args.INVERTED); + const inverted = Cast.toBoolean(args.INVERTED); if (id in noises) { let value = noises[id].GetNoise(args.X, args.Y, args.Z); - value = inverted == "true" ? value : -value; + value = inverted ? -value : value; value = (value + 1) / 2; switch (easing) { case "Linear": @@ -191,6 +197,8 @@ case "Root": value = Math.sqrt(Math.abs(value)); break; + default: + break; } value = value * 2 - 1; return value; From f742fdaa9d253700e040c868d6a55cc17c7a1476 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 18:02:39 -0700 Subject: [PATCH 14/36] prettier --- extensions/Corbnorb/noise.js | 6226 +++++++++++++++++----------------- 1 file changed, 3113 insertions(+), 3113 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index a21db9e9a3..ad9d877291 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -6,602 +6,603 @@ // License: MPL-2.0 (function (Scratch) { - "use strict"; - - const noises = Object.create(null); - - const BlockType = Scratch.BlockType; - const ArgumentType = Scratch.ArgumentType; - const Cast = Scratch.Cast; - - class Noise { - constructor() { - this.noiseSeed = 0; - this.worleySeed = 0; - this.time = performance.now(); - } - - getInfo() { - return { - id: "corbnorbsnoise", - name: "Noise", - color1: "#b5074c", - color2: "#990841", - docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", - blocks: [ - { - opcode: "initNoise", - blockType: BlockType.COMMAND, - text: "create noise id:[ID] type:[TYPE] frequency:[FREQUENCY] fractal:[FRACTAL] octaves:[OCTAVES] seed:[SEED]", - arguments: { - ID: { - type: ArgumentType.STRING, - defaultValue: "myNoise", - }, - SEED: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - TYPE: { - type: ArgumentType.STRING, - menu: "NOISE_TYPE", - defaultValue: "Perlin", - }, - OCTAVES: { - type: ArgumentType.NUMBER, - defaultValue: "1", - }, - FREQUENCY: { - type: ArgumentType.NUMBER, - defaultValue: "0.01", - }, - FRACTAL: { - type: ArgumentType.STRING, - menu: "FRACTAL_TYPE", - defaultValue: "FBm", - }, + "use strict"; + + const noises = Object.create(null); + + const BlockType = Scratch.BlockType; + const ArgumentType = Scratch.ArgumentType; + const Cast = Scratch.Cast; + + class Noise { + constructor() { + this.noiseSeed = 0; + this.worleySeed = 0; + this.time = performance.now(); + } + + getInfo() { + return { + id: "corbnorbsnoise", + name: "Noise", + color1: "#b5074c", + color2: "#990841", + docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", + blocks: [ + { + opcode: "initNoise", + blockType: BlockType.COMMAND, + text: "create noise id:[ID] type:[TYPE] frequency:[FREQUENCY] fractal:[FRACTAL] octaves:[OCTAVES] seed:[SEED]", + arguments: { + ID: { + type: ArgumentType.STRING, + defaultValue: "myNoise", }, - }, - { - opcode: "getNoise", - blockType: BlockType.REPORTER, - text: "get noise id:[ID] at x:[X] y:[Y] z:[Z] easing:[EASING] inverted?[INVERTED]", - arguments: { - ID: { - type: ArgumentType.STRING, - defaultValue: "myNoise", - }, - X: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - Y: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - Z: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - INVERTED: { - type: ArgumentType.STRING, - menu: "INVERTED_MENU", - defaultValue: "false", - }, - EASING: { - type: ArgumentType.STRING, - menu: "EASING_TYPE", - defaultValue: "Linear", - }, + SEED: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + TYPE: { + type: ArgumentType.STRING, + menu: "NOISE_TYPE", + defaultValue: "Perlin", + }, + OCTAVES: { + type: ArgumentType.NUMBER, + defaultValue: "1", + }, + FREQUENCY: { + type: ArgumentType.NUMBER, + defaultValue: "0.01", + }, + FRACTAL: { + type: ArgumentType.STRING, + menu: "FRACTAL_TYPE", + defaultValue: "FBm", }, }, - ], - menus: { - NOISE_TYPE: { - acceptReporters: true, - items: [ - "OpenSimpex2", - "OpenSimpex2S", - "Cellular", - "Perlin", - "Value Cubic", - "Value", - ], - }, - FRACTAL_TYPE: { - acceptReporters: true, - items: ["None", "FBm", "Ridged", "Ping Pong"], - }, - INVERTED_MENU: { - acceptReporters: true, - items: [{text: "true", value: true}, {text: "false", value: false}], - }, - EASING_TYPE: { - acceptReporters: true, - items: ["Linear", "Squared", "Cubed", "Root"], + }, + { + opcode: "getNoise", + blockType: BlockType.REPORTER, + text: "get noise id:[ID] at x:[X] y:[Y] z:[Z] easing:[EASING] inverted?[INVERTED]", + arguments: { + ID: { + type: ArgumentType.STRING, + defaultValue: "myNoise", + }, + X: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + Y: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + Z: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + INVERTED: { + type: ArgumentType.STRING, + menu: "INVERTED_MENU", + defaultValue: "false", + }, + EASING: { + type: ArgumentType.STRING, + menu: "EASING_TYPE", + defaultValue: "Linear", + }, }, }, - }; - } - - initNoise(args) { - const id = Cast.toString(args.ID); - const seed = Cast.toNumber(args.SEED); - const fractal = Cast.toString(args.FRACTAL); - const frequency = Cast.toNumber(args.FREQUENCY); - const octaves = Cast.toNumber(args.OCTAVES); - noises[id] = new FastNoiseLite(seed); - switch (args.TYPE) { - case "OpenSimplex2": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); - break; - case "OpenSimplex2S": - noises[id].SetNoiseType( - FastNoiseLite.NoiseType.OpenSimplex2S - ); - break; - case "Cellular": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Cellular); - break; - case "Perlin": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); - break; - case "Value Cubic": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.ValueCubic); - break; - case "Value": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Value); - break; - default: - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); - break; - } - switch (fractal) { - case "None": - noises[id].SetFractalType(FastNoiseLite.FractalType.None); + ], + menus: { + NOISE_TYPE: { + acceptReporters: true, + items: [ + "OpenSimpex2", + "OpenSimpex2S", + "Cellular", + "Perlin", + "Value Cubic", + "Value", + ], + }, + FRACTAL_TYPE: { + acceptReporters: true, + items: ["None", "FBm", "Ridged", "Ping Pong"], + }, + INVERTED_MENU: { + acceptReporters: true, + items: [ + { text: "true", value: true }, + { text: "false", value: false }, + ], + }, + EASING_TYPE: { + acceptReporters: true, + items: ["Linear", "Squared", "Cubed", "Root"], + }, + }, + }; + } + + initNoise(args) { + const id = Cast.toString(args.ID); + const seed = Cast.toNumber(args.SEED); + const fractal = Cast.toString(args.FRACTAL); + const frequency = Cast.toNumber(args.FREQUENCY); + const octaves = Cast.toNumber(args.OCTAVES); + noises[id] = new FastNoiseLite(seed); + switch (args.TYPE) { + case "OpenSimplex2": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); + break; + case "OpenSimplex2S": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2S); + break; + case "Cellular": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Cellular); + break; + case "Perlin": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); + break; + case "Value Cubic": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.ValueCubic); + break; + case "Value": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Value); + break; + default: + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); + break; + } + switch (fractal) { + case "None": + noises[id].SetFractalType(FastNoiseLite.FractalType.None); + break; + case "FBm": + noises[id].SetFractalType(FastNoiseLite.FractalType.FBm); + break; + case "Ridged": + noises[id].SetFractalType(FastNoiseLite.FractalType.Ridged); + break; + case "Ping Pong": + noises[id].SetFractalType(FastNoiseLite.FractalType.PingPong); + break; + default: + noises[id].SetFractalType(FastNoiseLite.FractalType.None); + break; + } + noises[id].SetFrequency(frequency); + noises[id].SetFractalOctaves(octaves); + } + + getNoise(args) { + const id = Cast.toString(args.ID); + const easing = Cast.toString(args.EASING); + const inverted = Cast.toBoolean(args.INVERTED); + if (id in noises) { + let value = noises[id].GetNoise(args.X, args.Y, args.Z); + value = inverted ? -value : value; + value = (value + 1) / 2; + switch (easing) { + case "Linear": break; - case "FBm": - noises[id].SetFractalType(FastNoiseLite.FractalType.FBm); + case "Squared": + value = Math.pow(value, 2); break; - case "Ridged": - noises[id].SetFractalType(FastNoiseLite.FractalType.Ridged); + case "Cubed": + value = Math.pow(value, 3); break; - case "Ping Pong": - noises[id].SetFractalType(FastNoiseLite.FractalType.PingPong); + case "Root": + value = Math.sqrt(Math.abs(value)); break; default: - noises[id].SetFractalType(FastNoiseLite.FractalType.None); break; } - noises[id].SetFrequency(frequency); - noises[id].SetFractalOctaves(octaves); - } - - getNoise(args) { - const id = Cast.toString(args.ID); - const easing = Cast.toString(args.EASING); - const inverted = Cast.toBoolean(args.INVERTED); - if (id in noises) { - let value = noises[id].GetNoise(args.X, args.Y, args.Z); - value = inverted ? -value : value; - value = (value + 1) / 2; - switch (easing) { - case "Linear": - break; - case "Squared": - value = Math.pow(value, 2); - break; - case "Cubed": - value = Math.pow(value, 3); - break; - case "Root": - value = Math.sqrt(Math.abs(value)); - break; - default: - break; - } - value = value * 2 - 1; - return value; - } - console.log("ISSUE"); - return 0; + value = value * 2 - 1; + return value; } + console.log("ISSUE"); + return 0; } + } -// MIT License -// -// Copyright(c) 2023 Jordan Peck (jordan.me2@gmail.com) -// Copyright(c) 2023 Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files(the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions : -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// - - class FastNoiseLite { - static NoiseType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2S: "OpenSimplex2S", - Cellular: "Cellular", - Perlin: "Perlin", - ValueCubic: "ValueCubic", - Value: "Value", - }); - static RotationType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", - }); - static FractalType = Object.freeze({ - None: "None", - FBm: "FBm", - Ridged: "Ridged", - PingPong: "PingPong", - DomainWarpProgressive: "DomainWarpProgressive", - DomainWarpIndependent: "DomainWarpIndependent", - }); - static CellularDistanceFunction = Object.freeze({ - Euclidean: "Euclidean", - EuclideanSq: "EuclideanSq", - Manhattan: "Manhattan", - Hybrid: "Hybrid", - }); - static CellularReturnType = Object.freeze({ - CellValue: "CellValue", - Distance: "Distance", - Distance2: "Distance2", - Distance2Add: "Distance2Add", - Distance2Sub: "Distance2Sub", - Distance2Mul: "Distance2Mul", - Distance2Div: "Distance2Div", - }); - static DomainWarpType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2Reduced: "OpenSimplex2Reduced", - BasicGrid: "BasicGrid", - }); - static TransformType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", - DefaultOpenSimplex2: "DefaultOpenSimplex2", - }); - - /* Private */ - _Seed = 1337; - _Frequency = 0.01; - _NoiseType = FastNoiseLite.NoiseType.OpenSimplex2; - _RotationType3D = FastNoiseLite.RotationType3D.None; - _TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - _DomainWarpAmp = 1.0; - - _FractalType = FastNoiseLite.FractalType.None; - _Octaves = 3; - _Lacunarity = 2.0; - _Gain = 0.5; - _WeightedStrength = 0.0; - _PingPongStrength = 2.0; - - _FractalBounding = 1 / 1.75; - - _CellularDistanceFunction = - FastNoiseLite.CellularDistanceFunction.EuclideanSq; - _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; - _CellularJitterModifier = 1.0; - - _DomainWarpType = FastNoiseLite.DomainWarpType.OpenSimplex2; - _WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - - /** - * @description Create new FastNoiseLite object with optional seed - * @param {number} [seed] - * @constructor - */ - constructor(seed) { - if (seed !== undefined) { - this._Seed = seed; - } - } - - /** - * @description Sets seed used for all noise types - * @remarks Default: 1337 - * @default 1337 - * @param {number} seed - */ - SetSeed(seed) { + // MIT License + // + // Copyright(c) 2023 Jordan Peck (jordan.me2@gmail.com) + // Copyright(c) 2023 Contributors + // + // Permission is hereby granted, free of charge, to any person obtaining a copy + // of this software and associated documentation files(the "Software"), to deal + // in the Software without restriction, including without limitation the rights + // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell + // copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions : + // + // The above copyright notice and this permission notice shall be included in all + // copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + // SOFTWARE. + // + + class FastNoiseLite { + static NoiseType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2S: "OpenSimplex2S", + Cellular: "Cellular", + Perlin: "Perlin", + ValueCubic: "ValueCubic", + Value: "Value", + }); + static RotationType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + }); + static FractalType = Object.freeze({ + None: "None", + FBm: "FBm", + Ridged: "Ridged", + PingPong: "PingPong", + DomainWarpProgressive: "DomainWarpProgressive", + DomainWarpIndependent: "DomainWarpIndependent", + }); + static CellularDistanceFunction = Object.freeze({ + Euclidean: "Euclidean", + EuclideanSq: "EuclideanSq", + Manhattan: "Manhattan", + Hybrid: "Hybrid", + }); + static CellularReturnType = Object.freeze({ + CellValue: "CellValue", + Distance: "Distance", + Distance2: "Distance2", + Distance2Add: "Distance2Add", + Distance2Sub: "Distance2Sub", + Distance2Mul: "Distance2Mul", + Distance2Div: "Distance2Div", + }); + static DomainWarpType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2Reduced: "OpenSimplex2Reduced", + BasicGrid: "BasicGrid", + }); + static TransformType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + DefaultOpenSimplex2: "DefaultOpenSimplex2", + }); + + /* Private */ + _Seed = 1337; + _Frequency = 0.01; + _NoiseType = FastNoiseLite.NoiseType.OpenSimplex2; + _RotationType3D = FastNoiseLite.RotationType3D.None; + _TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + _DomainWarpAmp = 1.0; + + _FractalType = FastNoiseLite.FractalType.None; + _Octaves = 3; + _Lacunarity = 2.0; + _Gain = 0.5; + _WeightedStrength = 0.0; + _PingPongStrength = 2.0; + + _FractalBounding = 1 / 1.75; + + _CellularDistanceFunction = + FastNoiseLite.CellularDistanceFunction.EuclideanSq; + _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; + _CellularJitterModifier = 1.0; + + _DomainWarpType = FastNoiseLite.DomainWarpType.OpenSimplex2; + _WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + + /** + * @description Create new FastNoiseLite object with optional seed + * @param {number} [seed] + * @constructor + */ + constructor(seed) { + if (seed !== undefined) { this._Seed = seed; } - - /** - * @description Sets frequency for all noise types - * @remarks Default: 0.01 - * @default 0.01 - * @param {number} frequency - */ - SetFrequency(frequency) { - this._Frequency = frequency; - } - - /** - * @description Sets noise algorithm used for GetNoise(...) - * @remarks Default: OpenSimplex2 - * @default FastNoiseLite.NoiseType.OpenSimplex2 - * @param {FastNoiseLite.NoiseType} noiseType - */ - SetNoiseType(noiseType) { - this._NoiseType = noiseType; - this._UpdateTransformType3D(); - } - - /** - * @description Sets domain rotation type for 3D Noise and 3D DomainWarp. - * @description Can aid in reducing directional artifacts when sampling a 2D plane in 3D - * @remarks Default: None - * @default FastNoiseLite.RotationType3D.None - * @param {FastNoiseLite.RotationType3D} rotationType3D - */ - SetRotationType3D(rotationType3D) { - this._RotationType3D = rotationType3D; - this._UpdateTransformType3D(); - this._UpdateWarpTransformType3D(); - } - - /** - * @description Sets method for combining octaves in all fractal noise types - * @remarks Default: None - * @default FastNoiseLite.FractalType.None - * @param {FastNoiseLite.FractalType} fractalType - */ - SetFractalType(fractalType) { - this._FractalType = fractalType; - } - - /** - * @description Sets octave count for all fractal noise types - * @remarks Default: 3 - * @default 3 - * @param {number} octaves - */ - SetFractalOctaves(octaves) { - this._Octaves = octaves; - this._CalculateFractalBounding(); - } - - /** - * @description Sets octave lacunarity for all fractal noise types - * @remarks Default: 2.0 - * @default 2.0 - * @param {number} lacunarity - */ - SetFractalLacunarity(lacunarity) { - this._Lacunarity = lacunarity; - } - - /** - * @description Sets octave gain for all fractal noise types - * @remarks Default: 0.5 - * @default 0.5 - * @param {number} gain - */ - SetFractalGain(gain) { - this._Gain = gain; - this._CalculateFractalBounding(); - } - - /** - * @description Sets octave weighting for all none DomainWarp fratal types - * @remarks Default: 0.0 | Keep between 0...1 to maintain -1...1 output bounding - * @default 0.5 - * @param {number} weightedStrength - */ - SetFractalWeightedStrength(weightedStrength) { - this._WeightedStrength = weightedStrength; - } - - /** - * @description Sets strength of the fractal ping pong effect - * @remarks Default: 2.0 - * @default 2.0 - * @param {number} pingPongStrength - */ - SetFractalPingPongStrength(pingPongStrength) { - this._PingPongStrength = pingPongStrength; - } - - /** - * @description Sets distance function used in cellular noise calculations - * @remarks Default: EuclideanSq - * @default FastNoiseLite.CellularDistanceFunction.EuclideanSq - * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction - */ - SetCellularDistanceFunction(cellularDistanceFunction) { - this._CellularDistanceFunction = cellularDistanceFunction; - } - - /** - * @description Sets return type from cellular noise calculations - * @remarks Default: Distance - * @default FastNoiseLite.CellularReturnType.Distance - * @param {FastNoiseLite.CellularReturnType} cellularReturnType - */ - SetCellularReturnType(cellularReturnType) { - this._CellularReturnType = cellularReturnType; - } - - /** - * @description Sets the maximum distance a cellular point can move from it's grid position - * @remarks Default: 1.0 - * @default 1.0 - * @param {number} cellularJitter - */ - SetCellularJitter(cellularJitter) { - this._CellularJitterModifier = cellularJitter; - } - - /** - * @description Sets the warp algorithm when using DomainWarp(...) - * @remarks Default: OpenSimplex2 - * @default FastNoiseLite.DomainWarpType.OpenSimplex2 - * @param {FastNoiseLite.DomainWarpType} domainWarpType - */ - SetDomainWarpType(domainWarpType) { - this._DomainWarpType = domainWarpType; - this._UpdateWarpTransformType3D(); - } - - /** - * @description Sets the maximum warp distance from original position when using DomainWarp(...) - * @remarks Default: 1.0 - * @default 1.0 - * @param {number} domainWarpAmp - */ - SetDomainWarpAmp(domainWarpAmp) { - this._DomainWarpAmp = domainWarpAmp; - } - + } + + /** + * @description Sets seed used for all noise types + * @remarks Default: 1337 + * @default 1337 + * @param {number} seed + */ + SetSeed(seed) { + this._Seed = seed; + } + + /** + * @description Sets frequency for all noise types + * @remarks Default: 0.01 + * @default 0.01 + * @param {number} frequency + */ + SetFrequency(frequency) { + this._Frequency = frequency; + } + + /** + * @description Sets noise algorithm used for GetNoise(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.NoiseType.OpenSimplex2 + * @param {FastNoiseLite.NoiseType} noiseType + */ + SetNoiseType(noiseType) { + this._NoiseType = noiseType; + this._UpdateTransformType3D(); + } + + /** + * @description Sets domain rotation type for 3D Noise and 3D DomainWarp. + * @description Can aid in reducing directional artifacts when sampling a 2D plane in 3D + * @remarks Default: None + * @default FastNoiseLite.RotationType3D.None + * @param {FastNoiseLite.RotationType3D} rotationType3D + */ + SetRotationType3D(rotationType3D) { + this._RotationType3D = rotationType3D; + this._UpdateTransformType3D(); + this._UpdateWarpTransformType3D(); + } + + /** + * @description Sets method for combining octaves in all fractal noise types + * @remarks Default: None + * @default FastNoiseLite.FractalType.None + * @param {FastNoiseLite.FractalType} fractalType + */ + SetFractalType(fractalType) { + this._FractalType = fractalType; + } + + /** + * @description Sets octave count for all fractal noise types + * @remarks Default: 3 + * @default 3 + * @param {number} octaves + */ + SetFractalOctaves(octaves) { + this._Octaves = octaves; + this._CalculateFractalBounding(); + } + + /** + * @description Sets octave lacunarity for all fractal noise types + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} lacunarity + */ + SetFractalLacunarity(lacunarity) { + this._Lacunarity = lacunarity; + } + + /** + * @description Sets octave gain for all fractal noise types + * @remarks Default: 0.5 + * @default 0.5 + * @param {number} gain + */ + SetFractalGain(gain) { + this._Gain = gain; + this._CalculateFractalBounding(); + } + + /** + * @description Sets octave weighting for all none DomainWarp fratal types + * @remarks Default: 0.0 | Keep between 0...1 to maintain -1...1 output bounding + * @default 0.5 + * @param {number} weightedStrength + */ + SetFractalWeightedStrength(weightedStrength) { + this._WeightedStrength = weightedStrength; + } + + /** + * @description Sets strength of the fractal ping pong effect + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} pingPongStrength + */ + SetFractalPingPongStrength(pingPongStrength) { + this._PingPongStrength = pingPongStrength; + } + + /** + * @description Sets distance function used in cellular noise calculations + * @remarks Default: EuclideanSq + * @default FastNoiseLite.CellularDistanceFunction.EuclideanSq + * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction + */ + SetCellularDistanceFunction(cellularDistanceFunction) { + this._CellularDistanceFunction = cellularDistanceFunction; + } + + /** + * @description Sets return type from cellular noise calculations + * @remarks Default: Distance + * @default FastNoiseLite.CellularReturnType.Distance + * @param {FastNoiseLite.CellularReturnType} cellularReturnType + */ + SetCellularReturnType(cellularReturnType) { + this._CellularReturnType = cellularReturnType; + } + + /** + * @description Sets the maximum distance a cellular point can move from it's grid position + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} cellularJitter + */ + SetCellularJitter(cellularJitter) { + this._CellularJitterModifier = cellularJitter; + } + + /** + * @description Sets the warp algorithm when using DomainWarp(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.DomainWarpType.OpenSimplex2 + * @param {FastNoiseLite.DomainWarpType} domainWarpType + */ + SetDomainWarpType(domainWarpType) { + this._DomainWarpType = domainWarpType; + this._UpdateWarpTransformType3D(); + } + + /** + * @description Sets the maximum warp distance from original position when using DomainWarp(...) + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} domainWarpAmp + */ + SetDomainWarpAmp(domainWarpAmp) { + this._DomainWarpAmp = domainWarpAmp; + } + + /** + * @description 2D/3D noise at given position using current settings + * @param {number} x X coordinate + * @param {number} y Y coordinate + * @param {number} [z] Z coordinate + * @return {number} Noise output bounded between -1...1 + */ + GetNoise(x, y, z) { /** - * @description 2D/3D noise at given position using current settings - * @param {number} x X coordinate - * @param {number} y Y coordinate - * @param {number} [z] Z coordinate + * @description 2D noise at given position using current settings + * @param {number} x + * @param {number} y * @return {number} Noise output bounded between -1...1 */ - GetNoise(x, y, z) { - /** - * @description 2D noise at given position using current settings - * @param {number} x - * @param {number} y - * @return {number} Noise output bounded between -1...1 - */ - let R2 = (x, y) => { - x *= this._Frequency; - y *= this._Frequency; - - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (x + y) * F2; - x += t; - y += t; - break; - } - default: - break; - } - - switch (this._FractalType) { - default: - return this._GenNoiseSingleR2(this._Seed, x, y); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR2(x, y); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR2(x, y); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR2(x, y); - } - }; - - /** - * @description 3D noise at given position using current settings - * @param {number} x - * @param {number} y - * @param {number} z - * @return {number} Noise output bounded between -1...1 - */ - let R3 = (x, y, z) => { - x *= this._Frequency; - y *= this._Frequency; - z *= this._Frequency; - - switch (this._TransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: { - let xy = x + y; - let s2 = xy * -0.211324865405187; - z *= 0.577350269189626; - x += s2 - z; - y += s2 - z; - z += xy * 0.577350269189626; - break; - } - case FastNoiseLite.TransformType3D.ImproveXZPlanes: { - let xz = x + z; - let s2 = xz * -0.211324865405187; - y *= 0.577350269189626; - x += s2 - y; - z += s2 - y; - y += xz * 0.577350269189626; - break; - } - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { - const R3 = 2.0 / 3.0; - let r = (x + y + z) * R3; - x = r - x; - y = r - y; - z = r - z; - break; - } - default: - break; - } - - switch (this._FractalType) { - default: - return this._GenNoiseSingleR3(this._Seed, x, y, z); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR3(x, y, z); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR3(x, y, z); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR3(x, y, z); + let R2 = (x, y) => { + x *= this._Frequency; + y *= this._Frequency; + + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (x + y) * F2; + x += t; + y += t; + break; } - }; - - if (arguments.length === 2) { - return R2(x, y); + default: + break; } - - if (arguments.length === 3) { - return R3(x, y, z); + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR2(this._Seed, x, y); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR2(x, y); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR2(x, y); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR2(x, y); } - } - + }; + /** - * @description 2D/3D warps the input position using current domain warp settings - * @param {Vector2|Vector3} coord + * @description 3D noise at given position using current settings + * @param {number} x + * @param {number} y + * @param {number} z + * @return {number} Noise output bounded between -1...1 */ - DomainWrap(coord) { - switch (this._FractalType) { - default: - this._DomainWarpSingle(coord); + let R3 = (x, y, z) => { + x *= this._Frequency; + y *= this._Frequency; + z *= this._Frequency; + + switch (this._TransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: { + let xy = x + y; + let s2 = xy * -0.211324865405187; + z *= 0.577350269189626; + x += s2 - z; + y += s2 - z; + z += xy * 0.577350269189626; break; - case FastNoiseLite.FractalType.DomainWarpProgressive: - this._DomainWarpFractalProgressive(coord); + } + case FastNoiseLite.TransformType3D.ImproveXZPlanes: { + let xz = x + z; + let s2 = xz * -0.211324865405187; + y *= 0.577350269189626; + x += s2 - y; + z += s2 - y; + y += xz * 0.577350269189626; + break; + } + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + const R3 = 2.0 / 3.0; + let r = (x + y + z) * R3; + x = r - x; + y = r - y; + z = r - z; break; - case FastNoiseLite.FractalType.DomainWarpIndependent: - this._DomainWarpFractalIndependent(coord); + } + default: break; } + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR3(this._Seed, x, y, z); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR3(x, y, z); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR3(x, y, z); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR3(x, y, z); + } + }; + + if (arguments.length === 2) { + return R2(x, y); + } + + if (arguments.length === 3) { + return R3(x, y, z); } - - // prettier-ignore - _Gradients2D = [ + } + + /** + * @description 2D/3D warps the input position using current domain warp settings + * @param {Vector2|Vector3} coord + */ + DomainWrap(coord) { + switch (this._FractalType) { + default: + this._DomainWarpSingle(coord); + break; + case FastNoiseLite.FractalType.DomainWarpProgressive: + this._DomainWarpFractalProgressive(coord); + break; + case FastNoiseLite.FractalType.DomainWarpIndependent: + this._DomainWarpFractalIndependent(coord); + break; + } + } + + // prettier-ignore + _Gradients2D = [ 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, @@ -635,9 +636,9 @@ 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, ]; - - // prettier-ignore - _RandVecs2D = [ + + // prettier-ignore + _RandVecs2D = [ -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, @@ -671,9 +672,9 @@ 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, ]; - - // prettier-ignore - _Gradients3D = [ + + // prettier-ignore + _Gradients3D = [ 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, @@ -691,9 +692,9 @@ 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 ]; - - // prettier-ignore - _RandVecs3D = [ + + // prettier-ignore + _RandVecs3D = [ -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, @@ -727,1950 +728,2038 @@ 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 ]; - - _PrimeX = 501125321; - _PrimeY = 1136930381; - _PrimeZ = 1720413743; - - /** - * @private - * @param {number} a - * @param {number} b - * @param {number} t - * @returns {number} - */ - static _Lerp(a, b, t) { - return a + t * (b - a); + + _PrimeX = 501125321; + _PrimeY = 1136930381; + _PrimeZ = 1720413743; + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} t + * @returns {number} + */ + static _Lerp(a, b, t) { + return a + t * (b - a); + } + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _InterpHermite(t) { + return t * t * (3 - 2 * t); + } + + /** + * @private + * @param t + * @returns {number} + */ + static _InterpQuintic(t) { + return t * t * t * (t * (t * 6 - 15) + 10); + } + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} c + * @param {number} d + * @param {number} t + * @returns {number} + */ + static _CubicLerp(a, b, c, d, t) { + const p = d - c - (a - b); + return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; + } + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _PingPong(t) { + t -= Math.trunc(t * 0.5) * 2; + return t < 1 ? t : 2 - t; + } + + /** + * @private + */ + _CalculateFractalBounding() { + let gain = Math.abs(this._Gain); + let amp = gain; + let ampFractal = 1.0; + for (let i = 1; i < this._Octaves; i++) { + ampFractal += amp; + amp *= gain; + } + this._FractalBounding = 1 / ampFractal; + } + + /** + * @private + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @returns {number} + */ + _HashR2(seed, xPrimed, yPrimed) { + let hash = seed ^ xPrimed ^ yPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _HashR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; + } + + /** + * @private + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @returns {number} + */ + _ValCoordR2(seed, xPrimed, yPrimed) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _ValCoordR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} xd + * @param {number} yd + * @returns {number} + */ + _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + hash ^= hash >> 15; + hash &= 127 << 1; + + let xg = this._Gradients2D[hash]; + let yg = this._Gradients2D[hash | 1]; + + return xd * xg + yd * yg; + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @param {number} xd + * @param {number} yd + * @param {number} zd + * @returns {number} + */ + _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + hash ^= hash >> 15; + hash &= 63 << 2; + + let xg = this._Gradients3D[hash]; + let yg = this._Gradients3D[hash | 1]; + let zg = this._Gradients3D[hash | 2]; + + return xd * xg + yd * yg + zd * zg; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenNoiseSingleR2(seed, x, y) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R2(seed, x, y); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR2(seed, x, y); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR2(seed, x, y); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR2(seed, x, y); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR2(seed, x, y); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR2(seed, x, y); + default: + return 0; } - - /** - * @private - * @param {number} t - * @returns {number} - */ - static _InterpHermite(t) { - return t * t * (3 - 2 * t); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenNoiseSingleR3(seed, x, y, z) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R3(seed, x, y, z); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR3(seed, x, y, z); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR3(seed, x, y, z); + default: + return 0; } - - /** - * @private - * @param t - * @returns {number} - */ - static _InterpQuintic(t) { - return t * t * t * (t * (t * 6 - 15) + 10); + } + + /** + * @private + */ + _UpdateTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: + this._TransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; + default: + this._TransformType3D = FastNoiseLite.TransformType3D.None; + break; + } + break; } - - /** - * @private - * @param {number} a - * @param {number} b - * @param {number} c - * @param {number} d - * @param {number} t - * @returns {number} - */ - static _CubicLerp(a, b, c, d, t) { - const p = d - c - (a - b); - return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; - } - - /** - * @private - * @param {number} t - * @returns {number} - */ - static _PingPong(t) { - t -= Math.trunc(t * 0.5) * 2; - return t < 1 ? t : 2 - t; - } - - /** - * @private - */ - _CalculateFractalBounding() { - let gain = Math.abs(this._Gain); - let amp = gain; - let ampFractal = 1.0; - for (let i = 1; i < this._Octaves; i++) { - ampFractal += amp; - amp *= gain; - } - this._FractalBounding = 1 / ampFractal; - } - - /** - * @private - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @returns {number} - */ - _HashR2(seed, xPrimed, yPrimed) { - let hash = seed ^ xPrimed ^ yPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @returns {number} - */ - _HashR3(seed, xPrimed, yPrimed, zPrimed) { - let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; - } - - /** - * @private - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @returns {number} - */ - _ValCoordR2(seed, xPrimed, yPrimed) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @returns {number} - */ - _ValCoordR3(seed, xPrimed, yPrimed, zPrimed) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} xd - * @param {number} yd - * @returns {number} - */ - _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - hash ^= hash >> 15; - hash &= 127 << 1; - - let xg = this._Gradients2D[hash]; - let yg = this._Gradients2D[hash | 1]; - - return xd * xg + yd * yg; - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @param {number} xd - * @param {number} yd - * @param {number} zd - * @returns {number} - */ - _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - hash ^= hash >> 15; - hash &= 63 << 2; - - let xg = this._Gradients3D[hash]; - let yg = this._Gradients3D[hash | 1]; - let zg = this._Gradients3D[hash | 2]; - - return xd * xg + yd * yg + zd * zg; + } + + /** + * @private + */ + _UpdateWarpTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; + default: + this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; + break; + } + break; } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenNoiseSingleR2(seed, x, y) { - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R2(seed, x, y); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR2(seed, x, y); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR2(seed, x, y); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR2(seed, x, y); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR2(seed, x, y); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR2(seed, x, y); - default: - return 0; - } + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalFBmR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR2(seed++, x, y); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + Math.min(noise + 1, 2) * 0.5, + this._WeightedStrength + ); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenNoiseSingleR3(seed, x, y, z) { - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R3(seed, x, y, z); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR3(seed, x, y, z); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR3(seed, x, y, z); - default: - return 0; - } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalFBmR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR3(seed++, x, y, z); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + (noise + 1) * 0.5, + this._WeightedStrength + ); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; } - - /** - * @private - */ - _UpdateTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; - default: - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: - this._TransformType3D = - FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - break; - default: - this._TransformType3D = FastNoiseLite.TransformType3D.None; - break; - } - break; - } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalRidgedR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; } - - /** - * @private - */ - _UpdateWarpTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; - default: - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - break; - default: - this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; - break; - } - break; - } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalRidgedR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalFBmR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR2(seed++, x, y); - sum += noise * amp; - amp *= FastNoiseLite._Lerp( - 1.0, - Math.min(noise + 1, 2) * 0.5, - this._WeightedStrength - ); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalPingPongR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalFBmR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR3(seed++, x, y, z); - sum += noise * amp; - amp *= FastNoiseLite._Lerp( - 1.0, - (noise + 1) * 0.5, - this._WeightedStrength - ); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalPingPongR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalRidgedR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + return sum; + } + + /** + * + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleOpenSimplex2R2(seed, x, y) { + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let n0, n1, n2; + + let a = 0.5 - x0 * x0 - y0 * y0; + + if (a <= 0) { + n0 = 0; + } else { + n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalRidgedR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + + if (c <= 0) { + n2 = 0; + } else { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + n2 = + c * + c * + (c * c) * + this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalPingPongR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = + b * + b * + (b * b) * + this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalPingPongR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; + } else { + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = + b * + b * + (b * b) * + this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); } - return sum; } - - /** - * - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleOpenSimplex2R2(seed, x, y) { - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let n0, n1, n2; - - let a = 0.5 - x0 * x0 - y0 * y0; - - if (a <= 0) { - n0 = 0; - } else { - n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); + return (n0 + n1 + n2) * 99.83685446303647; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleOpenSimplex2R3(seed, x, y, z) { + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let yNSign = Math.trunc((-1.0 - y0) | 1); + let xNSign = Math.trunc((-1.0 - x0) | 1); + let zNSign = Math.trunc((-1.0 - z0) | 1); + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let value = 0; + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + + for (let l = 0; ; l++) { + if (a > 0) { + value += + a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); } - - let c = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - - if (c <= 0) { - n2 = 0; + + if (ax0 >= ay0 && ax0 >= az0) { + let b = a + ax0 + ax0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i - xNSign * this._PrimeX, + j, + k, + x0 + xNSign, + y0, + z0 + ); + } + } else if (ay0 > ax0 && ay0 >= az0) { + let b = a + ay0 + ay0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j - yNSign * this._PrimeY, + k, + x0, + y0 + yNSign, + z0 + ); + } } else { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - n2 = - c * - c * - (c * c) * - this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); - } - - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = + let b = a + az0 + az0; + if (b > 1) { + b -= 1; + value += b * b * (b * b) * - this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); + this._GradCoordR3( + seed, + i, + j, + k - zNSign * this._PrimeZ, + x0, + y0, + z0 + zNSign + ); + } + } + + if (l === 1) { + break; + } + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed = ~seed; + } + return value * 32.69428253173828125; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleOpenSimplex2SR2(seed, x, y) { + // 2D OpenSimplex2S case is a modified 2D simplex noise. + + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + /* + * --- Skew moved to TransformNoiseCoordinate method --- + * final FNLfloat F2 = 0.5f * (SQRT3 - 1); + * FNLfloat s = (x + y) * F2; + * x += s; y += s; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + let i1 = i + this._PrimeX; + let j1 = j + this._PrimeY; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; + let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); + let a1 = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); + let x1 = x0 - (1 - 2 * G2); + let y1 = y0 - (1 - 2 * G2); + value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); + + // Nested conditionals were faster than compact bit logic/arithmetic. + let xmyi = xi - yi; + if (t > G2) { + if (xi + xmyi > 1) { + let x2 = x0 + (3 * G2 - 2); + let y2 = y0 + (3 * G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2( + seed, + i + (this._PrimeX << 1), + j + this._PrimeY, + x2, + y2 + ); } } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = - b * - b * - (b * b) * - this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); } } - return (n0 + n1 + n2) * 99.83685446303647; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleOpenSimplex2R3(seed, x, y, z) { - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let yNSign = Math.trunc((-1.0 - y0) | 1); - let xNSign = Math.trunc((-1.0 - x0) | 1); - let zNSign = Math.trunc((-1.0 - z0) | 1); - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let value = 0; - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - - for (let l = 0; ; l++) { - if (a > 0) { + + if (yi - xmyi > 1) { + let x3 = x0 + (3 * G2 - 1); + let y3 = y0 + (3 * G2 - 2); + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { value += - a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); - } - - if (ax0 >= ay0 && ax0 >= az0) { - let b = a + ax0 + ax0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i - xNSign * this._PrimeX, - j, - k, - x0 + xNSign, - y0, - z0 - ); - } - } else if (ay0 > ax0 && ay0 >= az0) { - let b = a + ay0 + ay0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i, - j - yNSign * this._PrimeY, - k, - x0, - y0 + yNSign, - z0 - ); - } - } else { - let b = a + az0 + az0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i, - j, - k - zNSign * this._PrimeZ, - x0, - y0, - z0 + zNSign - ); - } + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2( + seed, + i + this._PrimeX, + j + (this._PrimeY << 1), + x3, + y3 + ); } - - if (l === 1) { - break; + } else { + let x3 = x0 + (G2 - 1); + let y3 = y0 + G2; + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); } - - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; - - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; - - a += 0.75 - ax0 - (ay0 + az0); - - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; - - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; - - seed = ~seed; } - return value * 32.69428253173828125; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleOpenSimplex2SR2(seed, x, y) { - // 2D OpenSimplex2S case is a modified 2D simplex noise. - - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - /* - * --- Skew moved to TransformNoiseCoordinate method --- - * final FNLfloat F2 = 0.5f * (SQRT3 - 1); - * FNLfloat s = (x + y) * F2; - * x += s; y += s; - */ - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - let i1 = i + this._PrimeX; - let j1 = j + this._PrimeY; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; - let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); - let a1 = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); - let x1 = x0 - (1 - 2 * G2); - let y1 = y0 - (1 - 2 * G2); - value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); - - // Nested conditionals were faster than compact bit logic/arithmetic. - let xmyi = xi - yi; - if (t > G2) { - if (xi + xmyi > 1) { - let x2 = x0 + (3 * G2 - 2); - let y2 = y0 + (3 * G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2( - seed, - i + (this._PrimeX << 1), - j + this._PrimeY, - x2, - y2 - ); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } - } - - if (yi - xmyi > 1) { - let x3 = x0 + (3 * G2 - 1); - let y3 = y0 + (3 * G2 - 2); - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR2( - seed, - i + this._PrimeX, - j + (this._PrimeY << 1), - x3, - y3 - ); - } - } else { - let x3 = x0 + (G2 - 1); - let y3 = y0 + G2; - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); - } + } else { + if (xi + xmyi < 0) { + let x2 = x0 + (1 - G2); + let y2 = y0 - G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); } } else { - if (xi + xmyi < 0) { - let x2 = x0 + (1 - G2); - let y2 = y0 - G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); - } - } else { - let x2 = x0 + (G2 - 1); - let y2 = y0 + G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); - } + let x2 = x0 + (G2 - 1); + let y2 = y0 + G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); } - - if (yi < xmyi) { - let x2 = x0 - G2; - let y2 = y0 - (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } + } + + if (yi < xmyi) { + let x2 = x0 - G2; + let y2 = y0 - (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); } } - - return value * 18.24196194486065; } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} + + return value * 18.24196194486065; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleOpenSimplex2SR3(seed, x, y, z) { + // 3D OpenSimplex2S case uses two offset rotated cube grids. + + /* + * --- Rotation moved to TransformNoiseCoordinate method --- + * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); + * FNLfloat r = (x + y + z) * R3; // Rotation, not skew + * x = r - x; y = r - y; z = r - z; */ - _SingleOpenSimplex2SR3(seed, x, y, z) { - // 3D OpenSimplex2S case uses two offset rotated cube grids. - - /* - * --- Rotation moved to TransformNoiseCoordinate method --- - * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); - * FNLfloat r = (x + y + z) * R3; // Rotation, not skew - * x = r - x; y = r - y; z = r - z; - */ - - let i = Math.floor(x); - let j = Math.floor(y); - let k = Math.floor(z); - let xi = x - i; - let yi = y - j; - let zi = z - k; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - let seed2 = seed + 1293373; - - let xNMask = Math.trunc(-0.5 - xi); - let yNMask = Math.trunc(-0.5 - yi); - let zNMask = Math.trunc(-0.5 - zi); - - let x0 = xi + xNMask; - let y0 = yi + yNMask; - let z0 = zi + zNMask; - let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; - let value = - a0 * - a0 * - (a0 * a0) * + + let i = Math.floor(x); + let j = Math.floor(y); + let k = Math.floor(z); + let xi = x - i; + let yi = y - j; + let zi = z - k; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + let seed2 = seed + 1293373; + + let xNMask = Math.trunc(-0.5 - xi); + let yNMask = Math.trunc(-0.5 - yi); + let zNMask = Math.trunc(-0.5 - zi); + + let x0 = xi + xNMask; + let y0 = yi + yNMask; + let z0 = zi + zNMask; + let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; + let value = + a0 * + a0 * + (a0 * a0) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x0, + y0, + z0 + ); + + let x1 = xi - 0.5; + let y1 = yi - 0.5; + let z1 = zi - 0.5; + let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; + value += + a1 * + a1 * + (a1 * a1) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + this._PrimeZ, + x1, + y1, + z1 + ); + + let xAFlipMask0 = ((xNMask | 1) << 1) * x1; + let yAFlipMask0 = ((yNMask | 1) << 1) * y1; + let zAFlipMask0 = ((zNMask | 1) << 1) * z1; + let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; + let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; + let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; + + let skip5 = false; + let a2 = xAFlipMask0 + a0; + if (a2 > 0) { + let x2 = x0 - (xNMask | 1); + value += + a2 * + a2 * + (a2 * a2) * this._GradCoordR3( seed, - i + (xNMask & this._PrimeX), + i + (~xNMask & this._PrimeX), j + (yNMask & this._PrimeY), k + (zNMask & this._PrimeZ), - x0, + x2, y0, z0 ); - - let x1 = xi - 0.5; - let y1 = yi - 0.5; - let z1 = zi - 0.5; - let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; + } else { + let a3 = yAFlipMask0 + zAFlipMask0 + a0; + + if (a3 > 0) { + let x3 = x0; + let y3 = y0 - (yNMask | 1); + let z3 = z0 - (zNMask | 1); + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x3, + y3, + z3 + ); + } + + let a4 = xAFlipMask1 + a1; + if (a4 > 0) { + let x4 = (xNMask | 1) + x1; + value += + a4 * + a4 * + (a4 * a4) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + this._PrimeZ, + x4, + y1, + z1 + ); + skip5 = true; + } + } + + let skip9 = false; + let a6 = yAFlipMask0 + a0; + if (a6 > 0) { + let x6 = x0; + let y6 = y0 - (yNMask | 1); value += - a1 * - a1 * - (a1 * a1) * + a6 * + a6 * + (a6 * a6) * this._GradCoordR3( - seed2, - i + this._PrimeX, - j + this._PrimeY, - k + this._PrimeZ, - x1, - y1, - z1 + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x6, + y6, + z0 ); - - let xAFlipMask0 = ((xNMask | 1) << 1) * x1; - let yAFlipMask0 = ((yNMask | 1) << 1) * y1; - let zAFlipMask0 = ((zNMask | 1) << 1) * z1; - let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; - let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; - let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; - - let skip5 = false; - let a2 = xAFlipMask0 + a0; - if (a2 > 0) { - let x2 = x0 - (xNMask | 1); + } else { + let a7 = xAFlipMask0 + zAFlipMask0 + a0; + if (a7 > 0) { + let x7 = x0 - (xNMask | 1); + let y7 = y0; + let z7 = z0 - (zNMask | 1); value += - a2 * - a2 * - (a2 * a2) * + a7 * + a7 * + (a7 * a7) * this._GradCoordR3( seed, i + (~xNMask & this._PrimeX), j + (yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x2, - y0, - z0 + k + (~zNMask & this._PrimeZ), + x7, + y7, + z7 ); - } else { - let a3 = yAFlipMask0 + zAFlipMask0 + a0; - - if (a3 > 0) { - let x3 = x0; - let y3 = y0 - (yNMask | 1); - let z3 = z0 - (zNMask | 1); - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x3, - y3, - z3 - ); - } - - let a4 = xAFlipMask1 + a1; - if (a4 > 0) { - let x4 = (xNMask | 1) + x1; - value += - a4 * - a4 * - (a4 * a4) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + this._PrimeZ, - x4, - y1, - z1 - ); - skip5 = true; - } } - - let skip9 = false; - let a6 = yAFlipMask0 + a0; - if (a6 > 0) { - let x6 = x0; - let y6 = y0 - (yNMask | 1); + + let a8 = yAFlipMask1 + a1; + if (a8 > 0) { + let x8 = x1; + let y8 = (yNMask | 1) + y1; + value += + a8 * + a8 * + (a8 * a8) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + x8, + y8, + z1 + ); + skip9 = true; + } + } + + let skipD = false; + let aA = zAFlipMask0 + a0; + if (aA > 0) { + let xA = x0; + let yA = y0; + let zA = z0 - (zNMask | 1); + value += + aA * + aA * + (aA * aA) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + xA, + yA, + zA + ); + } else { + let aB = xAFlipMask0 + yAFlipMask0 + a0; + if (aB > 0) { + let xB = x0 - (xNMask | 1); + let yB = y0 - (yNMask | 1); value += - a6 * - a6 * - (a6 * a6) * + aB * + aB * + (aB * aB) * this._GradCoordR3( seed, - i + (xNMask & this._PrimeX), + i + (~xNMask & this._PrimeX), j + (~yNMask & this._PrimeY), k + (zNMask & this._PrimeZ), - x6, - y6, + xB, + yB, z0 ); - } else { - let a7 = xAFlipMask0 + zAFlipMask0 + a0; - if (a7 > 0) { - let x7 = x0 - (xNMask | 1); - let y7 = y0; - let z7 = z0 - (zNMask | 1); - value += - a7 * - a7 * - (a7 * a7) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x7, - y7, - z7 - ); - } - - let a8 = yAFlipMask1 + a1; - if (a8 > 0) { - let x8 = x1; - let y8 = (yNMask | 1) + y1; - value += - a8 * - a8 * - (a8 * a8) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - x8, - y8, - z1 - ); - skip9 = true; - } } - - let skipD = false; - let aA = zAFlipMask0 + a0; - if (aA > 0) { - let xA = x0; - let yA = y0; - let zA = z0 - (zNMask | 1); + + let aC = zAFlipMask1 + a1; + if (aC > 0) { + let xC = x1; + let yC = y1; + let zC = (zNMask | 1) + z1; value += - aA * - aA * - (aA * aA) * + aC * + aC * + (aC * aC) * this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - xA, - yA, - zA + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + xC, + yC, + zC ); - } else { - let aB = xAFlipMask0 + yAFlipMask0 + a0; - if (aB > 0) { - let xB = x0 - (xNMask | 1); - let yB = y0 - (yNMask | 1); - value += - aB * - aB * - (aB * aB) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - xB, - yB, - z0 - ); - } - - let aC = zAFlipMask1 + a1; - if (aC > 0) { - let xC = x1; - let yC = y1; - let zC = (zNMask | 1) + z1; - value += - aC * - aC * - (aC * aC) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - xC, - yC, - zC - ); - skipD = true; - } + skipD = true; } - - if (!skip5) { - let a5 = yAFlipMask1 + zAFlipMask1 + a1; - if (a5 > 0) { - let x5 = x1; - let y5 = (yNMask | 1) + y1; - let z5 = (zNMask | 1) + z1; - value += - a5 * - a5 * - (a5 * a5) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + (zNMask & (this._PrimeZ << 1)), - x5, - y5, - z5 - ); - } + } + + if (!skip5) { + let a5 = yAFlipMask1 + zAFlipMask1 + a1; + if (a5 > 0) { + let x5 = x1; + let y5 = (yNMask | 1) + y1; + let z5 = (zNMask | 1) + z1; + value += + a5 * + a5 * + (a5 * a5) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + (zNMask & (this._PrimeZ << 1)), + x5, + y5, + z5 + ); } - - if (!skip9) { - let a9 = xAFlipMask1 + zAFlipMask1 + a1; - if (a9 > 0) { - let x9 = (xNMask | 1) + x1; - let y9 = y1; - let z9 = (zNMask | 1) + z1; - value += - a9 * - a9 * - (a9 * a9) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - x9, - y9, - z9 - ); - } + } + + if (!skip9) { + let a9 = xAFlipMask1 + zAFlipMask1 + a1; + if (a9 > 0) { + let x9 = (xNMask | 1) + x1; + let y9 = y1; + let z9 = (zNMask | 1) + z1; + value += + a9 * + a9 * + (a9 * a9) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + x9, + y9, + z9 + ); } - - if (!skipD) { - let aD = xAFlipMask1 + yAFlipMask1 + a1; - if (aD > 0) { - let xD = (xNMask | 1) + x1; - let yD = (yNMask | 1) + y1; - value += - aD * - aD * - (aD * aD) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX << 1)), - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - xD, - yD, - z1 - ); - } + } + + if (!skipD) { + let aD = xAFlipMask1 + yAFlipMask1 + a1; + if (aD > 0) { + let xD = (xNMask | 1) + x1; + let yD = (yNMask | 1) + y1; + value += + aD * + aD * + (aD * aD) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX << 1)), + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + xD, + yD, + z1 + ); } - - return value * 9.046026385208288; } - + + return value * 9.046026385208288; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleCellularR2(seed, x, y) { /** - * @private + * * @param {number} seed * @param {number} x * @param {number} y * @returns {number} */ - _SingleCellularR2(seed, x, y) { - /** - * - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - let xr = Math.round(x); - let yr = Math.round(y); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - - let closestHash = 0; - - let cellularJitter = 0.43701595 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - - switch (this._CellularDistanceFunction) { - default: - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY; - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); + let xr = Math.round(x); + let yr = Math.round(y); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + + let closestHash = 0; + + let cellularJitter = 0.43701595 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + + switch (this._CellularDistanceFunction) { + default: + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY; + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = Math.abs(vecX) + Math.abs(vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + } + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + + if ( + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue + ) { + distance1 = Math.sqrt(distance1); + } + } + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; + } + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleCellularR3(seed, x, y, z) { + let xr = Math.round(x); + let yr = Math.round(y); + let zr = Math.round(z); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + let closestHash = 0; + + let cellularJitter = 0.39614353 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + let zPrimedBase = (zr - 1) * this._PrimeZ; + + switch (this._CellularDistanceFunction) { + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); if (newDistance < distance0) { distance0 = newDistance; closestHash = hash; } - yPrimed += this._PrimeY; + zPrimed += this._PrimeZ; } - xPrimed += this._PrimeX; + yPrimed += this._PrimeY; } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = Math.abs(vecX) + Math.abs(vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); if (newDistance < distance0) { distance0 = newDistance; closestHash = hash; } - yPrimed += this._PrimeY; + zPrimed += this._PrimeZ; } - xPrimed += this._PrimeX; + yPrimed += this._PrimeY; } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + let newDistance = - Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); + Math.abs(vecX) + + Math.abs(vecY) + + Math.abs(vecZ) + + (vecX * vecX + vecY * vecY + vecZ * vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); if (newDistance < distance0) { distance0 = newDistance; closestHash = hash; } - yPrimed += this._PrimeY; + zPrimed += this._PrimeZ; } - xPrimed += this._PrimeX; + yPrimed += this._PrimeY; } - break; - } - - if ( - this._CellularDistanceFunction === - FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue - ) { - distance0 = Math.sqrt(distance0); - - if ( - this._CellularReturnType !== - FastNoiseLite.CellularReturnType.CellValue - ) { - distance1 = Math.sqrt(distance1); + xPrimed += this._PrimeX; } - } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; - } + break; + default: + break; } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleCellularR3(seed, x, y, z) { - let xr = Math.round(x); - let yr = Math.round(y); - let zr = Math.round(z); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - let closestHash = 0; - - let cellularJitter = 0.39614353 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - let zPrimedBase = (zr - 1) * this._PrimeZ; - - switch (this._CellularDistanceFunction) { - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 - ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = - Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 - ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = - Math.abs(vecX) + - Math.abs(vecY) + - Math.abs(vecZ) + - (vecX * vecX + vecY * vecY + vecZ * vecZ); - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 - ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - default: - break; - } - + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + if ( - this._CellularDistanceFunction === - FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue ) { - distance0 = Math.sqrt(distance0); - - if ( - this._CellularReturnType !== - FastNoiseLite.CellularReturnType.CellValue - ) { - distance1 = Math.sqrt(distance1); - } - } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; + distance1 = Math.sqrt(distance1); } } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SinglePerlinR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xd0 = x - x0; - let yd0 = y - y0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y0, xd0, yd0), - this._GradCoordR2(seed, x1, y0, xd1, yd0), - xs - ); - let xf1 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y1, xd0, yd1), - this._GradCoordR2(seed, x1, y1, xd1, yd1), - xs - ); - - return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SinglePerlinR3(seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xd0 = x - x0; - let yd0 = y - y0; - let zd0 = z - z0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - let zd1 = zd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - let zs = FastNoiseLite._InterpQuintic(zd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), - this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), - this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), - this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), - xs - ); - let xf11 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), - this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), - xs - ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleValueCubicR2(seed, x, y) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - - let xs = x - x1; - let ys = y - y1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - - return ( + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SinglePerlinR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xd0 = x - x0; + let yd0 = y - y0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y0, xd0, yd0), + this._GradCoordR2(seed, x1, y0, xd1, yd0), + xs + ); + let xf1 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y1, xd0, yd1), + this._GradCoordR2(seed, x1, y1, xd1, yd1), + xs + ); + + return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SinglePerlinR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xd0 = x - x0; + let yd0 = y - y0; + let zd0 = z - z0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + let zd1 = zd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + let zs = FastNoiseLite._InterpQuintic(zd0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), + this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), + xs + ); + let xf10 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), + this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), + xs + ); + let xf01 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), + this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), + xs + ); + let xf11 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), + this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), + xs + ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueCubicR2(seed, x, y) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + + let xs = x - x1; + let ys = y - y1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), + this._ValCoordR2(seed, x2, y0), + this._ValCoordR2(seed, x3, y0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), + this._ValCoordR2(seed, x2, y1), + this._ValCoordR2(seed, x3, y1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y2), + this._ValCoordR2(seed, x1, y2), + this._ValCoordR2(seed, x2, y2), + this._ValCoordR2(seed, x3, y2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y3), + this._ValCoordR2(seed, x1, y3), + this._ValCoordR2(seed, x2, y3), + this._ValCoordR2(seed, x3, y3), + xs + ), + ys + ) * + (1 / (1.5 * 1.5)) + ); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueCubicR3(seed, x, y, z) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + let z1 = Math.floor(z); + + let xs = x - x1; + let ys = y - y1; + let zs = z - z1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + z1 = Math.imul(z1, this._PrimeZ); + + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let z0 = z1 - this._PrimeZ; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let z2 = z1 + this._PrimeZ; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + let z3 = z1 + (this._PrimeZ << 1); + + return ( + FastNoiseLite._CubicLerp( FastNoiseLite._CubicLerp( FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y0), - this._ValCoordR2(seed, x1, y0), - this._ValCoordR2(seed, x2, y0), - this._ValCoordR2(seed, x3, y0), + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + this._ValCoordR3(seed, x2, y0, z0), + this._ValCoordR3(seed, x3, y0, z0), xs ), FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y1), - this._ValCoordR2(seed, x1, y1), - this._ValCoordR2(seed, x2, y1), - this._ValCoordR2(seed, x3, y1), + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + this._ValCoordR3(seed, x2, y1, z0), + this._ValCoordR3(seed, x3, y1, z0), xs ), FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y2), - this._ValCoordR2(seed, x1, y2), - this._ValCoordR2(seed, x2, y2), - this._ValCoordR2(seed, x3, y2), + this._ValCoordR3(seed, x0, y2, z0), + this._ValCoordR3(seed, x1, y2, z0), + this._ValCoordR3(seed, x2, y2, z0), + this._ValCoordR3(seed, x3, y2, z0), xs ), FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y3), - this._ValCoordR2(seed, x1, y3), - this._ValCoordR2(seed, x2, y3), - this._ValCoordR2(seed, x3, y3), + this._ValCoordR3(seed, x0, y3, z0), + this._ValCoordR3(seed, x1, y3, z0), + this._ValCoordR3(seed, x2, y3, z0), + this._ValCoordR3(seed, x3, y3, z0), xs ), ys - ) * - (1 / (1.5 * 1.5)) - ); - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleValueCubicR3(seed, x, y, z) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - let z1 = Math.floor(z); - - let xs = x - x1; - let ys = y - y1; - let zs = z - z1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - z1 = Math.imul(z1, this._PrimeZ); - - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let z0 = z1 - this._PrimeZ; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let z2 = z1 + this._PrimeZ; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - let z3 = z1 + (this._PrimeZ << 1); - - return ( + ), FastNoiseLite._CubicLerp( FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - this._ValCoordR3(seed, x2, y0, z0), - this._ValCoordR3(seed, x3, y0, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - this._ValCoordR3(seed, x2, y1, z0), - this._ValCoordR3(seed, x3, y1, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z0), - this._ValCoordR3(seed, x1, y2, z0), - this._ValCoordR3(seed, x2, y2, z0), - this._ValCoordR3(seed, x3, y2, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z0), - this._ValCoordR3(seed, x1, y3, z0), - this._ValCoordR3(seed, x2, y3, z0), - this._ValCoordR3(seed, x3, y3, z0), - xs - ), - ys + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + this._ValCoordR3(seed, x2, y0, z1), + this._ValCoordR3(seed, x3, y0, z1), + xs ), FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - this._ValCoordR3(seed, x2, y0, z1), - this._ValCoordR3(seed, x3, y0, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - this._ValCoordR3(seed, x2, y1, z1), - this._ValCoordR3(seed, x3, y1, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z1), - this._ValCoordR3(seed, x1, y2, z1), - this._ValCoordR3(seed, x2, y2, z1), - this._ValCoordR3(seed, x3, y2, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z1), - this._ValCoordR3(seed, x1, y3, z1), - this._ValCoordR3(seed, x2, y3, z1), - this._ValCoordR3(seed, x3, y3, z1), - xs - ), - ys + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + this._ValCoordR3(seed, x2, y1, z1), + this._ValCoordR3(seed, x3, y1, z1), + xs ), FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z2), - this._ValCoordR3(seed, x1, y0, z2), - this._ValCoordR3(seed, x2, y0, z2), - this._ValCoordR3(seed, x3, y0, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z2), - this._ValCoordR3(seed, x1, y1, z2), - this._ValCoordR3(seed, x2, y1, z2), - this._ValCoordR3(seed, x3, y1, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z2), - this._ValCoordR3(seed, x1, y2, z2), - this._ValCoordR3(seed, x2, y2, z2), - this._ValCoordR3(seed, x3, y2, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z2), - this._ValCoordR3(seed, x1, y3, z2), - this._ValCoordR3(seed, x2, y3, z2), - this._ValCoordR3(seed, x3, y3, z2), - xs - ), - ys + this._ValCoordR3(seed, x0, y2, z1), + this._ValCoordR3(seed, x1, y2, z1), + this._ValCoordR3(seed, x2, y2, z1), + this._ValCoordR3(seed, x3, y2, z1), + xs ), FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z3), - this._ValCoordR3(seed, x1, y0, z3), - this._ValCoordR3(seed, x2, y0, z3), - this._ValCoordR3(seed, x3, y0, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z3), - this._ValCoordR3(seed, x1, y1, z3), - this._ValCoordR3(seed, x2, y1, z3), - this._ValCoordR3(seed, x3, y1, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z3), - this._ValCoordR3(seed, x1, y2, z3), - this._ValCoordR3(seed, x2, y2, z3), - this._ValCoordR3(seed, x3, y2, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z3), - this._ValCoordR3(seed, x1, y3, z3), - this._ValCoordR3(seed, x2, y3, z3), - this._ValCoordR3(seed, x3, y3, z3), - xs - ), - ys + this._ValCoordR3(seed, x0, y3, z1), + this._ValCoordR3(seed, x1, y3, z1), + this._ValCoordR3(seed, x2, y3, z1), + this._ValCoordR3(seed, x3, y3, z1), + xs ), - zs - ) * - (1 / (1.5 * 1.5 * 1.5)) - ); - } - + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z2), + this._ValCoordR3(seed, x1, y0, z2), + this._ValCoordR3(seed, x2, y0, z2), + this._ValCoordR3(seed, x3, y0, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z2), + this._ValCoordR3(seed, x1, y1, z2), + this._ValCoordR3(seed, x2, y1, z2), + this._ValCoordR3(seed, x3, y1, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z2), + this._ValCoordR3(seed, x1, y2, z2), + this._ValCoordR3(seed, x2, y2, z2), + this._ValCoordR3(seed, x3, y2, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z2), + this._ValCoordR3(seed, x1, y3, z2), + this._ValCoordR3(seed, x2, y3, z2), + this._ValCoordR3(seed, x3, y3, z2), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z3), + this._ValCoordR3(seed, x1, y0, z3), + this._ValCoordR3(seed, x2, y0, z3), + this._ValCoordR3(seed, x3, y0, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z3), + this._ValCoordR3(seed, x1, y1, z3), + this._ValCoordR3(seed, x2, y1, z3), + this._ValCoordR3(seed, x3, y1, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z3), + this._ValCoordR3(seed, x1, y2, z3), + this._ValCoordR3(seed, x2, y2, z3), + this._ValCoordR3(seed, x3, y2, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z3), + this._ValCoordR3(seed, x1, y3, z3), + this._ValCoordR3(seed, x2, y3, z3), + this._ValCoordR3(seed, x3, y3, z3), + xs + ), + ys + ), + zs + ) * + (1 / (1.5 * 1.5 * 1.5)) + ); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), + xs + ); + let xf1 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), + xs + ); + + return FastNoiseLite._Lerp(xf0, xf1, ys); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + let zs = FastNoiseLite._InterpHermite(z - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + xs + ); + let xf10 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + xs + ); + let xf01 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + xs + ); + let xf11 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + xs + ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs); + } + + /** + * @private + */ + _DoSingleDomainWarp() { /** - * @private + * * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector2} coord * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleValueR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp( - this._ValCoordR2(seed, x0, y0), - this._ValCoordR2(seed, x1, y0), - xs - ); - let xf1 = FastNoiseLite._Lerp( - this._ValCoordR2(seed, x0, y1), - this._ValCoordR2(seed, x1, y1), - xs - ); - - return FastNoiseLite._Lerp(xf0, xf1, ys); - } - + * @param {number} y + */ + let R2 = (seed, amp, freq, coord, x, y) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 38.283687591552734375, + freq, + coord, + false, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 16.0, + freq, + coord, + true, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); + break; + } + }; + /** - * @private + * * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector3} coord * @param {number} x * @param {number} y * @param {number} z - * @returns {number} */ - _SingleValueR3(seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - let zs = FastNoiseLite._InterpHermite(z - z0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - xs + let R3 = (seed, amp, freq, coord, x, y, z) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 32.69428253173828125, + freq, + coord, + false, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 7.71604938271605, + freq, + coord, + true, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); + break; + } + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + return R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] ); - let xf11 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - xs + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + return R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs); } - + } + + /** + * @private + */ + _DomainWarpSingle() { /** - * @private + * + * @param {Vector2} coord */ - _DoSingleDomainWarp() { - /** - * - * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector2} coord - * @param {number} x - * @param {number} y - */ - let R2 = (seed, amp, freq, coord, x, y) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 38.283687591552734375, - freq, - coord, - false, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 16.0, - freq, - coord, - true, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); - break; - } - }; - - /** - * - * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector3} coord - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, amp, freq, coord, x, y, z) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 32.69428253173828125, - freq, - coord, - false, - x, - y, - z - ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 7.71604938271605, - freq, - coord, - true, - x, - y, - z - ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); - break; + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; } - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - return R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5] - ); + default: + break; } - - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - return R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + break; + } + default: + break; } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); } - + } + + _DomainWarpFractalProgressive() { /** - * @private + * + * @param {Vector2} coord */ - _DomainWarpSingle() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { let xs = coord.x; let ys = coord.y; switch (this._DomainWarpType) { @@ -2686,19 +2775,25 @@ default: break; } - + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { let xs = coord.x; let ys = coord.y; let zs = coord.z; @@ -2713,7 +2808,6 @@ zs += xy * 0.577350269189626; } break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: { let xz = xs + zs; @@ -2724,783 +2818,689 @@ ys += xz * 0.577350269189626; } break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + } + break; + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + /** + * @private + */ + _DomainWarpFractalIndependent() { + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + } + default: + break; + } + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { const R3 = 2.0 / 3.0; let r = (xs + ys + zs) * R3; // Rotation, not skew xs = r - xs; ys = r - ys; zs = r - zs; - break; } - default: - break; - } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); + break; + default: + break; } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); + + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + /** + * @private + */ + _SingleDomainWarpBasicGrid() { + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + + let R2 = (seed, warpAmp, frequency, coord, x, y) => { + let xf = x * frequency; + let yf = y * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); + let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + hash0 = this._HashR2(seed, x0, y1) & (255 << 1); + hash1 = this._HashR2(seed, x1, y1) & (255 << 1); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; + coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { + let xf = x * frequency; + let yf = y * frequency; + let zf = z * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + let z0 = Math.floor(zf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + let zs = FastNoiseLite._InterpHermite(zf - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); + let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); + let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); + let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); + + hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); + + lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); + + lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + coord.x += + FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * + warpAmp; + coord.y += + FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * + warpAmp; + coord.z += + FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * + warpAmp; + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] + ); } - - _DomainWarpFractalProgressive() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - } - default: - break; - } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - } - break; - default: - break; - } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); } - + } + + /** + * @private + */ + _SingleDomainWarpOpenSimplex2Gradient() { /** - * @private + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y */ - _DomainWarpFractalIndependent() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - } - default: - break; - } - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - } - break; - default: - break; - } - - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; + let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + x *= frequency; + y *= frequency; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let vx, vy; + vx = vy = 0; + + let a = 0.5 - x0 * x0 - y0 * y0; + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i, j) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i, j); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x0 * xg + y0 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; } - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } - } - - /** - * @private - */ - _SingleDomainWarpBasicGrid() { - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord - * @param {number} x - * @param {number} y - */ - - let R2 = (seed, warpAmp, frequency, coord, x, y) => { - let xf = x * frequency; - let yf = y * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); - let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); - - let lx0x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0], - this._RandVecs2D[hash1], - xs - ); - let ly0x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0 | 1], - this._RandVecs2D[hash1 | 1], - xs - ); - - hash0 = this._HashR2(seed, x0, y1) & (255 << 1); - hash1 = this._HashR2(seed, x1, y1) & (255 << 1); - - let lx1x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0], - this._RandVecs2D[hash1], - xs - ); - let ly1x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0 | 1], - this._RandVecs2D[hash1 | 1], - xs - ); - - coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; - coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; - }; - - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { - let xf = x * frequency; - let yf = y * frequency; - let zf = z * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - let z0 = Math.floor(zf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - let zs = FastNoiseLite._InterpHermite(zf - z0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); - let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); - - let lx0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - let ly0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - let lz0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); - - let lx1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - let ly1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - let lz1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); - let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); - let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); - - hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); - - lx0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - ly0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - lz0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); - - lx1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - ly1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - lz1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - coord.x += - FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * - warpAmp; - coord.y += - FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * - warpAmp; - coord.z += - FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * - warpAmp; - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5] - ); + vx += aaaa * xo; + vy += aaaa * yo; } - - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + if (c > 0) { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + let cccc = c * c * (c * c); + let xo, yo; + if (outGradOnly) { + let hash = + this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & + (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x2 * xg + y2 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += cccc * xo; + vy += cccc * yo; } - } - - /** - * @private - */ - _SingleDomainWarpOpenSimplex2Gradient() { - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y - */ - let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - x *= frequency; - y *= frequency; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let vx, vy; - vx = vy = 0; - - let a = 0.5 - x0 * x0 - y0 * y0; - if (a > 0) { - let aaaa = a * a * (a * a); + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); let xo, yo; if (outGradOnly) { - let hash = this._HashR2(seed, i, j) & (255 << 1); + let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); xo = this._RandVecs2D[hash]; yo = this._RandVecs2D[hash | 1]; } else { - let hash = this._HashR2(seed, i, j); + let hash = this._HashR2(seed, i, j + this._PrimeY); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); let xg = this._Gradients2D[index1]; let yg = this._Gradients2D[index1 | 1]; - let value = x0 * xg + y0 * yg; + let value = x1 * xg + y1 * yg; let xgo = this._RandVecs2D[index2]; let ygo = this._RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } - vx += aaaa * xo; - vy += aaaa * yo; + vx += bbbb * xo; + vy += bbbb * yo; } - - let c = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - if (c > 0) { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - let cccc = c * c * (c * c); + } else { + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); let xo, yo; if (outGradOnly) { - let hash = - this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & - (255 << 1); + let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); xo = this._RandVecs2D[hash]; yo = this._RandVecs2D[hash | 1]; } else { - let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); + let hash = this._HashR2(seed, i + this._PrimeX, j); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); let xg = this._Gradients2D[index1]; let yg = this._Gradients2D[index1 | 1]; - let value = x2 * xg + y2 * yg; + let value = x1 * xg + y1 * yg; let xgo = this._RandVecs2D[index2]; let ygo = this._RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } - vx += cccc * xo; - vy += cccc * yo; + vx += bbbb * xo; + vy += bbbb * yo; } - - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i, j + this._PrimeY); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += bbbb * xo; - vy += bbbb * yo; + } + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { + x *= frequency; + y *= frequency; + z *= frequency; + + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let xNSign = (-x0 - 1.0) | 1; + let yNSign = (-y0 - 1.0) | 1; + let zNSign = (-z0 - 1.0) | 1; + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let vx, vy, vz; + vx = vy = vz = 0; + + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + for (let l = 0; ; l++) { + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i, j, k) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i, j, k); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x0 * xg + y0 * yg + z0 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; } + vx += aaaa * xo; + vy += aaaa * yo; + vz += aaaa * zo; + } + + let b = a; + let i1 = i; + let j1 = j; + let k1 = k; + let x1 = x0; + let y1 = y0; + let z1 = z0; + + if (ax0 >= ay0 && ax0 >= az0) { + x1 += xNSign; + b = b + ax0 + ax0; + i1 -= xNSign * this._PrimeX; + } else if (ay0 > ax0 && ay0 >= az0) { + y1 += yNSign; + b = b + ay0 + ay0; + j1 -= yNSign * this._PrimeY; } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i + this._PrimeX, j); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += bbbb * xo; - vy += bbbb * yo; - } + z1 += zNSign; + b = b + az0 + az0; + k1 -= zNSign * this._PrimeZ; } - - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - }; - - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { - x *= frequency; - y *= frequency; - z *= frequency; - - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let xNSign = (-x0 - 1.0) | 1; - let yNSign = (-y0 - 1.0) | 1; - let zNSign = (-z0 - 1.0) | 1; - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let vx, vy, vz; - vx = vy = vz = 0; - - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - for (let l = 0; ; l++) { - if (a > 0) { - let aaaa = a * a * (a * a); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i, j, k) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; - } else { - let hash = this._HashR3(seed, i, j, k); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x0 * xg + y0 * yg + z0 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; - } - vx += aaaa * xo; - vy += aaaa * yo; - vz += aaaa * zo; - } - - let b = a; - let i1 = i; - let j1 = j; - let k1 = k; - let x1 = x0; - let y1 = y0; - let z1 = z0; - - if (ax0 >= ay0 && ax0 >= az0) { - x1 += xNSign; - b = b + ax0 + ax0; - i1 -= xNSign * this._PrimeX; - } else if (ay0 > ax0 && ay0 >= az0) { - y1 += yNSign; - b = b + ay0 + ay0; - j1 -= yNSign * this._PrimeY; + + if (b > 1) { + b -= 1; + let bbbb = b * b * (b * b); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; } else { - z1 += zNSign; - b = b + az0 + az0; - k1 -= zNSign * this._PrimeZ; - } - - if (b > 1) { - b -= 1; - let bbbb = b * b * (b * b); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; - } else { - let hash = this._HashR3(seed, i1, j1, k1); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x1 * xg + y1 * yg + z1 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; - } - vx += bbbb * xo; - vy += bbbb * yo; - vz += bbbb * zo; + let hash = this._HashR3(seed, i1, j1, k1); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x1 * xg + y1 * yg + z1 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; } - - if (l === 1) break; - - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; - - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; - - a += 0.75 - ax0 - (ay0 + az0); - - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; - - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; - - seed += 1293373; + vx += bbbb * xo; + vy += bbbb * yo; + vz += bbbb * zo; } - - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - coord.z += vz * warpAmp; - }; - - if (arguments.length === 7) { - R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); - } - - if (arguments.length === 8) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6], - arguments[7] - ); + + if (l === 1) break; + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed += 1293373; } + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + coord.z += vz * warpAmp; + }; + + if (arguments.length === 7) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); } - } - - class Vector2 { - /** - * 2d Vector - * @param {number} x - * @param {number} y - */ - constructor(x, y) { - this.x = x; - this.y = y; + + if (arguments.length === 8) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6], + arguments[7] + ); } } - - class Vector3 { - /** - * 3d Vector - * @param {number} x - * @param {number} y - * @param {number} z - */ - constructor(x, y, z) { - this.x = x; - this.y = y; - this.z = z; - } + } + + class Vector2 { + /** + * 2d Vector + * @param {number} x + * @param {number} y + */ + constructor(x, y) { + this.x = x; + this.y = y; + } + } + + class Vector3 { + /** + * 3d Vector + * @param {number} x + * @param {number} y + * @param {number} z + */ + constructor(x, y, z) { + this.x = x; + this.y = y; + this.z = z; } - - Scratch.extensions.register(new Noise()); - })((window.Scratch = window.Scratch || {})); - \ No newline at end of file + } + + Scratch.extensions.register(new Noise()); +})((window.Scratch = window.Scratch || {})); From 4eb987d3d191d28ddd5d4a8c53bfa4c46593a621 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 18:04:27 -0700 Subject: [PATCH 15/36] punctuation --- extensions/Corbnorb/noise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index ad9d877291..679fe51514 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -1,6 +1,6 @@ // Name: Noise // ID: corbnorbsnoise -// Description: Adds many types of noises using FastNoiseLite +// Description: Adds many types of noises using FastNoiseLite. // By: Corbnorbs // Original: Auburn // License: MPL-2.0 From 85bfbd658e878250779b2f77bc6fa8ba887cfd83 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 18:06:14 -0700 Subject: [PATCH 16/36] format --- extensions/Corbnorb/noise.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 679fe51514..bb3ee81d7e 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -13,6 +13,7 @@ const BlockType = Scratch.BlockType; const ArgumentType = Scratch.ArgumentType; const Cast = Scratch.Cast; + const Translate = Scratch.Translate; class Noise { constructor() { @@ -32,7 +33,9 @@ { opcode: "initNoise", blockType: BlockType.COMMAND, - text: "create noise id:[ID] type:[TYPE] frequency:[FREQUENCY] fractal:[FRACTAL] octaves:[OCTAVES] seed:[SEED]", + text: Translate( + "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]" + ), arguments: { ID: { type: ArgumentType.STRING, @@ -65,7 +68,9 @@ { opcode: "getNoise", blockType: BlockType.REPORTER, - text: "get noise id:[ID] at x:[X] y:[Y] z:[Z] easing:[EASING] inverted?[INVERTED]", + text: Translate( + "get noise id:[ID] at x:[X] y:[Y] z:[Z] easing:[EASING] inverted?[INVERTED]" + ), arguments: { ID: { type: ArgumentType.STRING, From cbadec75c295bbae9df916c892f39b1404185260 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 18:07:26 -0700 Subject: [PATCH 17/36] fixes --- extensions/Corbnorb/noise.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index bb3ee81d7e..abd789d73b 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -25,7 +25,7 @@ getInfo() { return { id: "corbnorbsnoise", - name: "Noise", + name: Translate("Noise"), color1: "#b5074c", color2: "#990841", docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", @@ -3508,4 +3508,4 @@ } Scratch.extensions.register(new Noise()); -})((window.Scratch = window.Scratch || {})); +})((Scratch)); From ddaa6527dc518396483711f7d24804a7b157852f Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 18:08:48 -0700 Subject: [PATCH 18/36] final prettier --- extensions/Corbnorb/noise.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index abd789d73b..32d4cb8b76 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -34,8 +34,8 @@ opcode: "initNoise", blockType: BlockType.COMMAND, text: Translate( - "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]" - ), + "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]" + ), arguments: { ID: { type: ArgumentType.STRING, @@ -69,7 +69,7 @@ opcode: "getNoise", blockType: BlockType.REPORTER, text: Translate( - "get noise id:[ID] at x:[X] y:[Y] z:[Z] easing:[EASING] inverted?[INVERTED]" + "get noise id:[ID] at x:[X] y:[Y] z:[Z] easing:[EASING] inverted?[INVERTED]" ), arguments: { ID: { @@ -3508,4 +3508,4 @@ } Scratch.extensions.register(new Noise()); -})((Scratch)); +})(Scratch); From aeab863fffed4cd137c94625d4ac8df61d273350 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 18:11:46 -0700 Subject: [PATCH 19/36] boom --- extensions/Corbnorb/noise.js | 234 +++++++++++++++++------------------ 1 file changed, 117 insertions(+), 117 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 32d4cb8b76..daa1174e8f 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -13,7 +13,7 @@ const BlockType = Scratch.BlockType; const ArgumentType = Scratch.ArgumentType; const Cast = Scratch.Cast; - const Translate = Scratch.Translate; + const Translate = Scratch.translate; class Noise { constructor() { @@ -608,131 +608,131 @@ // prettier-ignore _Gradients2D = [ - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, - -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, - ]; + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, + -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, + ]; // prettier-ignore _RandVecs2D = [ - -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, - -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, - -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, - -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, - -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, - 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, - 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, - -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, - 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, - 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, - -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, - 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, - -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, - -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, - 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, - -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, - 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, - 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, - 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, - -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, - 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, - 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, - 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, - -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, - 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, - -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, - 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, - -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, - 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, - -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, - 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, - 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, - ]; + -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, + -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, + -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, + -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, + -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, + 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, + 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, + -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, + 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, + 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, + -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, + 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, + -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, + -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, + 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, + -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, + 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, + 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, + 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, + -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, + 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, + 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, + 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, + -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, + 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, + -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, + 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, + -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, + 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, + -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, + 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, + 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, + ]; // prettier-ignore _Gradients3D = [ - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 - ]; + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 + ]; // prettier-ignore _RandVecs3D = [ - -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, - 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, - -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, - -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, - 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, - -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, - 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, - 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, - -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, - 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, - -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, - -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, - 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, - 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, - -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, - 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, - 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, - -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, - -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, - -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, - -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, - 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, - 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, - 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, - -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, - -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, - -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, - 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, - 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, - 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, - 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, - -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 - ]; + -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, + 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, + -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, + -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, + 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, + -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, + 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, + 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, + -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, + 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, + -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, + -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, + 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, + 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, + -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, + 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, + 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, + -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, + -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, + -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, + -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, + 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, + 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, + 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, + -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, + -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, + -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, + 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, + 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, + 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, + 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, + -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 + ]; _PrimeX = 501125321; _PrimeY = 1136930381; From a922522b72d344bf4c1148672846a8f927bfd527 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 18:13:22 -0700 Subject: [PATCH 20/36] broken block --- extensions/Corbnorb/noise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index daa1174e8f..7cda838111 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -34,7 +34,7 @@ opcode: "initNoise", blockType: BlockType.COMMAND, text: Translate( - "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL] inverted?[INVERTED] easing:[EASING]" + "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL]" ), arguments: { ID: { From 495db9644590021214cca311fc9df2fd6f8c5c88 Mon Sep 17 00:00:00 2001 From: Cubester Date: Wed, 25 Dec 2024 20:22:30 -0500 Subject: [PATCH 21/36] Redo this --- extensions/Corbnorb/noise.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 7cda838111..6af6925ecc 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -16,12 +16,6 @@ const Translate = Scratch.translate; class Noise { - constructor() { - this.noiseSeed = 0; - this.worleySeed = 0; - this.time = performance.now(); - } - getInfo() { return { id: "corbnorbsnoise", From bfdaa100275517161c679b3cc1b630dae0e64ff1 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 19:04:40 -0700 Subject: [PATCH 22/36] fixed crashing --- extensions/Corbnorb/noise.js | 6581 +++++++++++++++++----------------- 1 file changed, 3291 insertions(+), 3290 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 7cda838111..be01a10cf2 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -6,3506 +6,3507 @@ // License: MPL-2.0 (function (Scratch) { - "use strict"; - - const noises = Object.create(null); - - const BlockType = Scratch.BlockType; - const ArgumentType = Scratch.ArgumentType; - const Cast = Scratch.Cast; - const Translate = Scratch.translate; - - class Noise { - constructor() { - this.noiseSeed = 0; - this.worleySeed = 0; - this.time = performance.now(); - } - - getInfo() { - return { - id: "corbnorbsnoise", - name: Translate("Noise"), - color1: "#b5074c", - color2: "#990841", - docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", - blocks: [ - { - opcode: "initNoise", - blockType: BlockType.COMMAND, - text: Translate( - "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL]" - ), - arguments: { - ID: { - type: ArgumentType.STRING, - defaultValue: "myNoise", - }, - SEED: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - TYPE: { - type: ArgumentType.STRING, - menu: "NOISE_TYPE", - defaultValue: "Perlin", - }, - OCTAVES: { - type: ArgumentType.NUMBER, - defaultValue: "1", - }, - FREQUENCY: { - type: ArgumentType.NUMBER, - defaultValue: "0.01", - }, - FRACTAL: { - type: ArgumentType.STRING, - menu: "FRACTAL_TYPE", - defaultValue: "FBm", + "use strict"; + + const noises = Object.create(null); + + const BlockType = Scratch.BlockType; + const ArgumentType = Scratch.ArgumentType; + const Cast = Scratch.Cast; + const Translate = Scratch.translate; + + class Noise { + constructor() { + this.noiseSeed = 0; + this.worleySeed = 0; + this.time = performance.now(); + } + + getInfo() { + return { + id: "corbnorbsnoise", + name: Translate("Noise"), + color1: "#b5074c", + color2: "#990841", + docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", + blocks: [ + { + opcode: "initNoise", + blockType: BlockType.COMMAND, + text: Translate( + "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL]" + ), + arguments: { + ID: { + type: ArgumentType.STRING, + defaultValue: "myNoise", + }, + SEED: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + TYPE: { + type: ArgumentType.STRING, + menu: "NOISE_TYPE", + defaultValue: "Perlin", + }, + OCTAVES: { + type: ArgumentType.NUMBER, + defaultValue: "1", + }, + FREQUENCY: { + type: ArgumentType.NUMBER, + defaultValue: "0.01", + }, + FRACTAL: { + type: ArgumentType.STRING, + menu: "FRACTAL_TYPE", + defaultValue: "FBm", + }, }, }, - }, - { - opcode: "getNoise", - blockType: BlockType.REPORTER, - text: Translate( - "get noise id:[ID] at x:[X] y:[Y] z:[Z] easing:[EASING] inverted?[INVERTED]" - ), - arguments: { - ID: { - type: ArgumentType.STRING, - defaultValue: "myNoise", - }, - X: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - Y: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - Z: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - INVERTED: { - type: ArgumentType.STRING, - menu: "INVERTED_MENU", - defaultValue: "false", - }, - EASING: { - type: ArgumentType.STRING, - menu: "EASING_TYPE", - defaultValue: "Linear", + { + opcode: "getNoise", + blockType: BlockType.REPORTER, + text: Translate( + "get noise id:[ID] at x:[X] y:[Y] z:[Z] easing:[EASING] inverted?[INVERTED]" + ), + arguments: { + ID: { + type: ArgumentType.STRING, + defaultValue: "myNoise", + }, + X: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + Y: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + Z: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + INVERTED: { + type: ArgumentType.STRING, + menu: "INVERTED_MENU", + defaultValue: "false", + }, + EASING: { + type: ArgumentType.STRING, + menu: "EASING_TYPE", + defaultValue: "Linear", + }, }, }, + ], + menus: { + NOISE_TYPE: { + acceptReporters: true, + items: [ + "openSimpex2", + "openSimpex2S", + "cellular", + "perlin", + "value Cubic", + "value", + ], + }, + FRACTAL_TYPE: { + acceptReporters: true, + items: ["none", "fbm", "ridged", "ping Pong"], + }, + INVERTED_MENU: { + acceptReporters: true, + items: [ + { text: "true", value: "true" }, + { text: "false", value: "false" }, + ], + }, + EASING_TYPE: { + acceptReporters: true, + items: ["linear", "squared", "cubed", "root"], + }, }, - ], - menus: { - NOISE_TYPE: { - acceptReporters: true, - items: [ - "OpenSimpex2", - "OpenSimpex2S", - "Cellular", - "Perlin", - "Value Cubic", - "Value", - ], - }, - FRACTAL_TYPE: { - acceptReporters: true, - items: ["None", "FBm", "Ridged", "Ping Pong"], - }, - INVERTED_MENU: { - acceptReporters: true, - items: [ - { text: "true", value: true }, - { text: "false", value: false }, - ], - }, - EASING_TYPE: { - acceptReporters: true, - items: ["Linear", "Squared", "Cubed", "Root"], - }, - }, - }; - } - - initNoise(args) { - const id = Cast.toString(args.ID); - const seed = Cast.toNumber(args.SEED); - const fractal = Cast.toString(args.FRACTAL); - const frequency = Cast.toNumber(args.FREQUENCY); - const octaves = Cast.toNumber(args.OCTAVES); - noises[id] = new FastNoiseLite(seed); - switch (args.TYPE) { - case "OpenSimplex2": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); - break; - case "OpenSimplex2S": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2S); - break; - case "Cellular": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Cellular); - break; - case "Perlin": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); - break; - case "Value Cubic": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.ValueCubic); - break; - case "Value": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Value); - break; - default: - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); - break; - } - switch (fractal) { - case "None": - noises[id].SetFractalType(FastNoiseLite.FractalType.None); - break; - case "FBm": - noises[id].SetFractalType(FastNoiseLite.FractalType.FBm); - break; - case "Ridged": - noises[id].SetFractalType(FastNoiseLite.FractalType.Ridged); - break; - case "Ping Pong": - noises[id].SetFractalType(FastNoiseLite.FractalType.PingPong); - break; - default: - noises[id].SetFractalType(FastNoiseLite.FractalType.None); - break; - } - noises[id].SetFrequency(frequency); - noises[id].SetFractalOctaves(octaves); - } - - getNoise(args) { - const id = Cast.toString(args.ID); - const easing = Cast.toString(args.EASING); - const inverted = Cast.toBoolean(args.INVERTED); - if (id in noises) { - let value = noises[id].GetNoise(args.X, args.Y, args.Z); - value = inverted ? -value : value; - value = (value + 1) / 2; - switch (easing) { - case "Linear": + }; + } + + initNoise(args) { + const id = Cast.toString(args.ID); + const seed = Cast.toNumber(args.SEED); + const fractal = Cast.toString(args.FRACTAL); + const frequency = Cast.toNumber(args.FREQUENCY); + const octaves = Cast.toNumber(args.OCTAVES); + noises[id] = new FastNoiseLite(seed); + switch (args.TYPE) { + case "openSimplex2": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); break; - case "Squared": - value = Math.pow(value, 2); + case "openSimplex2S": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2S); break; - case "Cubed": - value = Math.pow(value, 3); + case "cellular": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Cellular); break; - case "Root": - value = Math.sqrt(Math.abs(value)); + case "perlin": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); break; - default: + case "value cubic": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.ValueCubic); break; - } - value = value * 2 - 1; - return value; - } - console.log("ISSUE"); - return 0; - } - } - - // MIT License - // - // Copyright(c) 2023 Jordan Peck (jordan.me2@gmail.com) - // Copyright(c) 2023 Contributors - // - // Permission is hereby granted, free of charge, to any person obtaining a copy - // of this software and associated documentation files(the "Software"), to deal - // in the Software without restriction, including without limitation the rights - // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - // copies of the Software, and to permit persons to whom the Software is - // furnished to do so, subject to the following conditions : - // - // The above copyright notice and this permission notice shall be included in all - // copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - // SOFTWARE. - // - - class FastNoiseLite { - static NoiseType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2S: "OpenSimplex2S", - Cellular: "Cellular", - Perlin: "Perlin", - ValueCubic: "ValueCubic", - Value: "Value", - }); - static RotationType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", - }); - static FractalType = Object.freeze({ - None: "None", - FBm: "FBm", - Ridged: "Ridged", - PingPong: "PingPong", - DomainWarpProgressive: "DomainWarpProgressive", - DomainWarpIndependent: "DomainWarpIndependent", - }); - static CellularDistanceFunction = Object.freeze({ - Euclidean: "Euclidean", - EuclideanSq: "EuclideanSq", - Manhattan: "Manhattan", - Hybrid: "Hybrid", - }); - static CellularReturnType = Object.freeze({ - CellValue: "CellValue", - Distance: "Distance", - Distance2: "Distance2", - Distance2Add: "Distance2Add", - Distance2Sub: "Distance2Sub", - Distance2Mul: "Distance2Mul", - Distance2Div: "Distance2Div", - }); - static DomainWarpType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2Reduced: "OpenSimplex2Reduced", - BasicGrid: "BasicGrid", - }); - static TransformType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", - DefaultOpenSimplex2: "DefaultOpenSimplex2", - }); - - /* Private */ - _Seed = 1337; - _Frequency = 0.01; - _NoiseType = FastNoiseLite.NoiseType.OpenSimplex2; - _RotationType3D = FastNoiseLite.RotationType3D.None; - _TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - _DomainWarpAmp = 1.0; - - _FractalType = FastNoiseLite.FractalType.None; - _Octaves = 3; - _Lacunarity = 2.0; - _Gain = 0.5; - _WeightedStrength = 0.0; - _PingPongStrength = 2.0; - - _FractalBounding = 1 / 1.75; - - _CellularDistanceFunction = - FastNoiseLite.CellularDistanceFunction.EuclideanSq; - _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; - _CellularJitterModifier = 1.0; - - _DomainWarpType = FastNoiseLite.DomainWarpType.OpenSimplex2; - _WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - - /** - * @description Create new FastNoiseLite object with optional seed - * @param {number} [seed] - * @constructor - */ - constructor(seed) { - if (seed !== undefined) { - this._Seed = seed; - } - } - - /** - * @description Sets seed used for all noise types - * @remarks Default: 1337 - * @default 1337 - * @param {number} seed - */ - SetSeed(seed) { - this._Seed = seed; - } - - /** - * @description Sets frequency for all noise types - * @remarks Default: 0.01 - * @default 0.01 - * @param {number} frequency - */ - SetFrequency(frequency) { - this._Frequency = frequency; - } - - /** - * @description Sets noise algorithm used for GetNoise(...) - * @remarks Default: OpenSimplex2 - * @default FastNoiseLite.NoiseType.OpenSimplex2 - * @param {FastNoiseLite.NoiseType} noiseType - */ - SetNoiseType(noiseType) { - this._NoiseType = noiseType; - this._UpdateTransformType3D(); - } - - /** - * @description Sets domain rotation type for 3D Noise and 3D DomainWarp. - * @description Can aid in reducing directional artifacts when sampling a 2D plane in 3D - * @remarks Default: None - * @default FastNoiseLite.RotationType3D.None - * @param {FastNoiseLite.RotationType3D} rotationType3D - */ - SetRotationType3D(rotationType3D) { - this._RotationType3D = rotationType3D; - this._UpdateTransformType3D(); - this._UpdateWarpTransformType3D(); - } - - /** - * @description Sets method for combining octaves in all fractal noise types - * @remarks Default: None - * @default FastNoiseLite.FractalType.None - * @param {FastNoiseLite.FractalType} fractalType - */ - SetFractalType(fractalType) { - this._FractalType = fractalType; - } - - /** - * @description Sets octave count for all fractal noise types - * @remarks Default: 3 - * @default 3 - * @param {number} octaves - */ - SetFractalOctaves(octaves) { - this._Octaves = octaves; - this._CalculateFractalBounding(); - } - - /** - * @description Sets octave lacunarity for all fractal noise types - * @remarks Default: 2.0 - * @default 2.0 - * @param {number} lacunarity - */ - SetFractalLacunarity(lacunarity) { - this._Lacunarity = lacunarity; - } - - /** - * @description Sets octave gain for all fractal noise types - * @remarks Default: 0.5 - * @default 0.5 - * @param {number} gain - */ - SetFractalGain(gain) { - this._Gain = gain; - this._CalculateFractalBounding(); - } - - /** - * @description Sets octave weighting for all none DomainWarp fratal types - * @remarks Default: 0.0 | Keep between 0...1 to maintain -1...1 output bounding - * @default 0.5 - * @param {number} weightedStrength - */ - SetFractalWeightedStrength(weightedStrength) { - this._WeightedStrength = weightedStrength; - } - - /** - * @description Sets strength of the fractal ping pong effect - * @remarks Default: 2.0 - * @default 2.0 - * @param {number} pingPongStrength - */ - SetFractalPingPongStrength(pingPongStrength) { - this._PingPongStrength = pingPongStrength; - } - - /** - * @description Sets distance function used in cellular noise calculations - * @remarks Default: EuclideanSq - * @default FastNoiseLite.CellularDistanceFunction.EuclideanSq - * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction - */ - SetCellularDistanceFunction(cellularDistanceFunction) { - this._CellularDistanceFunction = cellularDistanceFunction; - } - - /** - * @description Sets return type from cellular noise calculations - * @remarks Default: Distance - * @default FastNoiseLite.CellularReturnType.Distance - * @param {FastNoiseLite.CellularReturnType} cellularReturnType - */ - SetCellularReturnType(cellularReturnType) { - this._CellularReturnType = cellularReturnType; - } - - /** - * @description Sets the maximum distance a cellular point can move from it's grid position - * @remarks Default: 1.0 - * @default 1.0 - * @param {number} cellularJitter - */ - SetCellularJitter(cellularJitter) { - this._CellularJitterModifier = cellularJitter; - } - - /** - * @description Sets the warp algorithm when using DomainWarp(...) - * @remarks Default: OpenSimplex2 - * @default FastNoiseLite.DomainWarpType.OpenSimplex2 - * @param {FastNoiseLite.DomainWarpType} domainWarpType - */ - SetDomainWarpType(domainWarpType) { - this._DomainWarpType = domainWarpType; - this._UpdateWarpTransformType3D(); - } - - /** - * @description Sets the maximum warp distance from original position when using DomainWarp(...) - * @remarks Default: 1.0 - * @default 1.0 - * @param {number} domainWarpAmp - */ - SetDomainWarpAmp(domainWarpAmp) { - this._DomainWarpAmp = domainWarpAmp; - } - - /** - * @description 2D/3D noise at given position using current settings - * @param {number} x X coordinate - * @param {number} y Y coordinate - * @param {number} [z] Z coordinate - * @return {number} Noise output bounded between -1...1 - */ - GetNoise(x, y, z) { - /** - * @description 2D noise at given position using current settings - * @param {number} x - * @param {number} y - * @return {number} Noise output bounded between -1...1 - */ - let R2 = (x, y) => { - x *= this._Frequency; - y *= this._Frequency; - - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (x + y) * F2; - x += t; - y += t; + case "value": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Value); break; - } default: + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); break; } - - switch (this._FractalType) { - default: - return this._GenNoiseSingleR2(this._Seed, x, y); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR2(x, y); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR2(x, y); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR2(x, y); - } - }; - - /** - * @description 3D noise at given position using current settings - * @param {number} x - * @param {number} y - * @param {number} z - * @return {number} Noise output bounded between -1...1 - */ - let R3 = (x, y, z) => { - x *= this._Frequency; - y *= this._Frequency; - z *= this._Frequency; - - switch (this._TransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: { - let xy = x + y; - let s2 = xy * -0.211324865405187; - z *= 0.577350269189626; - x += s2 - z; - y += s2 - z; - z += xy * 0.577350269189626; + switch (fractal) { + case "none": + noises[id].SetFractalType(FastNoiseLite.FractalType.None); break; - } - case FastNoiseLite.TransformType3D.ImproveXZPlanes: { - let xz = x + z; - let s2 = xz * -0.211324865405187; - y *= 0.577350269189626; - x += s2 - y; - z += s2 - y; - y += xz * 0.577350269189626; + case "fbm": + noises[id].SetFractalType(FastNoiseLite.FractalType.FBm); break; - } - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { - const R3 = 2.0 / 3.0; - let r = (x + y + z) * R3; - x = r - x; - y = r - y; - z = r - z; + case "ridged": + noises[id].SetFractalType(FastNoiseLite.FractalType.Ridged); break; - } - default: + case "ping pong": + noises[id].SetFractalType(FastNoiseLite.FractalType.PingPong); break; - } - - switch (this._FractalType) { default: - return this._GenNoiseSingleR3(this._Seed, x, y, z); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR3(x, y, z); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR3(x, y, z); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR3(x, y, z); + noises[id].SetFractalType(FastNoiseLite.FractalType.None); + break; } - }; - - if (arguments.length === 2) { - return R2(x, y); - } - - if (arguments.length === 3) { - return R3(x, y, z); - } - } - - /** - * @description 2D/3D warps the input position using current domain warp settings - * @param {Vector2|Vector3} coord - */ - DomainWrap(coord) { - switch (this._FractalType) { - default: - this._DomainWarpSingle(coord); - break; - case FastNoiseLite.FractalType.DomainWarpProgressive: - this._DomainWarpFractalProgressive(coord); - break; - case FastNoiseLite.FractalType.DomainWarpIndependent: - this._DomainWarpFractalIndependent(coord); - break; - } - } - - // prettier-ignore - _Gradients2D = [ - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, - -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, - ]; - - // prettier-ignore - _RandVecs2D = [ - -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, - -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, - -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, - -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, - -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, - 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, - 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, - -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, - 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, - 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, - -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, - 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, - -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, - -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, - 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, - -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, - 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, - 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, - 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, - -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, - 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, - 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, - 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, - -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, - 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, - -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, - 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, - -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, - 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, - -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, - 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, - 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, - ]; - - // prettier-ignore - _Gradients3D = [ - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 - ]; - - // prettier-ignore - _RandVecs3D = [ - -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, - 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, - -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, - -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, - 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, - -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, - 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, - 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, - -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, - 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, - -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, - -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, - 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, - 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, - -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, - 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, - 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, - -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, - -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, - -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, - -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, - 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, - 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, - 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, - -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, - -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, - -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, - 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, - 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, - 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, - 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, - -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 - ]; - - _PrimeX = 501125321; - _PrimeY = 1136930381; - _PrimeZ = 1720413743; - - /** - * @private - * @param {number} a - * @param {number} b - * @param {number} t - * @returns {number} - */ - static _Lerp(a, b, t) { - return a + t * (b - a); - } - - /** - * @private - * @param {number} t - * @returns {number} - */ - static _InterpHermite(t) { - return t * t * (3 - 2 * t); - } - - /** - * @private - * @param t - * @returns {number} - */ - static _InterpQuintic(t) { - return t * t * t * (t * (t * 6 - 15) + 10); - } - - /** - * @private - * @param {number} a - * @param {number} b - * @param {number} c - * @param {number} d - * @param {number} t - * @returns {number} - */ - static _CubicLerp(a, b, c, d, t) { - const p = d - c - (a - b); - return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; - } - - /** - * @private - * @param {number} t - * @returns {number} - */ - static _PingPong(t) { - t -= Math.trunc(t * 0.5) * 2; - return t < 1 ? t : 2 - t; - } - - /** - * @private - */ - _CalculateFractalBounding() { - let gain = Math.abs(this._Gain); - let amp = gain; - let ampFractal = 1.0; - for (let i = 1; i < this._Octaves; i++) { - ampFractal += amp; - amp *= gain; - } - this._FractalBounding = 1 / ampFractal; - } - - /** - * @private - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @returns {number} - */ - _HashR2(seed, xPrimed, yPrimed) { - let hash = seed ^ xPrimed ^ yPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @returns {number} - */ - _HashR3(seed, xPrimed, yPrimed, zPrimed) { - let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; - } - - /** - * @private - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @returns {number} - */ - _ValCoordR2(seed, xPrimed, yPrimed) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @returns {number} - */ - _ValCoordR3(seed, xPrimed, yPrimed, zPrimed) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} xd - * @param {number} yd - * @returns {number} - */ - _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - hash ^= hash >> 15; - hash &= 127 << 1; - - let xg = this._Gradients2D[hash]; - let yg = this._Gradients2D[hash | 1]; - - return xd * xg + yd * yg; - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @param {number} xd - * @param {number} yd - * @param {number} zd - * @returns {number} - */ - _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - hash ^= hash >> 15; - hash &= 63 << 2; - - let xg = this._Gradients3D[hash]; - let yg = this._Gradients3D[hash | 1]; - let zg = this._Gradients3D[hash | 2]; - - return xd * xg + yd * yg + zd * zg; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenNoiseSingleR2(seed, x, y) { - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R2(seed, x, y); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR2(seed, x, y); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR2(seed, x, y); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR2(seed, x, y); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR2(seed, x, y); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR2(seed, x, y); - default: - return 0; - } - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenNoiseSingleR3(seed, x, y, z) { - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R3(seed, x, y, z); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR3(seed, x, y, z); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR3(seed, x, y, z); - default: - return 0; + noises[id].SetFrequency(frequency); + noises[id].SetFractalOctaves(octaves); } - } - - /** - * @private - */ - _UpdateTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; - default: - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: - this._TransformType3D = - FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + + getNoise(args) { + const id = Cast.toString(args.ID); + const easing = Cast.toString(args.EASING); + const inverted = Cast.toBoolean(args.INVERTED); + if (id in noises) { + let value = noises[id].GetNoise(args.X, args.Y, args.Z); + value = (inverted == true) ? -value : value; + value = (value + 1) / 2; + switch (easing) { + case "linear": break; - default: - this._TransformType3D = FastNoiseLite.TransformType3D.None; + case "squared": + value = Math.pow(value, 2); break; - } - break; - } - } - - /** - * @private - */ - _UpdateWarpTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; - default: - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + case "cubed": + value = Math.pow(value, 3); + break; + case "root": + value = Math.sqrt(Math.abs(value)); break; default: - this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; break; } - break; + value = value * 2 - 1; + return value; + } + console.log("ISSUE"); + return 0; } } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalFBmR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR2(seed++, x, y); - sum += noise * amp; - amp *= FastNoiseLite._Lerp( - 1.0, - Math.min(noise + 1, 2) * 0.5, - this._WeightedStrength - ); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; + + // MIT License + // + // Copyright(c) 2023 Jordan Peck (jordan.me2@gmail.com) + // Copyright(c) 2023 Contributors + // + // Permission is hereby granted, free of charge, to any person obtaining a copy + // of this software and associated documentation files(the "Software"), to deal + // in the Software without restriction, including without limitation the rights + // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell + // copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions : + // + // The above copyright notice and this permission notice shall be included in all + // copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + // SOFTWARE. + // + + class FastNoiseLite { + static NoiseType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2S: "OpenSimplex2S", + Cellular: "Cellular", + Perlin: "Perlin", + ValueCubic: "ValueCubic", + Value: "Value", + }); + static RotationType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + }); + static FractalType = Object.freeze({ + None: "None", + FBm: "FBm", + Ridged: "Ridged", + PingPong: "PingPong", + DomainWarpProgressive: "DomainWarpProgressive", + DomainWarpIndependent: "DomainWarpIndependent", + }); + static CellularDistanceFunction = Object.freeze({ + Euclidean: "Euclidean", + EuclideanSq: "EuclideanSq", + Manhattan: "Manhattan", + Hybrid: "Hybrid", + }); + static CellularReturnType = Object.freeze({ + CellValue: "CellValue", + Distance: "Distance", + Distance2: "Distance2", + Distance2Add: "Distance2Add", + Distance2Sub: "Distance2Sub", + Distance2Mul: "Distance2Mul", + Distance2Div: "Distance2Div", + }); + static DomainWarpType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2Reduced: "OpenSimplex2Reduced", + BasicGrid: "BasicGrid", + }); + static TransformType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + DefaultOpenSimplex2: "DefaultOpenSimplex2", + }); + + /* Private */ + _Seed = 1337; + _Frequency = 0.01; + _NoiseType = FastNoiseLite.NoiseType.OpenSimplex2; + _RotationType3D = FastNoiseLite.RotationType3D.None; + _TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + _DomainWarpAmp = 1.0; + + _FractalType = FastNoiseLite.FractalType.None; + _Octaves = 3; + _Lacunarity = 2.0; + _Gain = 0.5; + _WeightedStrength = 0.0; + _PingPongStrength = 2.0; + + _FractalBounding = 1 / 1.75; + + _CellularDistanceFunction = + FastNoiseLite.CellularDistanceFunction.EuclideanSq; + _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; + _CellularJitterModifier = 1.0; + + _DomainWarpType = FastNoiseLite.DomainWarpType.OpenSimplex2; + _WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + + /** + * @description Create new FastNoiseLite object with optional seed + * @param {number} [seed] + * @constructor + */ + constructor(seed) { + if (seed !== undefined) { + this._Seed = seed; + } } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalFBmR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR3(seed++, x, y, z); - sum += noise * amp; - amp *= FastNoiseLite._Lerp( - 1.0, - (noise + 1) * 0.5, - this._WeightedStrength - ); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; + + /** + * @description Sets seed used for all noise types + * @remarks Default: 1337 + * @default 1337 + * @param {number} seed + */ + SetSeed(seed) { + this._Seed = seed; } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalRidgedR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; + + /** + * @description Sets frequency for all noise types + * @remarks Default: 0.01 + * @default 0.01 + * @param {number} frequency + */ + SetFrequency(frequency) { + this._Frequency = frequency; } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalRidgedR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; + + /** + * @description Sets noise algorithm used for GetNoise(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.NoiseType.OpenSimplex2 + * @param {FastNoiseLite.NoiseType} noiseType + */ + SetNoiseType(noiseType) { + this._NoiseType = noiseType; + this._UpdateTransformType3D(); } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalPingPongR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; + + /** + * @description Sets domain rotation type for 3D Noise and 3D DomainWarp. + * @description Can aid in reducing directional artifacts when sampling a 2D plane in 3D + * @remarks Default: None + * @default FastNoiseLite.RotationType3D.None + * @param {FastNoiseLite.RotationType3D} rotationType3D + */ + SetRotationType3D(rotationType3D) { + this._RotationType3D = rotationType3D; + this._UpdateTransformType3D(); + this._UpdateWarpTransformType3D(); } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalPingPongR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; + + /** + * @description Sets method for combining octaves in all fractal noise types + * @remarks Default: None + * @default FastNoiseLite.FractalType.None + * @param {FastNoiseLite.FractalType} fractalType + */ + SetFractalType(fractalType) { + this._FractalType = fractalType; } - return sum; - } - - /** - * - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleOpenSimplex2R2(seed, x, y) { - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let n0, n1, n2; - - let a = 0.5 - x0 * x0 - y0 * y0; - - if (a <= 0) { - n0 = 0; - } else { - n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); + + /** + * @description Sets octave count for all fractal noise types + * @remarks Default: 3 + * @default 3 + * @param {number} octaves + */ + SetFractalOctaves(octaves) { + this._Octaves = octaves; + this._CalculateFractalBounding(); } - - let c = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - - if (c <= 0) { - n2 = 0; - } else { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - n2 = - c * - c * - (c * c) * - this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); + + /** + * @description Sets octave lacunarity for all fractal noise types + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} lacunarity + */ + SetFractalLacunarity(lacunarity) { + this._Lacunarity = lacunarity; } - - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = - b * - b * - (b * b) * - this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); - } - } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = - b * - b * - (b * b) * - this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); - } + + /** + * @description Sets octave gain for all fractal noise types + * @remarks Default: 0.5 + * @default 0.5 + * @param {number} gain + */ + SetFractalGain(gain) { + this._Gain = gain; + this._CalculateFractalBounding(); } - return (n0 + n1 + n2) * 99.83685446303647; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleOpenSimplex2R3(seed, x, y, z) { - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let yNSign = Math.trunc((-1.0 - y0) | 1); - let xNSign = Math.trunc((-1.0 - x0) | 1); - let zNSign = Math.trunc((-1.0 - z0) | 1); - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let value = 0; - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - - for (let l = 0; ; l++) { - if (a > 0) { - value += - a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); - } - - if (ax0 >= ay0 && ax0 >= az0) { - let b = a + ax0 + ax0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i - xNSign * this._PrimeX, - j, - k, - x0 + xNSign, - y0, - z0 - ); - } - } else if (ay0 > ax0 && ay0 >= az0) { - let b = a + ay0 + ay0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i, - j - yNSign * this._PrimeY, - k, - x0, - y0 + yNSign, - z0 - ); - } - } else { - let b = a + az0 + az0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i, - j, - k - zNSign * this._PrimeZ, - x0, - y0, - z0 + zNSign - ); - } - } - - if (l === 1) { - break; - } - - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; - - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; - - a += 0.75 - ax0 - (ay0 + az0); - - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; - - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; - - seed = ~seed; + + /** + * @description Sets octave weighting for all none DomainWarp fratal types + * @remarks Default: 0.0 | Keep between 0...1 to maintain -1...1 output bounding + * @default 0.5 + * @param {number} weightedStrength + */ + SetFractalWeightedStrength(weightedStrength) { + this._WeightedStrength = weightedStrength; } - return value * 32.69428253173828125; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleOpenSimplex2SR2(seed, x, y) { - // 2D OpenSimplex2S case is a modified 2D simplex noise. - - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - /* - * --- Skew moved to TransformNoiseCoordinate method --- - * final FNLfloat F2 = 0.5f * (SQRT3 - 1); - * FNLfloat s = (x + y) * F2; - * x += s; y += s; + + /** + * @description Sets strength of the fractal ping pong effect + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} pingPongStrength */ - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - let i1 = i + this._PrimeX; - let j1 = j + this._PrimeY; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; - let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); - let a1 = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); - let x1 = x0 - (1 - 2 * G2); - let y1 = y0 - (1 - 2 * G2); - value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); - - // Nested conditionals were faster than compact bit logic/arithmetic. - let xmyi = xi - yi; - if (t > G2) { - if (xi + xmyi > 1) { - let x2 = x0 + (3 * G2 - 2); - let y2 = y0 + (3 * G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2( - seed, - i + (this._PrimeX << 1), - j + this._PrimeY, - x2, - y2 - ); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } - } - - if (yi - xmyi > 1) { - let x3 = x0 + (3 * G2 - 1); - let y3 = y0 + (3 * G2 - 2); - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR2( - seed, - i + this._PrimeX, - j + (this._PrimeY << 1), - x3, - y3 - ); + SetFractalPingPongStrength(pingPongStrength) { + this._PingPongStrength = pingPongStrength; + } + + /** + * @description Sets distance function used in cellular noise calculations + * @remarks Default: EuclideanSq + * @default FastNoiseLite.CellularDistanceFunction.EuclideanSq + * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction + */ + SetCellularDistanceFunction(cellularDistanceFunction) { + this._CellularDistanceFunction = cellularDistanceFunction; + } + + /** + * @description Sets return type from cellular noise calculations + * @remarks Default: Distance + * @default FastNoiseLite.CellularReturnType.Distance + * @param {FastNoiseLite.CellularReturnType} cellularReturnType + */ + SetCellularReturnType(cellularReturnType) { + this._CellularReturnType = cellularReturnType; + } + + /** + * @description Sets the maximum distance a cellular point can move from it's grid position + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} cellularJitter + */ + SetCellularJitter(cellularJitter) { + this._CellularJitterModifier = cellularJitter; + } + + /** + * @description Sets the warp algorithm when using DomainWarp(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.DomainWarpType.OpenSimplex2 + * @param {FastNoiseLite.DomainWarpType} domainWarpType + */ + SetDomainWarpType(domainWarpType) { + this._DomainWarpType = domainWarpType; + this._UpdateWarpTransformType3D(); + } + + /** + * @description Sets the maximum warp distance from original position when using DomainWarp(...) + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} domainWarpAmp + */ + SetDomainWarpAmp(domainWarpAmp) { + this._DomainWarpAmp = domainWarpAmp; + } + + /** + * @description 2D/3D noise at given position using current settings + * @param {number} x X coordinate + * @param {number} y Y coordinate + * @param {number} [z] Z coordinate + * @return {number} Noise output bounded between -1...1 + */ + GetNoise(x, y, z) { + /** + * @description 2D noise at given position using current settings + * @param {number} x + * @param {number} y + * @return {number} Noise output bounded between -1...1 + */ + let R2 = (x, y) => { + x *= this._Frequency; + y *= this._Frequency; + + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (x + y) * F2; + x += t; + y += t; + break; + } + default: + break; } - } else { - let x3 = x0 + (G2 - 1); - let y3 = y0 + G2; - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR2(this._Seed, x, y); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR2(x, y); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR2(x, y); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR2(x, y); } - } - } else { - if (xi + xmyi < 0) { - let x2 = x0 + (1 - G2); - let y2 = y0 - G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); + }; + + /** + * @description 3D noise at given position using current settings + * @param {number} x + * @param {number} y + * @param {number} z + * @return {number} Noise output bounded between -1...1 + */ + let R3 = (x, y, z) => { + x *= this._Frequency; + y *= this._Frequency; + z *= this._Frequency; + + switch (this._TransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: { + let xy = x + y; + let s2 = xy * -0.211324865405187; + z *= 0.577350269189626; + x += s2 - z; + y += s2 - z; + z += xy * 0.577350269189626; + break; + } + case FastNoiseLite.TransformType3D.ImproveXZPlanes: { + let xz = x + z; + let s2 = xz * -0.211324865405187; + y *= 0.577350269189626; + x += s2 - y; + z += s2 - y; + y += xz * 0.577350269189626; + break; + } + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + const R3 = 2.0 / 3.0; + let r = (x + y + z) * R3; + x = r - x; + y = r - y; + z = r - z; + break; + } + default: + break; } - } else { - let x2 = x0 + (G2 - 1); - let y2 = y0 + G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR3(this._Seed, x, y, z); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR3(x, y, z); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR3(x, y, z); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR3(x, y, z); } + }; + + if (arguments.length === 2) { + return R2(x, y); } - - if (yi < xmyi) { - let x2 = x0 - G2; - let y2 = y0 - (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } + + if (arguments.length === 3) { + return R3(x, y, z); } } - - return value * 18.24196194486065; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleOpenSimplex2SR3(seed, x, y, z) { - // 3D OpenSimplex2S case uses two offset rotated cube grids. - - /* - * --- Rotation moved to TransformNoiseCoordinate method --- - * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); - * FNLfloat r = (x + y + z) * R3; // Rotation, not skew - * x = r - x; y = r - y; z = r - z; + + /** + * @description 2D/3D warps the input position using current domain warp settings + * @param {Vector2|Vector3} coord */ - - let i = Math.floor(x); - let j = Math.floor(y); - let k = Math.floor(z); - let xi = x - i; - let yi = y - j; - let zi = z - k; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - let seed2 = seed + 1293373; - - let xNMask = Math.trunc(-0.5 - xi); - let yNMask = Math.trunc(-0.5 - yi); - let zNMask = Math.trunc(-0.5 - zi); - - let x0 = xi + xNMask; - let y0 = yi + yNMask; - let z0 = zi + zNMask; - let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; - let value = - a0 * - a0 * - (a0 * a0) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x0, - y0, - z0 - ); - - let x1 = xi - 0.5; - let y1 = yi - 0.5; - let z1 = zi - 0.5; - let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; - value += - a1 * - a1 * - (a1 * a1) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + this._PrimeY, - k + this._PrimeZ, - x1, - y1, - z1 - ); - - let xAFlipMask0 = ((xNMask | 1) << 1) * x1; - let yAFlipMask0 = ((yNMask | 1) << 1) * y1; - let zAFlipMask0 = ((zNMask | 1) << 1) * z1; - let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; - let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; - let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; - - let skip5 = false; - let a2 = xAFlipMask0 + a0; - if (a2 > 0) { - let x2 = x0 - (xNMask | 1); - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x2, - y0, - z0 - ); - } else { - let a3 = yAFlipMask0 + zAFlipMask0 + a0; - - if (a3 > 0) { - let x3 = x0; - let y3 = y0 - (yNMask | 1); - let z3 = z0 - (zNMask | 1); - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x3, - y3, - z3 - ); - } - - let a4 = xAFlipMask1 + a1; - if (a4 > 0) { - let x4 = (xNMask | 1) + x1; - value += - a4 * - a4 * - (a4 * a4) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + this._PrimeZ, - x4, - y1, - z1 - ); - skip5 = true; + DomainWrap(coord) { + switch (this._FractalType) { + default: + this._DomainWarpSingle(coord); + break; + case FastNoiseLite.FractalType.DomainWarpProgressive: + this._DomainWarpFractalProgressive(coord); + break; + case FastNoiseLite.FractalType.DomainWarpIndependent: + this._DomainWarpFractalIndependent(coord); + break; } } - - let skip9 = false; - let a6 = yAFlipMask0 + a0; - if (a6 > 0) { - let x6 = x0; - let y6 = y0 - (yNMask | 1); - value += - a6 * - a6 * - (a6 * a6) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x6, - y6, - z0 - ); - } else { - let a7 = xAFlipMask0 + zAFlipMask0 + a0; - if (a7 > 0) { - let x7 = x0 - (xNMask | 1); - let y7 = y0; - let z7 = z0 - (zNMask | 1); - value += - a7 * - a7 * - (a7 * a7) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x7, - y7, - z7 - ); - } - - let a8 = yAFlipMask1 + a1; - if (a8 > 0) { - let x8 = x1; - let y8 = (yNMask | 1) + y1; - value += - a8 * - a8 * - (a8 * a8) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - x8, - y8, - z1 - ); - skip9 = true; - } + + // prettier-ignore + _Gradients2D = [ + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, + -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, + ]; + + // prettier-ignore + _RandVecs2D = [ + -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, + -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, + -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, + -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, + -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, + 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, + 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, + -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, + 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, + 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, + -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, + 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, + -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, + -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, + 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, + -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, + 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, + 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, + 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, + -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, + 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, + 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, + 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, + -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, + 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, + -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, + 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, + -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, + 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, + -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, + 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, + 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, + ]; + + // prettier-ignore + _Gradients3D = [ + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 + ]; + + // prettier-ignore + _RandVecs3D = [ + -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, + 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, + -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, + -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, + 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, + -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, + 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, + 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, + -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, + 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, + -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, + -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, + 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, + 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, + -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, + 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, + 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, + -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, + -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, + -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, + -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, + 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, + 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, + 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, + -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, + -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, + -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, + 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, + 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, + 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, + 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, + -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 + ]; + + _PrimeX = 501125321; + _PrimeY = 1136930381; + _PrimeZ = 1720413743; + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} t + * @returns {number} + */ + static _Lerp(a, b, t) { + return a + t * (b - a); } - - let skipD = false; - let aA = zAFlipMask0 + a0; - if (aA > 0) { - let xA = x0; - let yA = y0; - let zA = z0 - (zNMask | 1); - value += - aA * - aA * - (aA * aA) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - xA, - yA, - zA - ); - } else { - let aB = xAFlipMask0 + yAFlipMask0 + a0; - if (aB > 0) { - let xB = x0 - (xNMask | 1); - let yB = y0 - (yNMask | 1); - value += - aB * - aB * - (aB * aB) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - xB, - yB, - z0 - ); - } - - let aC = zAFlipMask1 + a1; - if (aC > 0) { - let xC = x1; - let yC = y1; - let zC = (zNMask | 1) + z1; - value += - aC * - aC * - (aC * aC) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - xC, - yC, - zC - ); - skipD = true; - } + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _InterpHermite(t) { + return t * t * (3 - 2 * t); } - - if (!skip5) { - let a5 = yAFlipMask1 + zAFlipMask1 + a1; - if (a5 > 0) { - let x5 = x1; - let y5 = (yNMask | 1) + y1; - let z5 = (zNMask | 1) + z1; - value += - a5 * - a5 * - (a5 * a5) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + (zNMask & (this._PrimeZ << 1)), - x5, - y5, - z5 - ); - } + + /** + * @private + * @param t + * @returns {number} + */ + static _InterpQuintic(t) { + return t * t * t * (t * (t * 6 - 15) + 10); } - - if (!skip9) { - let a9 = xAFlipMask1 + zAFlipMask1 + a1; - if (a9 > 0) { - let x9 = (xNMask | 1) + x1; - let y9 = y1; - let z9 = (zNMask | 1) + z1; - value += - a9 * - a9 * - (a9 * a9) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - x9, - y9, - z9 - ); - } + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} c + * @param {number} d + * @param {number} t + * @returns {number} + */ + static _CubicLerp(a, b, c, d, t) { + const p = d - c - (a - b); + return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; } - - if (!skipD) { - let aD = xAFlipMask1 + yAFlipMask1 + a1; - if (aD > 0) { - let xD = (xNMask | 1) + x1; - let yD = (yNMask | 1) + y1; - value += - aD * - aD * - (aD * aD) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX << 1)), - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - xD, - yD, - z1 - ); + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _PingPong(t) { + t -= Math.trunc(t * 0.5) * 2; + return t < 1 ? t : 2 - t; + } + + /** + * @private + */ + _CalculateFractalBounding() { + let gain = Math.abs(this._Gain); + let amp = gain; + let ampFractal = 1.0; + for (let i = 1; i < this._Octaves; i++) { + ampFractal += amp; + amp *= gain; } + this._FractalBounding = 1 / ampFractal; } - - return value * 9.046026385208288; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleCellularR2(seed, x, y) { + /** - * + * @private * @param {number} seed - * @param {number} x - * @param {number} y + * @param {number} xPrimed + * @param {number} yPrimed * @returns {number} */ - let xr = Math.round(x); - let yr = Math.round(y); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - - let closestHash = 0; - - let cellularJitter = 0.43701595 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - - switch (this._CellularDistanceFunction) { - default: - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY; - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = Math.abs(vecX) + Math.abs(vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = - Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; + _HashR2(seed, xPrimed, yPrimed) { + let hash = seed ^ xPrimed ^ yPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; } - - if ( - this._CellularDistanceFunction === - FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue - ) { - distance0 = Math.sqrt(distance0); - - if ( - this._CellularReturnType !== - FastNoiseLite.CellularReturnType.CellValue - ) { - distance1 = Math.sqrt(distance1); + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _HashR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; + } + + /** + * @private + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @returns {number} + */ + _ValCoordR2(seed, xPrimed, yPrimed) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _ValCoordR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} xd + * @param {number} yd + * @returns {number} + */ + _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + hash ^= hash >> 15; + hash &= 127 << 1; + + let xg = this._Gradients2D[hash]; + let yg = this._Gradients2D[hash | 1]; + + return xd * xg + yd * yg; + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @param {number} xd + * @param {number} yd + * @param {number} zd + * @returns {number} + */ + _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + hash ^= hash >> 15; + hash &= 63 << 2; + + let xg = this._Gradients3D[hash]; + let yg = this._Gradients3D[hash | 1]; + let zg = this._Gradients3D[hash | 2]; + + return xd * xg + yd * yg + zd * zg; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenNoiseSingleR2(seed, x, y) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R2(seed, x, y); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR2(seed, x, y); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR2(seed, x, y); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR2(seed, x, y); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR2(seed, x, y); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR2(seed, x, y); + default: + return 0; } } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenNoiseSingleR3(seed, x, y, z) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R3(seed, x, y, z); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR3(seed, x, y, z); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR3(seed, x, y, z); + default: + return 0; + } } - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleCellularR3(seed, x, y, z) { - let xr = Math.round(x); - let yr = Math.round(y); - let zr = Math.round(z); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - let closestHash = 0; - - let cellularJitter = 0.39614353 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - let zPrimedBase = (zr - 1) * this._PrimeZ; - - switch (this._CellularDistanceFunction) { - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 - ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; + + /** + * @private + */ + _UpdateTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: + this._TransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; + default: + this._TransformType3D = FastNoiseLite.TransformType3D.None; + break; + } + break; + } + } + + /** + * @private + */ + _UpdateWarpTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; + default: + this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; + break; } - xPrimed += this._PrimeX; + break; + } + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalFBmR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR2(seed++, x, y); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + Math.min(noise + 1, 2) * 0.5, + this._WeightedStrength + ); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalFBmR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR3(seed++, x, y, z); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + (noise + 1) * 0.5, + this._WeightedStrength + ); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalRidgedR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalRidgedR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalPingPongR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalPingPongR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleOpenSimplex2R2(seed, x, y) { + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let n0, n1, n2; + + let a = 0.5 - x0 * x0 - y0 * y0; + + if (a <= 0) { + n0 = 0; + } else { + n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); + } + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + + if (c <= 0) { + n2 = 0; + } else { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + n2 = + c * + c * + (c * c) * + this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); + } + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = + b * + b * + (b * b) * + this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = - Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 + } else { + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = + b * + b * + (b * b) * + this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); + } + } + return (n0 + n1 + n2) * 99.83685446303647; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleOpenSimplex2R3(seed, x, y, z) { + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let yNSign = Math.trunc((-1.0 - y0) | 1); + let xNSign = Math.trunc((-1.0 - x0) | 1); + let zNSign = Math.trunc((-1.0 - z0) | 1); + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let value = 0; + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + + for (let l = 0; ; l++) { + if (a > 0) { + value += + a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); + } + + if (ax0 >= ay0 && ax0 >= az0) { + let b = a + ax0 + ax0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i - xNSign * this._PrimeX, + j, + k, + x0 + xNSign, + y0, + z0 ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = - Math.abs(vecX) + - Math.abs(vecY) + - Math.abs(vecZ) + - (vecX * vecX + vecY * vecY + vecZ * vecZ); - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 + } else if (ay0 > ax0 && ay0 >= az0) { + let b = a + ay0 + ay0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j - yNSign * this._PrimeY, + k, + x0, + y0 + yNSign, + z0 + ); + } + } else { + let b = a + az0 + az0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j, + k - zNSign * this._PrimeZ, + x0, + y0, + z0 + zNSign ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; } - xPrimed += this._PrimeX; } - break; - default: - break; - } - - if ( - this._CellularDistanceFunction === - FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue - ) { - distance0 = Math.sqrt(distance0); - - if ( - this._CellularReturnType !== - FastNoiseLite.CellularReturnType.CellValue - ) { - distance1 = Math.sqrt(distance1); + + if (l === 1) { + break; + } + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed = ~seed; } + return value * 32.69428253173828125; } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; - } - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SinglePerlinR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xd0 = x - x0; - let yd0 = y - y0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y0, xd0, yd0), - this._GradCoordR2(seed, x1, y0, xd1, yd0), - xs - ); - let xf1 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y1, xd0, yd1), - this._GradCoordR2(seed, x1, y1, xd1, yd1), - xs - ); - - return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SinglePerlinR3(seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xd0 = x - x0; - let yd0 = y - y0; - let zd0 = z - z0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - let zd1 = zd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - let zs = FastNoiseLite._InterpQuintic(zd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), - this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), - this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), - this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), - xs - ); - let xf11 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), - this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), - xs - ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleValueCubicR2(seed, x, y) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - - let xs = x - x1; - let ys = y - y1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - - return ( - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y0), - this._ValCoordR2(seed, x1, y0), - this._ValCoordR2(seed, x2, y0), - this._ValCoordR2(seed, x3, y0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y1), - this._ValCoordR2(seed, x1, y1), - this._ValCoordR2(seed, x2, y1), - this._ValCoordR2(seed, x3, y1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y2), - this._ValCoordR2(seed, x1, y2), - this._ValCoordR2(seed, x2, y2), - this._ValCoordR2(seed, x3, y2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y3), - this._ValCoordR2(seed, x1, y3), - this._ValCoordR2(seed, x2, y3), - this._ValCoordR2(seed, x3, y3), - xs - ), - ys - ) * - (1 / (1.5 * 1.5)) - ); - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleValueCubicR3(seed, x, y, z) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - let z1 = Math.floor(z); - - let xs = x - x1; - let ys = y - y1; - let zs = z - z1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - z1 = Math.imul(z1, this._PrimeZ); - - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let z0 = z1 - this._PrimeZ; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let z2 = z1 + this._PrimeZ; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - let z3 = z1 + (this._PrimeZ << 1); - - return ( - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - this._ValCoordR3(seed, x2, y0, z0), - this._ValCoordR3(seed, x3, y0, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - this._ValCoordR3(seed, x2, y1, z0), - this._ValCoordR3(seed, x3, y1, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z0), - this._ValCoordR3(seed, x1, y2, z0), - this._ValCoordR3(seed, x2, y2, z0), - this._ValCoordR3(seed, x3, y2, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z0), - this._ValCoordR3(seed, x1, y3, z0), - this._ValCoordR3(seed, x2, y3, z0), - this._ValCoordR3(seed, x3, y3, z0), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - this._ValCoordR3(seed, x2, y0, z1), - this._ValCoordR3(seed, x3, y0, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - this._ValCoordR3(seed, x2, y1, z1), - this._ValCoordR3(seed, x3, y1, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z1), - this._ValCoordR3(seed, x1, y2, z1), - this._ValCoordR3(seed, x2, y2, z1), - this._ValCoordR3(seed, x3, y2, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z1), - this._ValCoordR3(seed, x1, y3, z1), - this._ValCoordR3(seed, x2, y3, z1), - this._ValCoordR3(seed, x3, y3, z1), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z2), - this._ValCoordR3(seed, x1, y0, z2), - this._ValCoordR3(seed, x2, y0, z2), - this._ValCoordR3(seed, x3, y0, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z2), - this._ValCoordR3(seed, x1, y1, z2), - this._ValCoordR3(seed, x2, y1, z2), - this._ValCoordR3(seed, x3, y1, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z2), - this._ValCoordR3(seed, x1, y2, z2), - this._ValCoordR3(seed, x2, y2, z2), - this._ValCoordR3(seed, x3, y2, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z2), - this._ValCoordR3(seed, x1, y3, z2), - this._ValCoordR3(seed, x2, y3, z2), - this._ValCoordR3(seed, x3, y3, z2), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z3), - this._ValCoordR3(seed, x1, y0, z3), - this._ValCoordR3(seed, x2, y0, z3), - this._ValCoordR3(seed, x3, y0, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z3), - this._ValCoordR3(seed, x1, y1, z3), - this._ValCoordR3(seed, x2, y1, z3), - this._ValCoordR3(seed, x3, y1, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z3), - this._ValCoordR3(seed, x1, y2, z3), - this._ValCoordR3(seed, x2, y2, z3), - this._ValCoordR3(seed, x3, y2, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z3), - this._ValCoordR3(seed, x1, y3, z3), - this._ValCoordR3(seed, x2, y3, z3), - this._ValCoordR3(seed, x3, y3, z3), - xs - ), - ys - ), - zs - ) * - (1 / (1.5 * 1.5 * 1.5)) - ); - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleValueR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp( - this._ValCoordR2(seed, x0, y0), - this._ValCoordR2(seed, x1, y0), - xs - ); - let xf1 = FastNoiseLite._Lerp( - this._ValCoordR2(seed, x0, y1), - this._ValCoordR2(seed, x1, y1), - xs - ); - - return FastNoiseLite._Lerp(xf0, xf1, ys); - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleValueR3(seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - let zs = FastNoiseLite._InterpHermite(z - z0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - xs - ); - let xf11 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - xs - ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs); - } - - /** - * @private - */ - _DoSingleDomainWarp() { + /** - * + * @private * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector2} coord * @param {number} x * @param {number} y + * @returns {number} */ - let R2 = (seed, amp, freq, coord, x, y) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 38.283687591552734375, - freq, - coord, - false, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 16.0, - freq, - coord, - true, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); - break; + _SingleOpenSimplex2SR2(seed, x, y) { + // 2D OpenSimplex2S case is a modified 2D simplex noise. + + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + /* + * --- Skew moved to TransformNoiseCoordinate method --- + * final FNLfloat F2 = 0.5f * (SQRT3 - 1); + * FNLfloat s = (x + y) * F2; + * x += s; y += s; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + let i1 = i + this._PrimeX; + let j1 = j + this._PrimeY; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; + let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); + let a1 = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); + let x1 = x0 - (1 - 2 * G2); + let y1 = y0 - (1 - 2 * G2); + value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); + + // Nested conditionals were faster than compact bit logic/arithmetic. + let xmyi = xi - yi; + if (t > G2) { + if (xi + xmyi > 1) { + let x2 = x0 + (3 * G2 - 2); + let y2 = y0 + (3 * G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2( + seed, + i + (this._PrimeX << 1), + j + this._PrimeY, + x2, + y2 + ); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); + } + } + + if (yi - xmyi > 1) { + let x3 = x0 + (3 * G2 - 1); + let y3 = y0 + (3 * G2 - 2); + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2( + seed, + i + this._PrimeX, + j + (this._PrimeY << 1), + x3, + y3 + ); + } + } else { + let x3 = x0 + (G2 - 1); + let y3 = y0 + G2; + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); + } + } + } else { + if (xi + xmyi < 0) { + let x2 = x0 + (1 - G2); + let y2 = y0 - G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); + } + } else { + let x2 = x0 + (G2 - 1); + let y2 = y0 + G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); + } + } + + if (yi < xmyi) { + let x2 = x0 - G2; + let y2 = y0 - (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); + } + } } - }; - + + return value * 18.24196194486065; + } + /** - * + * @private * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector3} coord * @param {number} x * @param {number} y * @param {number} z + * @returns {number} */ - let R3 = (seed, amp, freq, coord, x, y, z) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( + _SingleOpenSimplex2SR3(seed, x, y, z) { + // 3D OpenSimplex2S case uses two offset rotated cube grids. + + /* + * --- Rotation moved to TransformNoiseCoordinate method --- + * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); + * FNLfloat r = (x + y + z) * R3; // Rotation, not skew + * x = r - x; y = r - y; z = r - z; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let k = Math.floor(z); + let xi = x - i; + let yi = y - j; + let zi = z - k; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + let seed2 = seed + 1293373; + + let xNMask = Math.trunc(-0.5 - xi); + let yNMask = Math.trunc(-0.5 - yi); + let zNMask = Math.trunc(-0.5 - zi); + + let x0 = xi + xNMask; + let y0 = yi + yNMask; + let z0 = zi + zNMask; + let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; + let value = + a0 * + a0 * + (a0 * a0) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x0, + y0, + z0 + ); + + let x1 = xi - 0.5; + let y1 = yi - 0.5; + let z1 = zi - 0.5; + let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; + value += + a1 * + a1 * + (a1 * a1) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + this._PrimeZ, + x1, + y1, + z1 + ); + + let xAFlipMask0 = ((xNMask | 1) << 1) * x1; + let yAFlipMask0 = ((yNMask | 1) << 1) * y1; + let zAFlipMask0 = ((zNMask | 1) << 1) * z1; + let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; + let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; + let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; + + let skip5 = false; + let a2 = xAFlipMask0 + a0; + if (a2 > 0) { + let x2 = x0 - (xNMask | 1); + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR3( seed, - amp * 32.69428253173828125, - freq, - coord, - false, - x, - y, - z + i + (~xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x2, + y0, + z0 ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( + } else { + let a3 = yAFlipMask0 + zAFlipMask0 + a0; + + if (a3 > 0) { + let x3 = x0; + let y3 = y0 - (yNMask | 1); + let z3 = z0 - (zNMask | 1); + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x3, + y3, + z3 + ); + } + + let a4 = xAFlipMask1 + a1; + if (a4 > 0) { + let x4 = (xNMask | 1) + x1; + value += + a4 * + a4 * + (a4 * a4) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + this._PrimeZ, + x4, + y1, + z1 + ); + skip5 = true; + } + } + + let skip9 = false; + let a6 = yAFlipMask0 + a0; + if (a6 > 0) { + let x6 = x0; + let y6 = y0 - (yNMask | 1); + value += + a6 * + a6 * + (a6 * a6) * + this._GradCoordR3( seed, - amp * 7.71604938271605, - freq, - coord, - true, - x, - y, - z + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x6, + y6, + z0 ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); - break; + } else { + let a7 = xAFlipMask0 + zAFlipMask0 + a0; + if (a7 > 0) { + let x7 = x0 - (xNMask | 1); + let y7 = y0; + let z7 = z0 - (zNMask | 1); + value += + a7 * + a7 * + (a7 * a7) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x7, + y7, + z7 + ); + } + + let a8 = yAFlipMask1 + a1; + if (a8 > 0) { + let x8 = x1; + let y8 = (yNMask | 1) + y1; + value += + a8 * + a8 * + (a8 * a8) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + x8, + y8, + z1 + ); + skip9 = true; + } } - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - return R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5] - ); - } - - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - return R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); - } - } - - /** - * @private - */ - _DomainWarpSingle() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; + + let skipD = false; + let aA = zAFlipMask0 + a0; + if (aA > 0) { + let xA = x0; + let yA = y0; + let zA = z0 - (zNMask | 1); + value += + aA * + aA * + (aA * aA) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + xA, + yA, + zA + ); + } else { + let aB = xAFlipMask0 + yAFlipMask0 + a0; + if (aB > 0) { + let xB = x0 - (xNMask | 1); + let yB = y0 - (yNMask | 1); + value += + aB * + aB * + (aB * aB) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + xB, + yB, + z0 + ); + } + + let aC = zAFlipMask1 + a1; + if (aC > 0) { + let xC = x1; + let yC = y1; + let zC = (zNMask | 1) + z1; + value += + aC * + aC * + (aC * aC) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + xC, + yC, + zC + ); + skipD = true; } - default: - break; } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - break; + + if (!skip5) { + let a5 = yAFlipMask1 + zAFlipMask1 + a1; + if (a5 > 0) { + let x5 = x1; + let y5 = (yNMask | 1) + y1; + let z5 = (zNMask | 1) + z1; + value += + a5 * + a5 * + (a5 * a5) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + (zNMask & (this._PrimeZ << 1)), + x5, + y5, + z5 + ); } - default: - break; } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } - } - - _DomainWarpFractalProgressive() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - } - default: - break; + + if (!skip9) { + let a9 = xAFlipMask1 + zAFlipMask1 + a1; + if (a9 > 0) { + let x9 = (xNMask | 1) + x1; + let y9 = y1; + let z9 = (zNMask | 1) + z1; + value += + a9 * + a9 * + (a9 * a9) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + x9, + y9, + z9 + ); } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; } - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - } - break; - default: - break; + + if (!skipD) { + let aD = xAFlipMask1 + yAFlipMask1 + a1; + if (aD > 0) { + let xD = (xNMask | 1) + x1; + let yD = (yNMask | 1) + y1; + value += + aD * + aD * + (aD * aD) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX << 1)), + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + xD, + yD, + z1 + ); } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; } - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); + + return value * 9.046026385208288; } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } - } - - /** - * @private - */ - _DomainWarpFractalIndependent() { + /** - * - * @param {Vector2} coord + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} */ - let R2 = (coord) => { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - } + _SingleCellularR2(seed, x, y) { + /** + * + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + let xr = Math.round(x); + let yr = Math.round(y); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + + let closestHash = 0; + + let cellularJitter = 0.43701595 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + + switch (this._CellularDistanceFunction) { default: + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY; + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = Math.abs(vecX) + Math.abs(vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } break; } - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + + if ( + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue + ) { + distance1 = Math.sqrt(distance1); + } } - }; - + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; + } + } + /** - * - * @param {Vector3} coord + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} */ - let R3 = (coord) => { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; + _SingleCellularR3(seed, x, y, z) { + let xr = Math.round(x); + let yr = Math.round(y); + let zr = Math.round(z); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + let closestHash = 0; + + let cellularJitter = 0.39614353 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + let zPrimedBase = (zr - 1) * this._PrimeZ; + + switch (this._CellularDistanceFunction) { + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; } break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; } break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = + Math.abs(vecX) + + Math.abs(vecY) + + Math.abs(vecZ) + + (vecX * vecX + vecY * vecY + vecZ * vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; } break; default: break; } - - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + + if ( + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue + ) { + distance1 = Math.sqrt(distance1); + } + } + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; } - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); } - } - - /** - * @private - */ - _SingleDomainWarpBasicGrid() { + /** - * + * @private * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord * @param {number} x * @param {number} y + * @returns {number} */ - - let R2 = (seed, warpAmp, frequency, coord, x, y) => { - let xf = x * frequency; - let yf = y * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - + _SinglePerlinR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xd0 = x - x0; + let yd0 = y - y0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + x0 = Math.imul(x0, this._PrimeX); y0 = Math.imul(y0, this._PrimeY); let x1 = x0 + this._PrimeX; let y1 = y0 + this._PrimeY; - - let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); - let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); - - let lx0x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0], - this._RandVecs2D[hash1], - xs - ); - let ly0x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0 | 1], - this._RandVecs2D[hash1 | 1], - xs - ); - - hash0 = this._HashR2(seed, x0, y1) & (255 << 1); - hash1 = this._HashR2(seed, x1, y1) & (255 << 1); - - let lx1x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0], - this._RandVecs2D[hash1], + + let xf0 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y0, xd0, yd0), + this._GradCoordR2(seed, x1, y0, xd1, yd0), xs ); - let ly1x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0 | 1], - this._RandVecs2D[hash1 | 1], + let xf1 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y1, xd0, yd1), + this._GradCoordR2(seed, x1, y1, xd1, yd1), xs ); - - coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; - coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; - }; - + + return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; + } + /** - * + * @private * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord * @param {number} x * @param {number} y * @param {number} z + * @returns {number} */ - let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { - let xf = x * frequency; - let yf = y * frequency; - let zf = z * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - let z0 = Math.floor(zf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - let zs = FastNoiseLite._InterpHermite(zf - z0); - + _SinglePerlinR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xd0 = x - x0; + let yd0 = y - y0; + let zd0 = z - z0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + let zd1 = zd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + let zs = FastNoiseLite._InterpQuintic(zd0); + x0 = Math.imul(x0, this._PrimeX); y0 = Math.imul(y0, this._PrimeY); z0 = Math.imul(z0, this._PrimeZ); let x1 = x0 + this._PrimeX; let y1 = y0 + this._PrimeY; let z1 = z0 + this._PrimeZ; - - let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); - let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); - - let lx0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], + + let xf00 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), + this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), xs ); - let ly0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], + let xf10 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), + this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), xs ); - let lz0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], + let xf01 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), + this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), xs ); - - hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); - - let lx1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], + let xf11 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), + this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), xs ); - let ly1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueCubicR2(seed, x, y) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + + let xs = x - x1; + let ys = y - y1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), + this._ValCoordR2(seed, x2, y0), + this._ValCoordR2(seed, x3, y0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), + this._ValCoordR2(seed, x2, y1), + this._ValCoordR2(seed, x3, y1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y2), + this._ValCoordR2(seed, x1, y2), + this._ValCoordR2(seed, x2, y2), + this._ValCoordR2(seed, x3, y2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y3), + this._ValCoordR2(seed, x1, y3), + this._ValCoordR2(seed, x2, y3), + this._ValCoordR2(seed, x3, y3), + xs + ), + ys + ) * + (1 / (1.5 * 1.5)) ); - let lz1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueCubicR3(seed, x, y, z) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + let z1 = Math.floor(z); + + let xs = x - x1; + let ys = y - y1; + let zs = z - z1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + z1 = Math.imul(z1, this._PrimeZ); + + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let z0 = z1 - this._PrimeZ; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let z2 = z1 + this._PrimeZ; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + let z3 = z1 + (this._PrimeZ << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + this._ValCoordR3(seed, x2, y0, z0), + this._ValCoordR3(seed, x3, y0, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + this._ValCoordR3(seed, x2, y1, z0), + this._ValCoordR3(seed, x3, y1, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z0), + this._ValCoordR3(seed, x1, y2, z0), + this._ValCoordR3(seed, x2, y2, z0), + this._ValCoordR3(seed, x3, y2, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z0), + this._ValCoordR3(seed, x1, y3, z0), + this._ValCoordR3(seed, x2, y3, z0), + this._ValCoordR3(seed, x3, y3, z0), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + this._ValCoordR3(seed, x2, y0, z1), + this._ValCoordR3(seed, x3, y0, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + this._ValCoordR3(seed, x2, y1, z1), + this._ValCoordR3(seed, x3, y1, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z1), + this._ValCoordR3(seed, x1, y2, z1), + this._ValCoordR3(seed, x2, y2, z1), + this._ValCoordR3(seed, x3, y2, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z1), + this._ValCoordR3(seed, x1, y3, z1), + this._ValCoordR3(seed, x2, y3, z1), + this._ValCoordR3(seed, x3, y3, z1), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z2), + this._ValCoordR3(seed, x1, y0, z2), + this._ValCoordR3(seed, x2, y0, z2), + this._ValCoordR3(seed, x3, y0, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z2), + this._ValCoordR3(seed, x1, y1, z2), + this._ValCoordR3(seed, x2, y1, z2), + this._ValCoordR3(seed, x3, y1, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z2), + this._ValCoordR3(seed, x1, y2, z2), + this._ValCoordR3(seed, x2, y2, z2), + this._ValCoordR3(seed, x3, y2, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z2), + this._ValCoordR3(seed, x1, y3, z2), + this._ValCoordR3(seed, x2, y3, z2), + this._ValCoordR3(seed, x3, y3, z2), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z3), + this._ValCoordR3(seed, x1, y0, z3), + this._ValCoordR3(seed, x2, y0, z3), + this._ValCoordR3(seed, x3, y0, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z3), + this._ValCoordR3(seed, x1, y1, z3), + this._ValCoordR3(seed, x2, y1, z3), + this._ValCoordR3(seed, x3, y1, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z3), + this._ValCoordR3(seed, x1, y2, z3), + this._ValCoordR3(seed, x2, y2, z3), + this._ValCoordR3(seed, x3, y2, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z3), + this._ValCoordR3(seed, x1, y3, z3), + this._ValCoordR3(seed, x2, y3, z3), + this._ValCoordR3(seed, x3, y3, z3), + xs + ), + ys + ), + zs + ) * + (1 / (1.5 * 1.5 * 1.5)) ); - - let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); - let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); - let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); - - hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); - - lx0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), xs ); - ly0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], + let xf1 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), xs ); - lz0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], + + return FastNoiseLite._Lerp(xf0, xf1, ys); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + let zs = FastNoiseLite._InterpHermite(z - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), xs ); - - hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); - - lx1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], + let xf10 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), xs ); - ly1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], + let xf01 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), xs ); - lz1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], + let xf11 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), xs ); - - coord.x += - FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * - warpAmp; - coord.y += - FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * - warpAmp; - coord.z += - FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * - warpAmp; - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5] - ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs); + } + + /** + * @private + */ + _DoSingleDomainWarp() { + /** + * + * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + let R2 = (seed, amp, freq, coord, x, y) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 38.283687591552734375, + freq, + coord, + false, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 16.0, + freq, + coord, + true, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); + break; + } + }; + + /** + * + * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, amp, freq, coord, x, y, z) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 32.69428253173828125, + freq, + coord, + false, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 7.71604938271605, + freq, + coord, + true, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); + break; + } + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + return R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] + ); + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + return R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + } + + /** + * @private + */ + _DomainWarpSingle() { + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + } + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + break; + } + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } } - - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); + + _DomainWarpFractalProgressive() { + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + } + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + } + break; + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } } - } - - /** - * @private - */ - _SingleDomainWarpOpenSimplex2Gradient() { + /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y + * @private */ - let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - x *= frequency; - y *= frequency; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let vx, vy; - vx = vy = 0; - - let a = 0.5 - x0 * x0 - y0 * y0; - if (a > 0) { - let aaaa = a * a * (a * a); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i, j) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i, j); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x0 * xg + y0 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; + _DomainWarpFractalIndependent() { + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + } + default: + break; } - vx += aaaa * xo; - vy += aaaa * yo; - } - - let c = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - if (c > 0) { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - let cccc = c * c * (c * c); - let xo, yo; - if (outGradOnly) { - let hash = - this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & - (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x2 * xg + y2 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + } + break; + default: + break; + } + + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; } - vx += cccc * xo; - vy += cccc * yo; + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); } - - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + /** + * @private + */ + _SingleDomainWarpBasicGrid() { + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + + let R2 = (seed, warpAmp, frequency, coord, x, y) => { + let xf = x * frequency; + let yf = y * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); + let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + hash0 = this._HashR2(seed, x0, y1) & (255 << 1); + hash1 = this._HashR2(seed, x1, y1) & (255 << 1); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; + coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { + let xf = x * frequency; + let yf = y * frequency; + let zf = z * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + let z0 = Math.floor(zf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + let zs = FastNoiseLite._InterpHermite(zf - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); + let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); + let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); + let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); + + hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); + + lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); + + lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + coord.x += + FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * + warpAmp; + coord.y += + FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * + warpAmp; + coord.z += + FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * + warpAmp; + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] + ); + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + } + + /** + * @private + */ + _SingleDomainWarpOpenSimplex2Gradient() { + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + */ + let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + x *= frequency; + y *= frequency; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let vx, vy; + vx = vy = 0; + + let a = 0.5 - x0 * x0 - y0 * y0; + if (a > 0) { + let aaaa = a * a * (a * a); let xo, yo; if (outGradOnly) { - let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); + let hash = this._HashR2(seed, i, j) & (255 << 1); xo = this._RandVecs2D[hash]; yo = this._RandVecs2D[hash | 1]; } else { - let hash = this._HashR2(seed, i, j + this._PrimeY); + let hash = this._HashR2(seed, i, j); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); let xg = this._Gradients2D[index1]; let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; + let value = x0 * xg + y0 * yg; let xgo = this._RandVecs2D[index2]; let ygo = this._RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } - vx += bbbb * xo; - vy += bbbb * yo; + vx += aaaa * xo; + vy += aaaa * yo; } - } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + if (c > 0) { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + let cccc = c * c * (c * c); let xo, yo; if (outGradOnly) { - let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); + let hash = + this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & + (255 << 1); xo = this._RandVecs2D[hash]; yo = this._RandVecs2D[hash | 1]; } else { - let hash = this._HashR2(seed, i + this._PrimeX, j); + let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); let xg = this._Gradients2D[index1]; let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; + let value = x2 * xg + y2 * yg; let xgo = this._RandVecs2D[index2]; let ygo = this._RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } - vx += bbbb * xo; - vy += bbbb * yo; + vx += cccc * xo; + vy += cccc * yo; } - } - - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - }; - - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { - x *= frequency; - y *= frequency; - z *= frequency; - - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let xNSign = (-x0 - 1.0) | 1; - let yNSign = (-y0 - 1.0) | 1; - let zNSign = (-z0 - 1.0) | 1; - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let vx, vy, vz; - vx = vy = vz = 0; - - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - for (let l = 0; ; l++) { - if (a > 0) { - let aaaa = a * a * (a * a); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i, j, k) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; - } else { - let hash = this._HashR3(seed, i, j, k); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x0 * xg + y0 * yg + z0 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i, j + this._PrimeY); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x1 * xg + y1 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += bbbb * xo; + vy += bbbb * yo; } - vx += aaaa * xo; - vy += aaaa * yo; - vz += aaaa * zo; - } - - let b = a; - let i1 = i; - let j1 = j; - let k1 = k; - let x1 = x0; - let y1 = y0; - let z1 = z0; - - if (ax0 >= ay0 && ax0 >= az0) { - x1 += xNSign; - b = b + ax0 + ax0; - i1 -= xNSign * this._PrimeX; - } else if (ay0 > ax0 && ay0 >= az0) { - y1 += yNSign; - b = b + ay0 + ay0; - j1 -= yNSign * this._PrimeY; } else { - z1 += zNSign; - b = b + az0 + az0; - k1 -= zNSign * this._PrimeZ; + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i + this._PrimeX, j); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x1 * xg + y1 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += bbbb * xo; + vy += bbbb * yo; + } } - - if (b > 1) { - b -= 1; - let bbbb = b * b * (b * b); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { + x *= frequency; + y *= frequency; + z *= frequency; + + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let xNSign = (-x0 - 1.0) | 1; + let yNSign = (-y0 - 1.0) | 1; + let zNSign = (-z0 - 1.0) | 1; + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let vx, vy, vz; + vx = vy = vz = 0; + + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + for (let l = 0; ; l++) { + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i, j, k) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i, j, k); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x0 * xg + y0 * yg + z0 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; + } + vx += aaaa * xo; + vy += aaaa * yo; + vz += aaaa * zo; + } + + let b = a; + let i1 = i; + let j1 = j; + let k1 = k; + let x1 = x0; + let y1 = y0; + let z1 = z0; + + if (ax0 >= ay0 && ax0 >= az0) { + x1 += xNSign; + b = b + ax0 + ax0; + i1 -= xNSign * this._PrimeX; + } else if (ay0 > ax0 && ay0 >= az0) { + y1 += yNSign; + b = b + ay0 + ay0; + j1 -= yNSign * this._PrimeY; } else { - let hash = this._HashR3(seed, i1, j1, k1); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x1 * xg + y1 * yg + z1 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; + z1 += zNSign; + b = b + az0 + az0; + k1 -= zNSign * this._PrimeZ; + } + + if (b > 1) { + b -= 1; + let bbbb = b * b * (b * b); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i1, j1, k1); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x1 * xg + y1 * yg + z1 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; + } + vx += bbbb * xo; + vy += bbbb * yo; + vz += bbbb * zo; } - vx += bbbb * xo; - vy += bbbb * yo; - vz += bbbb * zo; + + if (l === 1) break; + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed += 1293373; } - - if (l === 1) break; - - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; - - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; - - a += 0.75 - ax0 - (ay0 + az0); - - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; - - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; - - seed += 1293373; + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + coord.z += vz * warpAmp; + }; + + if (arguments.length === 7) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + + if (arguments.length === 8) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6], + arguments[7] + ); } - - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - coord.z += vz * warpAmp; - }; - - if (arguments.length === 7) { - R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); - } - - if (arguments.length === 8) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6], - arguments[7] - ); } } - } - - class Vector2 { - /** - * 2d Vector - * @param {number} x - * @param {number} y - */ - constructor(x, y) { - this.x = x; - this.y = y; + + class Vector2 { + /** + * 2d Vector + * @param {number} x + * @param {number} y + */ + constructor(x, y) { + this.x = x; + this.y = y; + } } - } - - class Vector3 { - /** - * 3d Vector - * @param {number} x - * @param {number} y - * @param {number} z - */ - constructor(x, y, z) { - this.x = x; - this.y = y; - this.z = z; + + class Vector3 { + /** + * 3d Vector + * @param {number} x + * @param {number} y + * @param {number} z + */ + constructor(x, y, z) { + this.x = x; + this.y = y; + this.z = z; + } } - } - - Scratch.extensions.register(new Noise()); -})(Scratch); + + Scratch.extensions.register(new Noise()); + })(Scratch); + \ No newline at end of file From 96fc087345cc23b20b644aae1f4b64f69643722b Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 19:08:33 -0700 Subject: [PATCH 23/36] fixed everything --- extensions/Corbnorb/noise.js | 6416 +++++++++++++++++----------------- 1 file changed, 3181 insertions(+), 3235 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index d542501e7c..0cd8f13480 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -6,65 +6,6 @@ // License: MPL-2.0 (function (Scratch) { -<<<<<<< HEAD - "use strict"; - - const noises = Object.create(null); - - const BlockType = Scratch.BlockType; - const ArgumentType = Scratch.ArgumentType; - const Cast = Scratch.Cast; - const Translate = Scratch.translate; - - class Noise { - constructor() { - this.noiseSeed = 0; - this.worleySeed = 0; - this.time = performance.now(); - } - - getInfo() { - return { - id: "corbnorbsnoise", - name: Translate("Noise"), - color1: "#b5074c", - color2: "#990841", - docsURI: "https://extensions.turbowarp.org/Corbnorb/noise", - blocks: [ - { - opcode: "initNoise", - blockType: BlockType.COMMAND, - text: Translate( - "create noise id:[ID] seed:[SEED] type:[TYPE] octaves:[OCTAVES] frequency:[FREQUENCY] fractal:[FRACTAL]" - ), - arguments: { - ID: { - type: ArgumentType.STRING, - defaultValue: "myNoise", - }, - SEED: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - TYPE: { - type: ArgumentType.STRING, - menu: "NOISE_TYPE", - defaultValue: "Perlin", - }, - OCTAVES: { - type: ArgumentType.NUMBER, - defaultValue: "1", - }, - FREQUENCY: { - type: ArgumentType.NUMBER, - defaultValue: "0.01", - }, - FRACTAL: { - type: ArgumentType.STRING, - menu: "FRACTAL_TYPE", - defaultValue: "FBm", - }, -======= "use strict"; const noises = Object.create(null); @@ -75,6 +16,12 @@ const Translate = Scratch.translate; class Noise { + constructor() { + this.noiseSeed = 0; + this.worleySeed = 0; + this.time = performance.now(); + } + getInfo() { return { id: "corbnorbsnoise", @@ -115,2621 +62,2709 @@ type: ArgumentType.STRING, menu: "FRACTAL_TYPE", defaultValue: "FBm", ->>>>>>> 495db9644590021214cca311fc9df2fd6f8c5c88 }, }, - { - opcode: "getNoise", - blockType: BlockType.REPORTER, - text: Translate( - "get noise id:[ID] at x:[X] y:[Y] z:[Z] easing:[EASING] inverted?[INVERTED]" - ), - arguments: { - ID: { - type: ArgumentType.STRING, - defaultValue: "myNoise", - }, - X: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - Y: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - Z: { - type: ArgumentType.NUMBER, - defaultValue: "0", - }, - INVERTED: { - type: ArgumentType.STRING, - menu: "INVERTED_MENU", - defaultValue: "false", - }, - EASING: { - type: ArgumentType.STRING, - menu: "EASING_TYPE", - defaultValue: "Linear", - }, + }, + { + opcode: "getNoise", + blockType: BlockType.REPORTER, + text: Translate( + "get noise id:[ID] at x:[X] y:[Y] z:[Z] easing:[EASING] inverted?[INVERTED]" + ), + arguments: { + ID: { + type: ArgumentType.STRING, + defaultValue: "myNoise", + }, + X: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + Y: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + Z: { + type: ArgumentType.NUMBER, + defaultValue: "0", + }, + INVERTED: { + type: ArgumentType.STRING, + menu: "INVERTED_MENU", + defaultValue: "false", + }, + EASING: { + type: ArgumentType.STRING, + menu: "EASING_TYPE", + defaultValue: "Linear", }, - }, - ], - menus: { - NOISE_TYPE: { - acceptReporters: true, - items: [ - "openSimpex2", - "openSimpex2S", - "cellular", - "perlin", - "value Cubic", - "value", - ], - }, - FRACTAL_TYPE: { - acceptReporters: true, - items: ["none", "fbm", "ridged", "ping Pong"], - }, - INVERTED_MENU: { - acceptReporters: true, - items: [ - { text: "true", value: "true" }, - { text: "false", value: "false" }, - ], - }, - EASING_TYPE: { - acceptReporters: true, - items: ["linear", "squared", "cubed", "root"], }, }, - }; - } - - initNoise(args) { - const id = Cast.toString(args.ID); - const seed = Cast.toNumber(args.SEED); - const fractal = Cast.toString(args.FRACTAL); - const frequency = Cast.toNumber(args.FREQUENCY); - const octaves = Cast.toNumber(args.OCTAVES); - noises[id] = new FastNoiseLite(seed); - switch (args.TYPE) { - case "openSimplex2": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); + ], + menus: { + NOISE_TYPE: { + acceptReporters: true, + items: [ + "openSimpex2", + "openSimpex2S", + "cellular", + "perlin", + "value Cubic", + "value", + ], + }, + FRACTAL_TYPE: { + acceptReporters: true, + items: ["none", "fbm", "ridged", "ping Pong"], + }, + INVERTED_MENU: { + acceptReporters: true, + items: [ + { text: "true", value: "true" }, + { text: "false", value: "false" }, + ], + }, + EASING_TYPE: { + acceptReporters: true, + items: ["linear", "squared", "cubed", "root"], + }, + }, + }; + } + + initNoise(args) { + const id = Cast.toString(args.ID); + const seed = Cast.toNumber(args.SEED); + const fractal = Cast.toString(args.FRACTAL); + const frequency = Cast.toNumber(args.FREQUENCY); + const octaves = Cast.toNumber(args.OCTAVES); + noises[id] = new FastNoiseLite(seed); + switch (args.TYPE) { + case "openSimplex2": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); + break; + case "openSimplex2S": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2S); + break; + case "cellular": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Cellular); + break; + case "perlin": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); + break; + case "value cubic": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.ValueCubic); + break; + case "value": + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Value); + break; + default: + noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); + break; + } + switch (fractal) { + case "none": + noises[id].SetFractalType(FastNoiseLite.FractalType.None); + break; + case "fbm": + noises[id].SetFractalType(FastNoiseLite.FractalType.FBm); + break; + case "ridged": + noises[id].SetFractalType(FastNoiseLite.FractalType.Ridged); + break; + case "ping pong": + noises[id].SetFractalType(FastNoiseLite.FractalType.PingPong); + break; + default: + noises[id].SetFractalType(FastNoiseLite.FractalType.None); + break; + } + noises[id].SetFrequency(frequency); + noises[id].SetFractalOctaves(octaves); + } + + getNoise(args) { + const id = Cast.toString(args.ID); + const easing = Cast.toString(args.EASING); + const inverted = Cast.toBoolean(args.INVERTED); + if (id in noises) { + let value = noises[id].GetNoise(args.X, args.Y, args.Z); + value = (inverted == true) ? -value : value; + value = (value + 1) / 2; + switch (easing) { + case "linear": break; - case "openSimplex2S": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2S); + case "squared": + value = Math.pow(value, 2); break; - case "cellular": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Cellular); + case "cubed": + value = Math.pow(value, 3); break; - case "perlin": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); + case "root": + value = Math.sqrt(Math.abs(value)); break; - case "value cubic": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.ValueCubic); + default: break; - case "value": - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Value); + } + value = value * 2 - 1; + return value; + } + console.log("ISSUE"); + return 0; + } + } + + // MIT License + // + // Copyright(c) 2023 Jordan Peck (jordan.me2@gmail.com) + // Copyright(c) 2023 Contributors + // + // Permission is hereby granted, free of charge, to any person obtaining a copy + // of this software and associated documentation files(the "Software"), to deal + // in the Software without restriction, including without limitation the rights + // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell + // copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions : + // + // The above copyright notice and this permission notice shall be included in all + // copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + // SOFTWARE. + // + + class FastNoiseLite { + static NoiseType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2S: "OpenSimplex2S", + Cellular: "Cellular", + Perlin: "Perlin", + ValueCubic: "ValueCubic", + Value: "Value", + }); + static RotationType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + }); + static FractalType = Object.freeze({ + None: "None", + FBm: "FBm", + Ridged: "Ridged", + PingPong: "PingPong", + DomainWarpProgressive: "DomainWarpProgressive", + DomainWarpIndependent: "DomainWarpIndependent", + }); + static CellularDistanceFunction = Object.freeze({ + Euclidean: "Euclidean", + EuclideanSq: "EuclideanSq", + Manhattan: "Manhattan", + Hybrid: "Hybrid", + }); + static CellularReturnType = Object.freeze({ + CellValue: "CellValue", + Distance: "Distance", + Distance2: "Distance2", + Distance2Add: "Distance2Add", + Distance2Sub: "Distance2Sub", + Distance2Mul: "Distance2Mul", + Distance2Div: "Distance2Div", + }); + static DomainWarpType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2Reduced: "OpenSimplex2Reduced", + BasicGrid: "BasicGrid", + }); + static TransformType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + DefaultOpenSimplex2: "DefaultOpenSimplex2", + }); + + /* Private */ + _Seed = 1337; + _Frequency = 0.01; + _NoiseType = FastNoiseLite.NoiseType.OpenSimplex2; + _RotationType3D = FastNoiseLite.RotationType3D.None; + _TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + _DomainWarpAmp = 1.0; + + _FractalType = FastNoiseLite.FractalType.None; + _Octaves = 3; + _Lacunarity = 2.0; + _Gain = 0.5; + _WeightedStrength = 0.0; + _PingPongStrength = 2.0; + + _FractalBounding = 1 / 1.75; + + _CellularDistanceFunction = + FastNoiseLite.CellularDistanceFunction.EuclideanSq; + _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; + _CellularJitterModifier = 1.0; + + _DomainWarpType = FastNoiseLite.DomainWarpType.OpenSimplex2; + _WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + + /** + * @description Create new FastNoiseLite object with optional seed + * @param {number} [seed] + * @constructor + */ + constructor(seed) { + if (seed !== undefined) { + this._Seed = seed; + } + } + + /** + * @description Sets seed used for all noise types + * @remarks Default: 1337 + * @default 1337 + * @param {number} seed + */ + SetSeed(seed) { + this._Seed = seed; + } + + /** + * @description Sets frequency for all noise types + * @remarks Default: 0.01 + * @default 0.01 + * @param {number} frequency + */ + SetFrequency(frequency) { + this._Frequency = frequency; + } + + /** + * @description Sets noise algorithm used for GetNoise(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.NoiseType.OpenSimplex2 + * @param {FastNoiseLite.NoiseType} noiseType + */ + SetNoiseType(noiseType) { + this._NoiseType = noiseType; + this._UpdateTransformType3D(); + } + + /** + * @description Sets domain rotation type for 3D Noise and 3D DomainWarp. + * @description Can aid in reducing directional artifacts when sampling a 2D plane in 3D + * @remarks Default: None + * @default FastNoiseLite.RotationType3D.None + * @param {FastNoiseLite.RotationType3D} rotationType3D + */ + SetRotationType3D(rotationType3D) { + this._RotationType3D = rotationType3D; + this._UpdateTransformType3D(); + this._UpdateWarpTransformType3D(); + } + + /** + * @description Sets method for combining octaves in all fractal noise types + * @remarks Default: None + * @default FastNoiseLite.FractalType.None + * @param {FastNoiseLite.FractalType} fractalType + */ + SetFractalType(fractalType) { + this._FractalType = fractalType; + } + + /** + * @description Sets octave count for all fractal noise types + * @remarks Default: 3 + * @default 3 + * @param {number} octaves + */ + SetFractalOctaves(octaves) { + this._Octaves = octaves; + this._CalculateFractalBounding(); + } + + /** + * @description Sets octave lacunarity for all fractal noise types + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} lacunarity + */ + SetFractalLacunarity(lacunarity) { + this._Lacunarity = lacunarity; + } + + /** + * @description Sets octave gain for all fractal noise types + * @remarks Default: 0.5 + * @default 0.5 + * @param {number} gain + */ + SetFractalGain(gain) { + this._Gain = gain; + this._CalculateFractalBounding(); + } + + /** + * @description Sets octave weighting for all none DomainWarp fratal types + * @remarks Default: 0.0 | Keep between 0...1 to maintain -1...1 output bounding + * @default 0.5 + * @param {number} weightedStrength + */ + SetFractalWeightedStrength(weightedStrength) { + this._WeightedStrength = weightedStrength; + } + + /** + * @description Sets strength of the fractal ping pong effect + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} pingPongStrength + */ + SetFractalPingPongStrength(pingPongStrength) { + this._PingPongStrength = pingPongStrength; + } + + /** + * @description Sets distance function used in cellular noise calculations + * @remarks Default: EuclideanSq + * @default FastNoiseLite.CellularDistanceFunction.EuclideanSq + * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction + */ + SetCellularDistanceFunction(cellularDistanceFunction) { + this._CellularDistanceFunction = cellularDistanceFunction; + } + + /** + * @description Sets return type from cellular noise calculations + * @remarks Default: Distance + * @default FastNoiseLite.CellularReturnType.Distance + * @param {FastNoiseLite.CellularReturnType} cellularReturnType + */ + SetCellularReturnType(cellularReturnType) { + this._CellularReturnType = cellularReturnType; + } + + /** + * @description Sets the maximum distance a cellular point can move from it's grid position + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} cellularJitter + */ + SetCellularJitter(cellularJitter) { + this._CellularJitterModifier = cellularJitter; + } + + /** + * @description Sets the warp algorithm when using DomainWarp(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.DomainWarpType.OpenSimplex2 + * @param {FastNoiseLite.DomainWarpType} domainWarpType + */ + SetDomainWarpType(domainWarpType) { + this._DomainWarpType = domainWarpType; + this._UpdateWarpTransformType3D(); + } + + /** + * @description Sets the maximum warp distance from original position when using DomainWarp(...) + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} domainWarpAmp + */ + SetDomainWarpAmp(domainWarpAmp) { + this._DomainWarpAmp = domainWarpAmp; + } + + /** + * @description 2D/3D noise at given position using current settings + * @param {number} x X coordinate + * @param {number} y Y coordinate + * @param {number} [z] Z coordinate + * @return {number} Noise output bounded between -1...1 + */ + GetNoise(x, y, z) { + /** + * @description 2D noise at given position using current settings + * @param {number} x + * @param {number} y + * @return {number} Noise output bounded between -1...1 + */ + let R2 = (x, y) => { + x *= this._Frequency; + y *= this._Frequency; + + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (x + y) * F2; + x += t; + y += t; break; + } default: - noises[id].SetNoiseType(FastNoiseLite.NoiseType.Perlin); break; } - switch (fractal) { - case "none": - noises[id].SetFractalType(FastNoiseLite.FractalType.None); - break; - case "fbm": - noises[id].SetFractalType(FastNoiseLite.FractalType.FBm); + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR2(this._Seed, x, y); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR2(x, y); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR2(x, y); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR2(x, y); + } + }; + + /** + * @description 3D noise at given position using current settings + * @param {number} x + * @param {number} y + * @param {number} z + * @return {number} Noise output bounded between -1...1 + */ + let R3 = (x, y, z) => { + x *= this._Frequency; + y *= this._Frequency; + z *= this._Frequency; + + switch (this._TransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: { + let xy = x + y; + let s2 = xy * -0.211324865405187; + z *= 0.577350269189626; + x += s2 - z; + y += s2 - z; + z += xy * 0.577350269189626; break; - case "ridged": - noises[id].SetFractalType(FastNoiseLite.FractalType.Ridged); + } + case FastNoiseLite.TransformType3D.ImproveXZPlanes: { + let xz = x + z; + let s2 = xz * -0.211324865405187; + y *= 0.577350269189626; + x += s2 - y; + z += s2 - y; + y += xz * 0.577350269189626; break; - case "ping pong": - noises[id].SetFractalType(FastNoiseLite.FractalType.PingPong); + } + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + const R3 = 2.0 / 3.0; + let r = (x + y + z) * R3; + x = r - x; + y = r - y; + z = r - z; break; + } default: - noises[id].SetFractalType(FastNoiseLite.FractalType.None); break; } - noises[id].SetFrequency(frequency); - noises[id].SetFractalOctaves(octaves); - } - - getNoise(args) { - const id = Cast.toString(args.ID); - const easing = Cast.toString(args.EASING); - const inverted = Cast.toBoolean(args.INVERTED); - if (id in noises) { - let value = noises[id].GetNoise(args.X, args.Y, args.Z); - value = (inverted == true) ? -value : value; - value = (value + 1) / 2; - switch (easing) { - case "linear": - break; - case "squared": - value = Math.pow(value, 2); - break; - case "cubed": - value = Math.pow(value, 3); - break; - case "root": - value = Math.sqrt(Math.abs(value)); - break; - default: - break; - } - value = value * 2 - 1; - return value; - } - console.log("ISSUE"); - return 0; - } - } - - // MIT License - // - // Copyright(c) 2023 Jordan Peck (jordan.me2@gmail.com) - // Copyright(c) 2023 Contributors - // - // Permission is hereby granted, free of charge, to any person obtaining a copy - // of this software and associated documentation files(the "Software"), to deal - // in the Software without restriction, including without limitation the rights - // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - // copies of the Software, and to permit persons to whom the Software is - // furnished to do so, subject to the following conditions : - // - // The above copyright notice and this permission notice shall be included in all - // copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - // SOFTWARE. - // - - class FastNoiseLite { - static NoiseType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2S: "OpenSimplex2S", - Cellular: "Cellular", - Perlin: "Perlin", - ValueCubic: "ValueCubic", - Value: "Value", - }); - static RotationType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", - }); - static FractalType = Object.freeze({ - None: "None", - FBm: "FBm", - Ridged: "Ridged", - PingPong: "PingPong", - DomainWarpProgressive: "DomainWarpProgressive", - DomainWarpIndependent: "DomainWarpIndependent", - }); - static CellularDistanceFunction = Object.freeze({ - Euclidean: "Euclidean", - EuclideanSq: "EuclideanSq", - Manhattan: "Manhattan", - Hybrid: "Hybrid", - }); - static CellularReturnType = Object.freeze({ - CellValue: "CellValue", - Distance: "Distance", - Distance2: "Distance2", - Distance2Add: "Distance2Add", - Distance2Sub: "Distance2Sub", - Distance2Mul: "Distance2Mul", - Distance2Div: "Distance2Div", - }); - static DomainWarpType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2Reduced: "OpenSimplex2Reduced", - BasicGrid: "BasicGrid", - }); - static TransformType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", - DefaultOpenSimplex2: "DefaultOpenSimplex2", - }); - - /* Private */ - _Seed = 1337; - _Frequency = 0.01; - _NoiseType = FastNoiseLite.NoiseType.OpenSimplex2; - _RotationType3D = FastNoiseLite.RotationType3D.None; - _TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - _DomainWarpAmp = 1.0; - - _FractalType = FastNoiseLite.FractalType.None; - _Octaves = 3; - _Lacunarity = 2.0; - _Gain = 0.5; - _WeightedStrength = 0.0; - _PingPongStrength = 2.0; - - _FractalBounding = 1 / 1.75; - - _CellularDistanceFunction = - FastNoiseLite.CellularDistanceFunction.EuclideanSq; - _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; - _CellularJitterModifier = 1.0; - - _DomainWarpType = FastNoiseLite.DomainWarpType.OpenSimplex2; - _WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - - /** - * @description Create new FastNoiseLite object with optional seed - * @param {number} [seed] - * @constructor - */ - constructor(seed) { - if (seed !== undefined) { - this._Seed = seed; + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR3(this._Seed, x, y, z); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR3(x, y, z); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR3(x, y, z); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR3(x, y, z); } + }; + + if (arguments.length === 2) { + return R2(x, y); } - - /** - * @description Sets seed used for all noise types - * @remarks Default: 1337 - * @default 1337 - * @param {number} seed - */ - SetSeed(seed) { - this._Seed = seed; - } - - /** - * @description Sets frequency for all noise types - * @remarks Default: 0.01 - * @default 0.01 - * @param {number} frequency - */ - SetFrequency(frequency) { - this._Frequency = frequency; - } - - /** - * @description Sets noise algorithm used for GetNoise(...) - * @remarks Default: OpenSimplex2 - * @default FastNoiseLite.NoiseType.OpenSimplex2 - * @param {FastNoiseLite.NoiseType} noiseType - */ - SetNoiseType(noiseType) { - this._NoiseType = noiseType; - this._UpdateTransformType3D(); - } - - /** - * @description Sets domain rotation type for 3D Noise and 3D DomainWarp. - * @description Can aid in reducing directional artifacts when sampling a 2D plane in 3D - * @remarks Default: None - * @default FastNoiseLite.RotationType3D.None - * @param {FastNoiseLite.RotationType3D} rotationType3D - */ - SetRotationType3D(rotationType3D) { - this._RotationType3D = rotationType3D; - this._UpdateTransformType3D(); - this._UpdateWarpTransformType3D(); - } - - /** - * @description Sets method for combining octaves in all fractal noise types - * @remarks Default: None - * @default FastNoiseLite.FractalType.None - * @param {FastNoiseLite.FractalType} fractalType - */ - SetFractalType(fractalType) { - this._FractalType = fractalType; - } - - /** - * @description Sets octave count for all fractal noise types - * @remarks Default: 3 - * @default 3 - * @param {number} octaves - */ - SetFractalOctaves(octaves) { - this._Octaves = octaves; - this._CalculateFractalBounding(); - } - - /** - * @description Sets octave lacunarity for all fractal noise types - * @remarks Default: 2.0 - * @default 2.0 - * @param {number} lacunarity - */ - SetFractalLacunarity(lacunarity) { - this._Lacunarity = lacunarity; - } - - /** - * @description Sets octave gain for all fractal noise types - * @remarks Default: 0.5 - * @default 0.5 - * @param {number} gain - */ - SetFractalGain(gain) { - this._Gain = gain; - this._CalculateFractalBounding(); - } - - /** - * @description Sets octave weighting for all none DomainWarp fratal types - * @remarks Default: 0.0 | Keep between 0...1 to maintain -1...1 output bounding - * @default 0.5 - * @param {number} weightedStrength - */ - SetFractalWeightedStrength(weightedStrength) { - this._WeightedStrength = weightedStrength; - } - - /** - * @description Sets strength of the fractal ping pong effect - * @remarks Default: 2.0 - * @default 2.0 - * @param {number} pingPongStrength - */ - SetFractalPingPongStrength(pingPongStrength) { - this._PingPongStrength = pingPongStrength; - } - - /** - * @description Sets distance function used in cellular noise calculations - * @remarks Default: EuclideanSq - * @default FastNoiseLite.CellularDistanceFunction.EuclideanSq - * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction - */ - SetCellularDistanceFunction(cellularDistanceFunction) { - this._CellularDistanceFunction = cellularDistanceFunction; - } - - /** - * @description Sets return type from cellular noise calculations - * @remarks Default: Distance - * @default FastNoiseLite.CellularReturnType.Distance - * @param {FastNoiseLite.CellularReturnType} cellularReturnType - */ - SetCellularReturnType(cellularReturnType) { - this._CellularReturnType = cellularReturnType; + + if (arguments.length === 3) { + return R3(x, y, z); } - - /** - * @description Sets the maximum distance a cellular point can move from it's grid position - * @remarks Default: 1.0 - * @default 1.0 - * @param {number} cellularJitter - */ - SetCellularJitter(cellularJitter) { - this._CellularJitterModifier = cellularJitter; + } + + /** + * @description 2D/3D warps the input position using current domain warp settings + * @param {Vector2|Vector3} coord + */ + DomainWrap(coord) { + switch (this._FractalType) { + default: + this._DomainWarpSingle(coord); + break; + case FastNoiseLite.FractalType.DomainWarpProgressive: + this._DomainWarpFractalProgressive(coord); + break; + case FastNoiseLite.FractalType.DomainWarpIndependent: + this._DomainWarpFractalIndependent(coord); + break; } - - /** - * @description Sets the warp algorithm when using DomainWarp(...) - * @remarks Default: OpenSimplex2 - * @default FastNoiseLite.DomainWarpType.OpenSimplex2 - * @param {FastNoiseLite.DomainWarpType} domainWarpType - */ - SetDomainWarpType(domainWarpType) { - this._DomainWarpType = domainWarpType; - this._UpdateWarpTransformType3D(); + } + + // prettier-ignore + _Gradients2D = [ + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, + -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, + ]; + + // prettier-ignore + _RandVecs2D = [ + -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, + -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, + -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, + -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, + -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, + 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, + 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, + -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, + 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, + 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, + -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, + 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, + -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, + -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, + 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, + -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, + 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, + 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, + 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, + -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, + 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, + 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, + 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, + -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, + 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, + -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, + 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, + -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, + 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, + -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, + 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, + 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, + ]; + + // prettier-ignore + _Gradients3D = [ + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 + ]; + + // prettier-ignore + _RandVecs3D = [ + -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, + 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, + -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, + -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, + 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, + -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, + 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, + 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, + -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, + 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, + -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, + -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, + 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, + 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, + -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, + 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, + 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, + -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, + -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, + -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, + -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, + 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, + 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, + 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, + -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, + -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, + -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, + 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, + 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, + 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, + 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, + -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 + ]; + + _PrimeX = 501125321; + _PrimeY = 1136930381; + _PrimeZ = 1720413743; + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} t + * @returns {number} + */ + static _Lerp(a, b, t) { + return a + t * (b - a); + } + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _InterpHermite(t) { + return t * t * (3 - 2 * t); + } + + /** + * @private + * @param t + * @returns {number} + */ + static _InterpQuintic(t) { + return t * t * t * (t * (t * 6 - 15) + 10); + } + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} c + * @param {number} d + * @param {number} t + * @returns {number} + */ + static _CubicLerp(a, b, c, d, t) { + const p = d - c - (a - b); + return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; + } + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _PingPong(t) { + t -= Math.trunc(t * 0.5) * 2; + return t < 1 ? t : 2 - t; + } + + /** + * @private + */ + _CalculateFractalBounding() { + let gain = Math.abs(this._Gain); + let amp = gain; + let ampFractal = 1.0; + for (let i = 1; i < this._Octaves; i++) { + ampFractal += amp; + amp *= gain; + } + this._FractalBounding = 1 / ampFractal; + } + + /** + * @private + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @returns {number} + */ + _HashR2(seed, xPrimed, yPrimed) { + let hash = seed ^ xPrimed ^ yPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _HashR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; + } + + /** + * @private + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @returns {number} + */ + _ValCoordR2(seed, xPrimed, yPrimed) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _ValCoordR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} xd + * @param {number} yd + * @returns {number} + */ + _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + hash ^= hash >> 15; + hash &= 127 << 1; + + let xg = this._Gradients2D[hash]; + let yg = this._Gradients2D[hash | 1]; + + return xd * xg + yd * yg; + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @param {number} xd + * @param {number} yd + * @param {number} zd + * @returns {number} + */ + _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + hash ^= hash >> 15; + hash &= 63 << 2; + + let xg = this._Gradients3D[hash]; + let yg = this._Gradients3D[hash | 1]; + let zg = this._Gradients3D[hash | 2]; + + return xd * xg + yd * yg + zd * zg; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenNoiseSingleR2(seed, x, y) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R2(seed, x, y); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR2(seed, x, y); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR2(seed, x, y); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR2(seed, x, y); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR2(seed, x, y); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR2(seed, x, y); + default: + return 0; } - - /** - * @description Sets the maximum warp distance from original position when using DomainWarp(...) - * @remarks Default: 1.0 - * @default 1.0 - * @param {number} domainWarpAmp - */ - SetDomainWarpAmp(domainWarpAmp) { - this._DomainWarpAmp = domainWarpAmp; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenNoiseSingleR3(seed, x, y, z) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R3(seed, x, y, z); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR3(seed, x, y, z); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR3(seed, x, y, z); + default: + return 0; } - - /** - * @description 2D/3D noise at given position using current settings - * @param {number} x X coordinate - * @param {number} y Y coordinate - * @param {number} [z] Z coordinate - * @return {number} Noise output bounded between -1...1 - */ - GetNoise(x, y, z) { - /** - * @description 2D noise at given position using current settings - * @param {number} x - * @param {number} y - * @return {number} Noise output bounded between -1...1 - */ - let R2 = (x, y) => { - x *= this._Frequency; - y *= this._Frequency; - + } + + /** + * @private + */ + _UpdateTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: switch (this._NoiseType) { case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (x + y) * F2; - x += t; - y += t; + case FastNoiseLite.NoiseType.OpenSimplex2S: + this._TransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; break; - } default: + this._TransformType3D = FastNoiseLite.TransformType3D.None; break; } - - switch (this._FractalType) { - default: - return this._GenNoiseSingleR2(this._Seed, x, y); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR2(x, y); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR2(x, y); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR2(x, y); - } - }; - - /** - * @description 3D noise at given position using current settings - * @param {number} x - * @param {number} y - * @param {number} z - * @return {number} Noise output bounded between -1...1 - */ - let R3 = (x, y, z) => { - x *= this._Frequency; - y *= this._Frequency; - z *= this._Frequency; - - switch (this._TransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: { - let xy = x + y; - let s2 = xy * -0.211324865405187; - z *= 0.577350269189626; - x += s2 - z; - y += s2 - z; - z += xy * 0.577350269189626; - break; - } - case FastNoiseLite.TransformType3D.ImproveXZPlanes: { - let xz = x + z; - let s2 = xz * -0.211324865405187; - y *= 0.577350269189626; - x += s2 - y; - z += s2 - y; - y += xz * 0.577350269189626; - break; - } - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { - const R3 = 2.0 / 3.0; - let r = (x + y + z) * R3; - x = r - x; - y = r - y; - z = r - z; + break; + } + } + + /** + * @private + */ + _UpdateWarpTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; break; - } default: + this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; break; } - - switch (this._FractalType) { - default: - return this._GenNoiseSingleR3(this._Seed, x, y, z); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR3(x, y, z); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR3(x, y, z); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR3(x, y, z); - } - }; - - if (arguments.length === 2) { - return R2(x, y); - } - - if (arguments.length === 3) { - return R3(x, y, z); - } + break; } - - /** - * @description 2D/3D warps the input position using current domain warp settings - * @param {Vector2|Vector3} coord - */ - DomainWrap(coord) { - switch (this._FractalType) { - default: - this._DomainWarpSingle(coord); - break; - case FastNoiseLite.FractalType.DomainWarpProgressive: - this._DomainWarpFractalProgressive(coord); - break; - case FastNoiseLite.FractalType.DomainWarpIndependent: - this._DomainWarpFractalIndependent(coord); - break; - } + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalFBmR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR2(seed++, x, y); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + Math.min(noise + 1, 2) * 0.5, + this._WeightedStrength + ); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; } - - // prettier-ignore - _Gradients2D = [ - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, - -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, - ]; - - // prettier-ignore - _RandVecs2D = [ - -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, - -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, - -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, - -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, - -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, - 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, - 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, - -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, - 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, - 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, - -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, - 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, - -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, - -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, - 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, - -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, - 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, - 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, - 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, - -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, - 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, - 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, - 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, - -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, - 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, - -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, - 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, - -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, - 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, - -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, - 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, - 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, - ]; - - // prettier-ignore - _Gradients3D = [ - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 - ]; - - // prettier-ignore - _RandVecs3D = [ - -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, - 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, - -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, - -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, - 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, - -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, - 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, - 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, - -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, - 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, - -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, - -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, - 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, - 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, - -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, - 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, - 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, - -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, - -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, - -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, - -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, - 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, - 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, - 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, - -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, - -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, - -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, - 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, - 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, - 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, - 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, - -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 - ]; - - _PrimeX = 501125321; - _PrimeY = 1136930381; - _PrimeZ = 1720413743; - - /** - * @private - * @param {number} a - * @param {number} b - * @param {number} t - * @returns {number} - */ - static _Lerp(a, b, t) { - return a + t * (b - a); - } - - /** - * @private - * @param {number} t - * @returns {number} - */ - static _InterpHermite(t) { - return t * t * (3 - 2 * t); - } - - /** - * @private - * @param t - * @returns {number} - */ - static _InterpQuintic(t) { - return t * t * t * (t * (t * 6 - 15) + 10); - } - - /** - * @private - * @param {number} a - * @param {number} b - * @param {number} c - * @param {number} d - * @param {number} t - * @returns {number} - */ - static _CubicLerp(a, b, c, d, t) { - const p = d - c - (a - b); - return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; - } - - /** - * @private - * @param {number} t - * @returns {number} - */ - static _PingPong(t) { - t -= Math.trunc(t * 0.5) * 2; - return t < 1 ? t : 2 - t; - } - - /** - * @private - */ - _CalculateFractalBounding() { - let gain = Math.abs(this._Gain); - let amp = gain; - let ampFractal = 1.0; - for (let i = 1; i < this._Octaves; i++) { - ampFractal += amp; - amp *= gain; - } - this._FractalBounding = 1 / ampFractal; - } - - /** - * @private - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @returns {number} - */ - _HashR2(seed, xPrimed, yPrimed) { - let hash = seed ^ xPrimed ^ yPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @returns {number} - */ - _HashR3(seed, xPrimed, yPrimed, zPrimed) { - let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; - } - - /** - * @private - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @returns {number} - */ - _ValCoordR2(seed, xPrimed, yPrimed) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @returns {number} - */ - _ValCoordR3(seed, xPrimed, yPrimed, zPrimed) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} xd - * @param {number} yd - * @returns {number} - */ - _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - hash ^= hash >> 15; - hash &= 127 << 1; - - let xg = this._Gradients2D[hash]; - let yg = this._Gradients2D[hash | 1]; - - return xd * xg + yd * yg; - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @param {number} xd - * @param {number} yd - * @param {number} zd - * @returns {number} - */ - _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - hash ^= hash >> 15; - hash &= 63 << 2; - - let xg = this._Gradients3D[hash]; - let yg = this._Gradients3D[hash | 1]; - let zg = this._Gradients3D[hash | 2]; - - return xd * xg + yd * yg + zd * zg; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenNoiseSingleR2(seed, x, y) { - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R2(seed, x, y); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR2(seed, x, y); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR2(seed, x, y); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR2(seed, x, y); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR2(seed, x, y); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR2(seed, x, y); - default: - return 0; - } - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenNoiseSingleR3(seed, x, y, z) { - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R3(seed, x, y, z); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR3(seed, x, y, z); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR3(seed, x, y, z); - default: - return 0; - } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalFBmR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR3(seed++, x, y, z); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + (noise + 1) * 0.5, + this._WeightedStrength + ); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; } - - /** - * @private - */ - _UpdateTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; - default: - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: - this._TransformType3D = - FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - break; - default: - this._TransformType3D = FastNoiseLite.TransformType3D.None; - break; - } - break; - } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalRidgedR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; } - - /** - * @private - */ - _UpdateWarpTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; - default: - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - break; - default: - this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; - break; - } - break; - } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalRidgedR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalFBmR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR2(seed++, x, y); - sum += noise * amp; - amp *= FastNoiseLite._Lerp( - 1.0, - Math.min(noise + 1, 2) * 0.5, - this._WeightedStrength - ); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalPingPongR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalFBmR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR3(seed++, x, y, z); - sum += noise * amp; - amp *= FastNoiseLite._Lerp( - 1.0, - (noise + 1) * 0.5, - this._WeightedStrength - ); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalPingPongR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalRidgedR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + return sum; + } + + /** + * + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleOpenSimplex2R2(seed, x, y) { + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let n0, n1, n2; + + let a = 0.5 - x0 * x0 - y0 * y0; + + if (a <= 0) { + n0 = 0; + } else { + n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalRidgedR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; - } - return sum; + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + + if (c <= 0) { + n2 = 0; + } else { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + n2 = + c * + c * + (c * c) * + this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalPingPongR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = + b * + b * + (b * b) * + this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalPingPongR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; + } else { + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = + b * + b * + (b * b) * + this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); } - return sum; } - - /** - * - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleOpenSimplex2R2(seed, x, y) { - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let n0, n1, n2; - - let a = 0.5 - x0 * x0 - y0 * y0; - - if (a <= 0) { - n0 = 0; - } else { - n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); + return (n0 + n1 + n2) * 99.83685446303647; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleOpenSimplex2R3(seed, x, y, z) { + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let yNSign = Math.trunc((-1.0 - y0) | 1); + let xNSign = Math.trunc((-1.0 - x0) | 1); + let zNSign = Math.trunc((-1.0 - z0) | 1); + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let value = 0; + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + + for (let l = 0; ; l++) { + if (a > 0) { + value += + a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); } - - let c = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - - if (c <= 0) { - n2 = 0; + + if (ax0 >= ay0 && ax0 >= az0) { + let b = a + ax0 + ax0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i - xNSign * this._PrimeX, + j, + k, + x0 + xNSign, + y0, + z0 + ); + } + } else if (ay0 > ax0 && ay0 >= az0) { + let b = a + ay0 + ay0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j - yNSign * this._PrimeY, + k, + x0, + y0 + yNSign, + z0 + ); + } } else { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - n2 = - c * - c * - (c * c) * - this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); - } - - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = + let b = a + az0 + az0; + if (b > 1) { + b -= 1; + value += b * b * (b * b) * - this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); + this._GradCoordR3( + seed, + i, + j, + k - zNSign * this._PrimeZ, + x0, + y0, + z0 + zNSign + ); + } + } + + if (l === 1) { + break; + } + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed = ~seed; + } + return value * 32.69428253173828125; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleOpenSimplex2SR2(seed, x, y) { + // 2D OpenSimplex2S case is a modified 2D simplex noise. + + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + /* + * --- Skew moved to TransformNoiseCoordinate method --- + * final FNLfloat F2 = 0.5f * (SQRT3 - 1); + * FNLfloat s = (x + y) * F2; + * x += s; y += s; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + let i1 = i + this._PrimeX; + let j1 = j + this._PrimeY; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; + let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); + let a1 = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); + let x1 = x0 - (1 - 2 * G2); + let y1 = y0 - (1 - 2 * G2); + value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); + + // Nested conditionals were faster than compact bit logic/arithmetic. + let xmyi = xi - yi; + if (t > G2) { + if (xi + xmyi > 1) { + let x2 = x0 + (3 * G2 - 2); + let y2 = y0 + (3 * G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2( + seed, + i + (this._PrimeX << 1), + j + this._PrimeY, + x2, + y2 + ); } } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = - b * - b * - (b * b) * - this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); } } - return (n0 + n1 + n2) * 99.83685446303647; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleOpenSimplex2R3(seed, x, y, z) { - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let yNSign = Math.trunc((-1.0 - y0) | 1); - let xNSign = Math.trunc((-1.0 - x0) | 1); - let zNSign = Math.trunc((-1.0 - z0) | 1); - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let value = 0; - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - - for (let l = 0; ; l++) { - if (a > 0) { + + if (yi - xmyi > 1) { + let x3 = x0 + (3 * G2 - 1); + let y3 = y0 + (3 * G2 - 2); + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { value += - a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); - } - - if (ax0 >= ay0 && ax0 >= az0) { - let b = a + ax0 + ax0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i - xNSign * this._PrimeX, - j, - k, - x0 + xNSign, - y0, - z0 - ); - } - } else if (ay0 > ax0 && ay0 >= az0) { - let b = a + ay0 + ay0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i, - j - yNSign * this._PrimeY, - k, - x0, - y0 + yNSign, - z0 - ); - } - } else { - let b = a + az0 + az0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i, - j, - k - zNSign * this._PrimeZ, - x0, - y0, - z0 + zNSign - ); - } + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2( + seed, + i + this._PrimeX, + j + (this._PrimeY << 1), + x3, + y3 + ); } - - if (l === 1) { - break; + } else { + let x3 = x0 + (G2 - 1); + let y3 = y0 + G2; + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); } - - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; - - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; - - a += 0.75 - ax0 - (ay0 + az0); - - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; - - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; - - seed = ~seed; } - return value * 32.69428253173828125; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleOpenSimplex2SR2(seed, x, y) { - // 2D OpenSimplex2S case is a modified 2D simplex noise. - - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - /* - * --- Skew moved to TransformNoiseCoordinate method --- - * final FNLfloat F2 = 0.5f * (SQRT3 - 1); - * FNLfloat s = (x + y) * F2; - * x += s; y += s; - */ - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - let i1 = i + this._PrimeX; - let j1 = j + this._PrimeY; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; - let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); - let a1 = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); - let x1 = x0 - (1 - 2 * G2); - let y1 = y0 - (1 - 2 * G2); - value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); - - // Nested conditionals were faster than compact bit logic/arithmetic. - let xmyi = xi - yi; - if (t > G2) { - if (xi + xmyi > 1) { - let x2 = x0 + (3 * G2 - 2); - let y2 = y0 + (3 * G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2( - seed, - i + (this._PrimeX << 1), - j + this._PrimeY, - x2, - y2 - ); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } - } - - if (yi - xmyi > 1) { - let x3 = x0 + (3 * G2 - 1); - let y3 = y0 + (3 * G2 - 2); - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR2( - seed, - i + this._PrimeX, - j + (this._PrimeY << 1), - x3, - y3 - ); - } - } else { - let x3 = x0 + (G2 - 1); - let y3 = y0 + G2; - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); - } + } else { + if (xi + xmyi < 0) { + let x2 = x0 + (1 - G2); + let y2 = y0 - G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); } } else { - if (xi + xmyi < 0) { - let x2 = x0 + (1 - G2); - let y2 = y0 - G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); - } - } else { - let x2 = x0 + (G2 - 1); - let y2 = y0 + G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); - } + let x2 = x0 + (G2 - 1); + let y2 = y0 + G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); } - - if (yi < xmyi) { - let x2 = x0 - G2; - let y2 = y0 - (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } + } + + if (yi < xmyi) { + let x2 = x0 - G2; + let y2 = y0 - (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); } } - - return value * 18.24196194486065; } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} + + return value * 18.24196194486065; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleOpenSimplex2SR3(seed, x, y, z) { + // 3D OpenSimplex2S case uses two offset rotated cube grids. + + /* + * --- Rotation moved to TransformNoiseCoordinate method --- + * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); + * FNLfloat r = (x + y + z) * R3; // Rotation, not skew + * x = r - x; y = r - y; z = r - z; */ - _SingleOpenSimplex2SR3(seed, x, y, z) { - // 3D OpenSimplex2S case uses two offset rotated cube grids. - - /* - * --- Rotation moved to TransformNoiseCoordinate method --- - * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); - * FNLfloat r = (x + y + z) * R3; // Rotation, not skew - * x = r - x; y = r - y; z = r - z; - */ - - let i = Math.floor(x); - let j = Math.floor(y); - let k = Math.floor(z); - let xi = x - i; - let yi = y - j; - let zi = z - k; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - let seed2 = seed + 1293373; - - let xNMask = Math.trunc(-0.5 - xi); - let yNMask = Math.trunc(-0.5 - yi); - let zNMask = Math.trunc(-0.5 - zi); - - let x0 = xi + xNMask; - let y0 = yi + yNMask; - let z0 = zi + zNMask; - let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; - let value = - a0 * - a0 * - (a0 * a0) * + + let i = Math.floor(x); + let j = Math.floor(y); + let k = Math.floor(z); + let xi = x - i; + let yi = y - j; + let zi = z - k; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + let seed2 = seed + 1293373; + + let xNMask = Math.trunc(-0.5 - xi); + let yNMask = Math.trunc(-0.5 - yi); + let zNMask = Math.trunc(-0.5 - zi); + + let x0 = xi + xNMask; + let y0 = yi + yNMask; + let z0 = zi + zNMask; + let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; + let value = + a0 * + a0 * + (a0 * a0) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x0, + y0, + z0 + ); + + let x1 = xi - 0.5; + let y1 = yi - 0.5; + let z1 = zi - 0.5; + let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; + value += + a1 * + a1 * + (a1 * a1) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + this._PrimeZ, + x1, + y1, + z1 + ); + + let xAFlipMask0 = ((xNMask | 1) << 1) * x1; + let yAFlipMask0 = ((yNMask | 1) << 1) * y1; + let zAFlipMask0 = ((zNMask | 1) << 1) * z1; + let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; + let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; + let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; + + let skip5 = false; + let a2 = xAFlipMask0 + a0; + if (a2 > 0) { + let x2 = x0 - (xNMask | 1); + value += + a2 * + a2 * + (a2 * a2) * this._GradCoordR3( seed, - i + (xNMask & this._PrimeX), + i + (~xNMask & this._PrimeX), j + (yNMask & this._PrimeY), k + (zNMask & this._PrimeZ), - x0, + x2, y0, z0 ); - - let x1 = xi - 0.5; - let y1 = yi - 0.5; - let z1 = zi - 0.5; - let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; + } else { + let a3 = yAFlipMask0 + zAFlipMask0 + a0; + + if (a3 > 0) { + let x3 = x0; + let y3 = y0 - (yNMask | 1); + let z3 = z0 - (zNMask | 1); + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x3, + y3, + z3 + ); + } + + let a4 = xAFlipMask1 + a1; + if (a4 > 0) { + let x4 = (xNMask | 1) + x1; + value += + a4 * + a4 * + (a4 * a4) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + this._PrimeZ, + x4, + y1, + z1 + ); + skip5 = true; + } + } + + let skip9 = false; + let a6 = yAFlipMask0 + a0; + if (a6 > 0) { + let x6 = x0; + let y6 = y0 - (yNMask | 1); value += - a1 * - a1 * - (a1 * a1) * + a6 * + a6 * + (a6 * a6) * this._GradCoordR3( - seed2, - i + this._PrimeX, - j + this._PrimeY, - k + this._PrimeZ, - x1, - y1, - z1 + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x6, + y6, + z0 ); - - let xAFlipMask0 = ((xNMask | 1) << 1) * x1; - let yAFlipMask0 = ((yNMask | 1) << 1) * y1; - let zAFlipMask0 = ((zNMask | 1) << 1) * z1; - let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; - let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; - let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; - - let skip5 = false; - let a2 = xAFlipMask0 + a0; - if (a2 > 0) { - let x2 = x0 - (xNMask | 1); + } else { + let a7 = xAFlipMask0 + zAFlipMask0 + a0; + if (a7 > 0) { + let x7 = x0 - (xNMask | 1); + let y7 = y0; + let z7 = z0 - (zNMask | 1); value += - a2 * - a2 * - (a2 * a2) * + a7 * + a7 * + (a7 * a7) * this._GradCoordR3( seed, i + (~xNMask & this._PrimeX), j + (yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x2, - y0, - z0 + k + (~zNMask & this._PrimeZ), + x7, + y7, + z7 ); - } else { - let a3 = yAFlipMask0 + zAFlipMask0 + a0; - - if (a3 > 0) { - let x3 = x0; - let y3 = y0 - (yNMask | 1); - let z3 = z0 - (zNMask | 1); - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x3, - y3, - z3 - ); - } - - let a4 = xAFlipMask1 + a1; - if (a4 > 0) { - let x4 = (xNMask | 1) + x1; - value += - a4 * - a4 * - (a4 * a4) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + this._PrimeZ, - x4, - y1, - z1 - ); - skip5 = true; - } } - - let skip9 = false; - let a6 = yAFlipMask0 + a0; - if (a6 > 0) { - let x6 = x0; - let y6 = y0 - (yNMask | 1); + + let a8 = yAFlipMask1 + a1; + if (a8 > 0) { + let x8 = x1; + let y8 = (yNMask | 1) + y1; + value += + a8 * + a8 * + (a8 * a8) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + x8, + y8, + z1 + ); + skip9 = true; + } + } + + let skipD = false; + let aA = zAFlipMask0 + a0; + if (aA > 0) { + let xA = x0; + let yA = y0; + let zA = z0 - (zNMask | 1); + value += + aA * + aA * + (aA * aA) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + xA, + yA, + zA + ); + } else { + let aB = xAFlipMask0 + yAFlipMask0 + a0; + if (aB > 0) { + let xB = x0 - (xNMask | 1); + let yB = y0 - (yNMask | 1); value += - a6 * - a6 * - (a6 * a6) * + aB * + aB * + (aB * aB) * this._GradCoordR3( seed, - i + (xNMask & this._PrimeX), + i + (~xNMask & this._PrimeX), j + (~yNMask & this._PrimeY), k + (zNMask & this._PrimeZ), - x6, - y6, + xB, + yB, z0 ); - } else { - let a7 = xAFlipMask0 + zAFlipMask0 + a0; - if (a7 > 0) { - let x7 = x0 - (xNMask | 1); - let y7 = y0; - let z7 = z0 - (zNMask | 1); - value += - a7 * - a7 * - (a7 * a7) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x7, - y7, - z7 - ); - } - - let a8 = yAFlipMask1 + a1; - if (a8 > 0) { - let x8 = x1; - let y8 = (yNMask | 1) + y1; - value += - a8 * - a8 * - (a8 * a8) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - x8, - y8, - z1 - ); - skip9 = true; - } } - - let skipD = false; - let aA = zAFlipMask0 + a0; - if (aA > 0) { - let xA = x0; - let yA = y0; - let zA = z0 - (zNMask | 1); + + let aC = zAFlipMask1 + a1; + if (aC > 0) { + let xC = x1; + let yC = y1; + let zC = (zNMask | 1) + z1; value += - aA * - aA * - (aA * aA) * + aC * + aC * + (aC * aC) * this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - xA, - yA, - zA + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + xC, + yC, + zC ); - } else { - let aB = xAFlipMask0 + yAFlipMask0 + a0; - if (aB > 0) { - let xB = x0 - (xNMask | 1); - let yB = y0 - (yNMask | 1); - value += - aB * - aB * - (aB * aB) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - xB, - yB, - z0 - ); - } - - let aC = zAFlipMask1 + a1; - if (aC > 0) { - let xC = x1; - let yC = y1; - let zC = (zNMask | 1) + z1; - value += - aC * - aC * - (aC * aC) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - xC, - yC, - zC - ); - skipD = true; - } + skipD = true; } - - if (!skip5) { - let a5 = yAFlipMask1 + zAFlipMask1 + a1; - if (a5 > 0) { - let x5 = x1; - let y5 = (yNMask | 1) + y1; - let z5 = (zNMask | 1) + z1; - value += - a5 * - a5 * - (a5 * a5) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + (zNMask & (this._PrimeZ << 1)), - x5, - y5, - z5 - ); - } + } + + if (!skip5) { + let a5 = yAFlipMask1 + zAFlipMask1 + a1; + if (a5 > 0) { + let x5 = x1; + let y5 = (yNMask | 1) + y1; + let z5 = (zNMask | 1) + z1; + value += + a5 * + a5 * + (a5 * a5) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + (zNMask & (this._PrimeZ << 1)), + x5, + y5, + z5 + ); } - - if (!skip9) { - let a9 = xAFlipMask1 + zAFlipMask1 + a1; - if (a9 > 0) { - let x9 = (xNMask | 1) + x1; - let y9 = y1; - let z9 = (zNMask | 1) + z1; - value += - a9 * - a9 * - (a9 * a9) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - x9, - y9, - z9 - ); - } + } + + if (!skip9) { + let a9 = xAFlipMask1 + zAFlipMask1 + a1; + if (a9 > 0) { + let x9 = (xNMask | 1) + x1; + let y9 = y1; + let z9 = (zNMask | 1) + z1; + value += + a9 * + a9 * + (a9 * a9) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + x9, + y9, + z9 + ); } - - if (!skipD) { - let aD = xAFlipMask1 + yAFlipMask1 + a1; - if (aD > 0) { - let xD = (xNMask | 1) + x1; - let yD = (yNMask | 1) + y1; - value += - aD * - aD * - (aD * aD) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX << 1)), - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - xD, - yD, - z1 - ); - } + } + + if (!skipD) { + let aD = xAFlipMask1 + yAFlipMask1 + a1; + if (aD > 0) { + let xD = (xNMask | 1) + x1; + let yD = (yNMask | 1) + y1; + value += + aD * + aD * + (aD * aD) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX << 1)), + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + xD, + yD, + z1 + ); } - - return value * 9.046026385208288; } - + + return value * 9.046026385208288; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleCellularR2(seed, x, y) { /** - * @private + * * @param {number} seed * @param {number} x * @param {number} y * @returns {number} */ - _SingleCellularR2(seed, x, y) { - /** - * - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - let xr = Math.round(x); - let yr = Math.round(y); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - - let closestHash = 0; - - let cellularJitter = 0.43701595 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - - switch (this._CellularDistanceFunction) { - default: - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY; - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); + let xr = Math.round(x); + let yr = Math.round(y); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + + let closestHash = 0; + + let cellularJitter = 0.43701595 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + + switch (this._CellularDistanceFunction) { + default: + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY; + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = Math.abs(vecX) + Math.abs(vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + } + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + + if ( + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue + ) { + distance1 = Math.sqrt(distance1); + } + } + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; + } + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleCellularR3(seed, x, y, z) { + let xr = Math.round(x); + let yr = Math.round(y); + let zr = Math.round(z); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + let closestHash = 0; + + let cellularJitter = 0.39614353 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + let zPrimedBase = (zr - 1) * this._PrimeZ; + + switch (this._CellularDistanceFunction) { + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); if (newDistance < distance0) { distance0 = newDistance; closestHash = hash; } - yPrimed += this._PrimeY; + zPrimed += this._PrimeZ; } - xPrimed += this._PrimeX; + yPrimed += this._PrimeY; } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = Math.abs(vecX) + Math.abs(vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); if (newDistance < distance0) { distance0 = newDistance; closestHash = hash; } - yPrimed += this._PrimeY; + zPrimed += this._PrimeZ; } - xPrimed += this._PrimeX; + yPrimed += this._PrimeY; } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + let newDistance = - Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); + Math.abs(vecX) + + Math.abs(vecY) + + Math.abs(vecZ) + + (vecX * vecX + vecY * vecY + vecZ * vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); if (newDistance < distance0) { distance0 = newDistance; closestHash = hash; } - yPrimed += this._PrimeY; + zPrimed += this._PrimeZ; } - xPrimed += this._PrimeX; + yPrimed += this._PrimeY; } - break; - } - - if ( - this._CellularDistanceFunction === - FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue - ) { - distance0 = Math.sqrt(distance0); - - if ( - this._CellularReturnType !== - FastNoiseLite.CellularReturnType.CellValue - ) { - distance1 = Math.sqrt(distance1); + xPrimed += this._PrimeX; } - } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; - } + break; + default: + break; } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleCellularR3(seed, x, y, z) { - let xr = Math.round(x); - let yr = Math.round(y); - let zr = Math.round(z); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - let closestHash = 0; - - let cellularJitter = 0.39614353 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - let zPrimedBase = (zr - 1) * this._PrimeZ; - - switch (this._CellularDistanceFunction) { - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 - ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = - Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 - ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = - Math.abs(vecX) + - Math.abs(vecY) + - Math.abs(vecZ) + - (vecX * vecX + vecY * vecY + vecZ * vecZ); - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 - ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - default: - break; - } - + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + if ( - this._CellularDistanceFunction === - FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue ) { - distance0 = Math.sqrt(distance0); - - if ( - this._CellularReturnType !== - FastNoiseLite.CellularReturnType.CellValue - ) { - distance1 = Math.sqrt(distance1); - } - } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; + distance1 = Math.sqrt(distance1); } } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SinglePerlinR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xd0 = x - x0; - let yd0 = y - y0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y0, xd0, yd0), - this._GradCoordR2(seed, x1, y0, xd1, yd0), - xs - ); - let xf1 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y1, xd0, yd1), - this._GradCoordR2(seed, x1, y1, xd1, yd1), - xs - ); - - return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SinglePerlinR3(seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xd0 = x - x0; - let yd0 = y - y0; - let zd0 = z - z0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - let zd1 = zd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - let zs = FastNoiseLite._InterpQuintic(zd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), - this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), - this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), - this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), - xs - ); - let xf11 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), - this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), - xs - ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleValueCubicR2(seed, x, y) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - - let xs = x - x1; - let ys = y - y1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - - return ( + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SinglePerlinR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xd0 = x - x0; + let yd0 = y - y0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y0, xd0, yd0), + this._GradCoordR2(seed, x1, y0, xd1, yd0), + xs + ); + let xf1 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y1, xd0, yd1), + this._GradCoordR2(seed, x1, y1, xd1, yd1), + xs + ); + + return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SinglePerlinR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xd0 = x - x0; + let yd0 = y - y0; + let zd0 = z - z0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + let zd1 = zd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + let zs = FastNoiseLite._InterpQuintic(zd0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), + this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), + xs + ); + let xf10 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), + this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), + xs + ); + let xf01 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), + this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), + xs + ); + let xf11 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), + this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), + xs + ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueCubicR2(seed, x, y) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + + let xs = x - x1; + let ys = y - y1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), + this._ValCoordR2(seed, x2, y0), + this._ValCoordR2(seed, x3, y0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), + this._ValCoordR2(seed, x2, y1), + this._ValCoordR2(seed, x3, y1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y2), + this._ValCoordR2(seed, x1, y2), + this._ValCoordR2(seed, x2, y2), + this._ValCoordR2(seed, x3, y2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y3), + this._ValCoordR2(seed, x1, y3), + this._ValCoordR2(seed, x2, y3), + this._ValCoordR2(seed, x3, y3), + xs + ), + ys + ) * + (1 / (1.5 * 1.5)) + ); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueCubicR3(seed, x, y, z) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + let z1 = Math.floor(z); + + let xs = x - x1; + let ys = y - y1; + let zs = z - z1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + z1 = Math.imul(z1, this._PrimeZ); + + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let z0 = z1 - this._PrimeZ; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let z2 = z1 + this._PrimeZ; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + let z3 = z1 + (this._PrimeZ << 1); + + return ( + FastNoiseLite._CubicLerp( FastNoiseLite._CubicLerp( FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y0), - this._ValCoordR2(seed, x1, y0), - this._ValCoordR2(seed, x2, y0), - this._ValCoordR2(seed, x3, y0), + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + this._ValCoordR3(seed, x2, y0, z0), + this._ValCoordR3(seed, x3, y0, z0), xs ), FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y1), - this._ValCoordR2(seed, x1, y1), - this._ValCoordR2(seed, x2, y1), - this._ValCoordR2(seed, x3, y1), + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + this._ValCoordR3(seed, x2, y1, z0), + this._ValCoordR3(seed, x3, y1, z0), xs ), FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y2), - this._ValCoordR2(seed, x1, y2), - this._ValCoordR2(seed, x2, y2), - this._ValCoordR2(seed, x3, y2), + this._ValCoordR3(seed, x0, y2, z0), + this._ValCoordR3(seed, x1, y2, z0), + this._ValCoordR3(seed, x2, y2, z0), + this._ValCoordR3(seed, x3, y2, z0), xs ), FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y3), - this._ValCoordR2(seed, x1, y3), - this._ValCoordR2(seed, x2, y3), - this._ValCoordR2(seed, x3, y3), + this._ValCoordR3(seed, x0, y3, z0), + this._ValCoordR3(seed, x1, y3, z0), + this._ValCoordR3(seed, x2, y3, z0), + this._ValCoordR3(seed, x3, y3, z0), xs ), ys - ) * - (1 / (1.5 * 1.5)) - ); - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleValueCubicR3(seed, x, y, z) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - let z1 = Math.floor(z); - - let xs = x - x1; - let ys = y - y1; - let zs = z - z1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - z1 = Math.imul(z1, this._PrimeZ); - - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let z0 = z1 - this._PrimeZ; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let z2 = z1 + this._PrimeZ; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - let z3 = z1 + (this._PrimeZ << 1); - - return ( + ), FastNoiseLite._CubicLerp( FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - this._ValCoordR3(seed, x2, y0, z0), - this._ValCoordR3(seed, x3, y0, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - this._ValCoordR3(seed, x2, y1, z0), - this._ValCoordR3(seed, x3, y1, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z0), - this._ValCoordR3(seed, x1, y2, z0), - this._ValCoordR3(seed, x2, y2, z0), - this._ValCoordR3(seed, x3, y2, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z0), - this._ValCoordR3(seed, x1, y3, z0), - this._ValCoordR3(seed, x2, y3, z0), - this._ValCoordR3(seed, x3, y3, z0), - xs - ), - ys + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + this._ValCoordR3(seed, x2, y0, z1), + this._ValCoordR3(seed, x3, y0, z1), + xs ), FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - this._ValCoordR3(seed, x2, y0, z1), - this._ValCoordR3(seed, x3, y0, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - this._ValCoordR3(seed, x2, y1, z1), - this._ValCoordR3(seed, x3, y1, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z1), - this._ValCoordR3(seed, x1, y2, z1), - this._ValCoordR3(seed, x2, y2, z1), - this._ValCoordR3(seed, x3, y2, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z1), - this._ValCoordR3(seed, x1, y3, z1), - this._ValCoordR3(seed, x2, y3, z1), - this._ValCoordR3(seed, x3, y3, z1), - xs - ), - ys + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + this._ValCoordR3(seed, x2, y1, z1), + this._ValCoordR3(seed, x3, y1, z1), + xs ), FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z2), - this._ValCoordR3(seed, x1, y0, z2), - this._ValCoordR3(seed, x2, y0, z2), - this._ValCoordR3(seed, x3, y0, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z2), - this._ValCoordR3(seed, x1, y1, z2), - this._ValCoordR3(seed, x2, y1, z2), - this._ValCoordR3(seed, x3, y1, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z2), - this._ValCoordR3(seed, x1, y2, z2), - this._ValCoordR3(seed, x2, y2, z2), - this._ValCoordR3(seed, x3, y2, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z2), - this._ValCoordR3(seed, x1, y3, z2), - this._ValCoordR3(seed, x2, y3, z2), - this._ValCoordR3(seed, x3, y3, z2), - xs - ), - ys + this._ValCoordR3(seed, x0, y2, z1), + this._ValCoordR3(seed, x1, y2, z1), + this._ValCoordR3(seed, x2, y2, z1), + this._ValCoordR3(seed, x3, y2, z1), + xs ), FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z3), - this._ValCoordR3(seed, x1, y0, z3), - this._ValCoordR3(seed, x2, y0, z3), - this._ValCoordR3(seed, x3, y0, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z3), - this._ValCoordR3(seed, x1, y1, z3), - this._ValCoordR3(seed, x2, y1, z3), - this._ValCoordR3(seed, x3, y1, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z3), - this._ValCoordR3(seed, x1, y2, z3), - this._ValCoordR3(seed, x2, y2, z3), - this._ValCoordR3(seed, x3, y2, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z3), - this._ValCoordR3(seed, x1, y3, z3), - this._ValCoordR3(seed, x2, y3, z3), - this._ValCoordR3(seed, x3, y3, z3), - xs - ), - ys + this._ValCoordR3(seed, x0, y3, z1), + this._ValCoordR3(seed, x1, y3, z1), + this._ValCoordR3(seed, x2, y3, z1), + this._ValCoordR3(seed, x3, y3, z1), + xs ), - zs - ) * - (1 / (1.5 * 1.5 * 1.5)) - ); - } - + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z2), + this._ValCoordR3(seed, x1, y0, z2), + this._ValCoordR3(seed, x2, y0, z2), + this._ValCoordR3(seed, x3, y0, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z2), + this._ValCoordR3(seed, x1, y1, z2), + this._ValCoordR3(seed, x2, y1, z2), + this._ValCoordR3(seed, x3, y1, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z2), + this._ValCoordR3(seed, x1, y2, z2), + this._ValCoordR3(seed, x2, y2, z2), + this._ValCoordR3(seed, x3, y2, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z2), + this._ValCoordR3(seed, x1, y3, z2), + this._ValCoordR3(seed, x2, y3, z2), + this._ValCoordR3(seed, x3, y3, z2), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z3), + this._ValCoordR3(seed, x1, y0, z3), + this._ValCoordR3(seed, x2, y0, z3), + this._ValCoordR3(seed, x3, y0, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z3), + this._ValCoordR3(seed, x1, y1, z3), + this._ValCoordR3(seed, x2, y1, z3), + this._ValCoordR3(seed, x3, y1, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z3), + this._ValCoordR3(seed, x1, y2, z3), + this._ValCoordR3(seed, x2, y2, z3), + this._ValCoordR3(seed, x3, y2, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z3), + this._ValCoordR3(seed, x1, y3, z3), + this._ValCoordR3(seed, x2, y3, z3), + this._ValCoordR3(seed, x3, y3, z3), + xs + ), + ys + ), + zs + ) * + (1 / (1.5 * 1.5 * 1.5)) + ); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), + xs + ); + let xf1 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), + xs + ); + + return FastNoiseLite._Lerp(xf0, xf1, ys); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + let zs = FastNoiseLite._InterpHermite(z - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + xs + ); + let xf10 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + xs + ); + let xf01 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + xs + ); + let xf11 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + xs + ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs); + } + + /** + * @private + */ + _DoSingleDomainWarp() { /** - * @private + * * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector2} coord * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleValueR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp( - this._ValCoordR2(seed, x0, y0), - this._ValCoordR2(seed, x1, y0), - xs - ); - let xf1 = FastNoiseLite._Lerp( - this._ValCoordR2(seed, x0, y1), - this._ValCoordR2(seed, x1, y1), - xs - ); - - return FastNoiseLite._Lerp(xf0, xf1, ys); - } - + * @param {number} y + */ + let R2 = (seed, amp, freq, coord, x, y) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 38.283687591552734375, + freq, + coord, + false, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 16.0, + freq, + coord, + true, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); + break; + } + }; + /** - * @private + * * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector3} coord * @param {number} x * @param {number} y * @param {number} z - * @returns {number} */ - _SingleValueR3(seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - let zs = FastNoiseLite._InterpHermite(z - z0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - xs + let R3 = (seed, amp, freq, coord, x, y, z) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 32.69428253173828125, + freq, + coord, + false, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 7.71604938271605, + freq, + coord, + true, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); + break; + } + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + return R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] ); - let xf11 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - xs + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + return R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs); } - + } + + /** + * @private + */ + _DomainWarpSingle() { /** - * @private + * + * @param {Vector2} coord */ - _DoSingleDomainWarp() { - /** - * - * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector2} coord - * @param {number} x - * @param {number} y - */ - let R2 = (seed, amp, freq, coord, x, y) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 38.283687591552734375, - freq, - coord, - false, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 16.0, - freq, - coord, - true, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); - break; - } - }; - - /** - * - * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector3} coord - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, amp, freq, coord, x, y, z) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 32.69428253173828125, - freq, - coord, - false, - x, - y, - z - ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 7.71604938271605, - freq, - coord, - true, - x, - y, - z - ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); - break; + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; } - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - return R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5] - ); + default: + break; } - - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - return R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + break; + } + default: + break; } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); } - + } + + _DomainWarpFractalProgressive() { /** - * @private + * + * @param {Vector2} coord */ - _DomainWarpSingle() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { let xs = coord.x; let ys = coord.y; switch (this._DomainWarpType) { @@ -2745,19 +2780,25 @@ default: break; } - + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { let xs = coord.x; let ys = coord.y; let zs = coord.z; @@ -2772,7 +2813,6 @@ zs += xy * 0.577350269189626; } break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: { let xz = xs + zs; @@ -2783,783 +2823,689 @@ ys += xz * 0.577350269189626; } break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + } + break; + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + /** + * @private + */ + _DomainWarpFractalIndependent() { + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + } + default: + break; + } + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { const R3 = 2.0 / 3.0; let r = (xs + ys + zs) * R3; // Rotation, not skew xs = r - xs; ys = r - ys; zs = r - zs; - break; } - default: - break; - } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); + break; + default: + break; } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); + + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + /** + * @private + */ + _SingleDomainWarpBasicGrid() { + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + + let R2 = (seed, warpAmp, frequency, coord, x, y) => { + let xf = x * frequency; + let yf = y * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); + let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + hash0 = this._HashR2(seed, x0, y1) & (255 << 1); + hash1 = this._HashR2(seed, x1, y1) & (255 << 1); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; + coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { + let xf = x * frequency; + let yf = y * frequency; + let zf = z * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + let z0 = Math.floor(zf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + let zs = FastNoiseLite._InterpHermite(zf - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); + let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); + let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); + let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); + + hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); + + lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); + + lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + coord.x += + FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * + warpAmp; + coord.y += + FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * + warpAmp; + coord.z += + FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * + warpAmp; + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] + ); } - - _DomainWarpFractalProgressive() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - } - default: - break; - } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - } - break; - default: - break; - } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); } - + } + + /** + * @private + */ + _SingleDomainWarpOpenSimplex2Gradient() { /** - * @private + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y */ - _DomainWarpFractalIndependent() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - } - default: - break; - } - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - } - break; - default: - break; - } - - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; + let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + x *= frequency; + y *= frequency; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let vx, vy; + vx = vy = 0; + + let a = 0.5 - x0 * x0 - y0 * y0; + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i, j) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i, j); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x0 * xg + y0 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; } - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } - } - - /** - * @private - */ - _SingleDomainWarpBasicGrid() { - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord - * @param {number} x - * @param {number} y - */ - - let R2 = (seed, warpAmp, frequency, coord, x, y) => { - let xf = x * frequency; - let yf = y * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); - let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); - - let lx0x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0], - this._RandVecs2D[hash1], - xs - ); - let ly0x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0 | 1], - this._RandVecs2D[hash1 | 1], - xs - ); - - hash0 = this._HashR2(seed, x0, y1) & (255 << 1); - hash1 = this._HashR2(seed, x1, y1) & (255 << 1); - - let lx1x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0], - this._RandVecs2D[hash1], - xs - ); - let ly1x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0 | 1], - this._RandVecs2D[hash1 | 1], - xs - ); - - coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; - coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; - }; - - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { - let xf = x * frequency; - let yf = y * frequency; - let zf = z * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - let z0 = Math.floor(zf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - let zs = FastNoiseLite._InterpHermite(zf - z0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); - let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); - - let lx0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - let ly0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - let lz0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); - - let lx1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - let ly1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - let lz1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); - let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); - let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); - - hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); - - lx0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - ly0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - lz0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); - - lx1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - ly1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - lz1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - coord.x += - FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * - warpAmp; - coord.y += - FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * - warpAmp; - coord.z += - FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * - warpAmp; - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5] - ); + vx += aaaa * xo; + vy += aaaa * yo; } - - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + if (c > 0) { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + let cccc = c * c * (c * c); + let xo, yo; + if (outGradOnly) { + let hash = + this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & + (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x2 * xg + y2 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += cccc * xo; + vy += cccc * yo; } - } - - /** - * @private - */ - _SingleDomainWarpOpenSimplex2Gradient() { - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y - */ - let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - x *= frequency; - y *= frequency; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let vx, vy; - vx = vy = 0; - - let a = 0.5 - x0 * x0 - y0 * y0; - if (a > 0) { - let aaaa = a * a * (a * a); + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); let xo, yo; if (outGradOnly) { - let hash = this._HashR2(seed, i, j) & (255 << 1); + let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); xo = this._RandVecs2D[hash]; yo = this._RandVecs2D[hash | 1]; } else { - let hash = this._HashR2(seed, i, j); + let hash = this._HashR2(seed, i, j + this._PrimeY); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); let xg = this._Gradients2D[index1]; let yg = this._Gradients2D[index1 | 1]; - let value = x0 * xg + y0 * yg; + let value = x1 * xg + y1 * yg; let xgo = this._RandVecs2D[index2]; let ygo = this._RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } - vx += aaaa * xo; - vy += aaaa * yo; + vx += bbbb * xo; + vy += bbbb * yo; } - - let c = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - if (c > 0) { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - let cccc = c * c * (c * c); + } else { + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); let xo, yo; if (outGradOnly) { - let hash = - this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & - (255 << 1); + let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); xo = this._RandVecs2D[hash]; yo = this._RandVecs2D[hash | 1]; } else { - let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); + let hash = this._HashR2(seed, i + this._PrimeX, j); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); let xg = this._Gradients2D[index1]; let yg = this._Gradients2D[index1 | 1]; - let value = x2 * xg + y2 * yg; + let value = x1 * xg + y1 * yg; let xgo = this._RandVecs2D[index2]; let ygo = this._RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } - vx += cccc * xo; - vy += cccc * yo; + vx += bbbb * xo; + vy += bbbb * yo; } - - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i, j + this._PrimeY); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += bbbb * xo; - vy += bbbb * yo; + } + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { + x *= frequency; + y *= frequency; + z *= frequency; + + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let xNSign = (-x0 - 1.0) | 1; + let yNSign = (-y0 - 1.0) | 1; + let zNSign = (-z0 - 1.0) | 1; + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let vx, vy, vz; + vx = vy = vz = 0; + + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + for (let l = 0; ; l++) { + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i, j, k) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i, j, k); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x0 * xg + y0 * yg + z0 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; } + vx += aaaa * xo; + vy += aaaa * yo; + vz += aaaa * zo; + } + + let b = a; + let i1 = i; + let j1 = j; + let k1 = k; + let x1 = x0; + let y1 = y0; + let z1 = z0; + + if (ax0 >= ay0 && ax0 >= az0) { + x1 += xNSign; + b = b + ax0 + ax0; + i1 -= xNSign * this._PrimeX; + } else if (ay0 > ax0 && ay0 >= az0) { + y1 += yNSign; + b = b + ay0 + ay0; + j1 -= yNSign * this._PrimeY; } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i + this._PrimeX, j); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += bbbb * xo; - vy += bbbb * yo; - } + z1 += zNSign; + b = b + az0 + az0; + k1 -= zNSign * this._PrimeZ; } - - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - }; - - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { - x *= frequency; - y *= frequency; - z *= frequency; - - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let xNSign = (-x0 - 1.0) | 1; - let yNSign = (-y0 - 1.0) | 1; - let zNSign = (-z0 - 1.0) | 1; - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let vx, vy, vz; - vx = vy = vz = 0; - - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - for (let l = 0; ; l++) { - if (a > 0) { - let aaaa = a * a * (a * a); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i, j, k) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; - } else { - let hash = this._HashR3(seed, i, j, k); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x0 * xg + y0 * yg + z0 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; - } - vx += aaaa * xo; - vy += aaaa * yo; - vz += aaaa * zo; - } - - let b = a; - let i1 = i; - let j1 = j; - let k1 = k; - let x1 = x0; - let y1 = y0; - let z1 = z0; - - if (ax0 >= ay0 && ax0 >= az0) { - x1 += xNSign; - b = b + ax0 + ax0; - i1 -= xNSign * this._PrimeX; - } else if (ay0 > ax0 && ay0 >= az0) { - y1 += yNSign; - b = b + ay0 + ay0; - j1 -= yNSign * this._PrimeY; + + if (b > 1) { + b -= 1; + let bbbb = b * b * (b * b); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; } else { - z1 += zNSign; - b = b + az0 + az0; - k1 -= zNSign * this._PrimeZ; - } - - if (b > 1) { - b -= 1; - let bbbb = b * b * (b * b); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; - } else { - let hash = this._HashR3(seed, i1, j1, k1); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x1 * xg + y1 * yg + z1 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; - } - vx += bbbb * xo; - vy += bbbb * yo; - vz += bbbb * zo; + let hash = this._HashR3(seed, i1, j1, k1); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x1 * xg + y1 * yg + z1 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; } - - if (l === 1) break; - - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; - - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; - - a += 0.75 - ax0 - (ay0 + az0); - - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; - - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; - - seed += 1293373; + vx += bbbb * xo; + vy += bbbb * yo; + vz += bbbb * zo; } - - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - coord.z += vz * warpAmp; - }; - - if (arguments.length === 7) { - R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); - } - - if (arguments.length === 8) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6], - arguments[7] - ); + + if (l === 1) break; + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed += 1293373; } + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + coord.z += vz * warpAmp; + }; + + if (arguments.length === 7) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); } - } - - class Vector2 { - /** - * 2d Vector - * @param {number} x - * @param {number} y - */ - constructor(x, y) { - this.x = x; - this.y = y; + + if (arguments.length === 8) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6], + arguments[7] + ); } } - - class Vector3 { - /** - * 3d Vector - * @param {number} x - * @param {number} y - * @param {number} z - */ - constructor(x, y, z) { - this.x = x; - this.y = y; - this.z = z; - } + } + + class Vector2 { + /** + * 2d Vector + * @param {number} x + * @param {number} y + */ + constructor(x, y) { + this.x = x; + this.y = y; + } + } + + class Vector3 { + /** + * 3d Vector + * @param {number} x + * @param {number} y + * @param {number} z + */ + constructor(x, y, z) { + this.x = x; + this.y = y; + this.z = z; } - - Scratch.extensions.register(new Noise()); - })(Scratch); - \ No newline at end of file + } + + Scratch.extensions.register(new Noise()); +})(Scratch); From 402e4c3999c6396a8c63e5af6e5171296c3d0763 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 19:09:24 -0700 Subject: [PATCH 24/36] stupid formatting --- extensions/Corbnorb/noise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 0cd8f13480..5ca8194282 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -189,7 +189,7 @@ const inverted = Cast.toBoolean(args.INVERTED); if (id in noises) { let value = noises[id].GetNoise(args.X, args.Y, args.Z); - value = (inverted == true) ? -value : value; + value = inverted == true ? -value : value; value = (value + 1) / 2; switch (easing) { case "linear": From 106d2f68efb6680060dc90b09078290e649b6702 Mon Sep 17 00:00:00 2001 From: Cubester Date: Wed, 25 Dec 2024 21:18:10 -0500 Subject: [PATCH 25/36] We don't need this, man --- extensions/Corbnorb/noise.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 5ca8194282..8b09604a78 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -16,12 +16,6 @@ const Translate = Scratch.translate; class Noise { - constructor() { - this.noiseSeed = 0; - this.worleySeed = 0; - this.time = performance.now(); - } - getInfo() { return { id: "corbnorbsnoise", From 95e68233fccb997cd7e70b72db2594e9e7e36901 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 19:52:33 -0700 Subject: [PATCH 26/36] minified --- extensions/Corbnorb/noise.js | 3273 +--------------------------------- 1 file changed, 3 insertions(+), 3270 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 8b09604a78..ef446667a1 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -232,3274 +232,7 @@ // SOFTWARE. // - class FastNoiseLite { - static NoiseType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2S: "OpenSimplex2S", - Cellular: "Cellular", - Perlin: "Perlin", - ValueCubic: "ValueCubic", - Value: "Value", - }); - static RotationType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", - }); - static FractalType = Object.freeze({ - None: "None", - FBm: "FBm", - Ridged: "Ridged", - PingPong: "PingPong", - DomainWarpProgressive: "DomainWarpProgressive", - DomainWarpIndependent: "DomainWarpIndependent", - }); - static CellularDistanceFunction = Object.freeze({ - Euclidean: "Euclidean", - EuclideanSq: "EuclideanSq", - Manhattan: "Manhattan", - Hybrid: "Hybrid", - }); - static CellularReturnType = Object.freeze({ - CellValue: "CellValue", - Distance: "Distance", - Distance2: "Distance2", - Distance2Add: "Distance2Add", - Distance2Sub: "Distance2Sub", - Distance2Mul: "Distance2Mul", - Distance2Div: "Distance2Div", - }); - static DomainWarpType = Object.freeze({ - OpenSimplex2: "OpenSimplex2", - OpenSimplex2Reduced: "OpenSimplex2Reduced", - BasicGrid: "BasicGrid", - }); - static TransformType3D = Object.freeze({ - None: "None", - ImproveXYPlanes: "ImproveXYPlanes", - ImproveXZPlanes: "ImproveXZPlanes", - DefaultOpenSimplex2: "DefaultOpenSimplex2", - }); + // minified, find original here: + // https://raw.githubusercontent.com/Auburn/FastNoiseLite/refs/heads/master/JavaScript/FastNoiseLite.js - /* Private */ - _Seed = 1337; - _Frequency = 0.01; - _NoiseType = FastNoiseLite.NoiseType.OpenSimplex2; - _RotationType3D = FastNoiseLite.RotationType3D.None; - _TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - _DomainWarpAmp = 1.0; - - _FractalType = FastNoiseLite.FractalType.None; - _Octaves = 3; - _Lacunarity = 2.0; - _Gain = 0.5; - _WeightedStrength = 0.0; - _PingPongStrength = 2.0; - - _FractalBounding = 1 / 1.75; - - _CellularDistanceFunction = - FastNoiseLite.CellularDistanceFunction.EuclideanSq; - _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; - _CellularJitterModifier = 1.0; - - _DomainWarpType = FastNoiseLite.DomainWarpType.OpenSimplex2; - _WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - - /** - * @description Create new FastNoiseLite object with optional seed - * @param {number} [seed] - * @constructor - */ - constructor(seed) { - if (seed !== undefined) { - this._Seed = seed; - } - } - - /** - * @description Sets seed used for all noise types - * @remarks Default: 1337 - * @default 1337 - * @param {number} seed - */ - SetSeed(seed) { - this._Seed = seed; - } - - /** - * @description Sets frequency for all noise types - * @remarks Default: 0.01 - * @default 0.01 - * @param {number} frequency - */ - SetFrequency(frequency) { - this._Frequency = frequency; - } - - /** - * @description Sets noise algorithm used for GetNoise(...) - * @remarks Default: OpenSimplex2 - * @default FastNoiseLite.NoiseType.OpenSimplex2 - * @param {FastNoiseLite.NoiseType} noiseType - */ - SetNoiseType(noiseType) { - this._NoiseType = noiseType; - this._UpdateTransformType3D(); - } - - /** - * @description Sets domain rotation type for 3D Noise and 3D DomainWarp. - * @description Can aid in reducing directional artifacts when sampling a 2D plane in 3D - * @remarks Default: None - * @default FastNoiseLite.RotationType3D.None - * @param {FastNoiseLite.RotationType3D} rotationType3D - */ - SetRotationType3D(rotationType3D) { - this._RotationType3D = rotationType3D; - this._UpdateTransformType3D(); - this._UpdateWarpTransformType3D(); - } - - /** - * @description Sets method for combining octaves in all fractal noise types - * @remarks Default: None - * @default FastNoiseLite.FractalType.None - * @param {FastNoiseLite.FractalType} fractalType - */ - SetFractalType(fractalType) { - this._FractalType = fractalType; - } - - /** - * @description Sets octave count for all fractal noise types - * @remarks Default: 3 - * @default 3 - * @param {number} octaves - */ - SetFractalOctaves(octaves) { - this._Octaves = octaves; - this._CalculateFractalBounding(); - } - - /** - * @description Sets octave lacunarity for all fractal noise types - * @remarks Default: 2.0 - * @default 2.0 - * @param {number} lacunarity - */ - SetFractalLacunarity(lacunarity) { - this._Lacunarity = lacunarity; - } - - /** - * @description Sets octave gain for all fractal noise types - * @remarks Default: 0.5 - * @default 0.5 - * @param {number} gain - */ - SetFractalGain(gain) { - this._Gain = gain; - this._CalculateFractalBounding(); - } - - /** - * @description Sets octave weighting for all none DomainWarp fratal types - * @remarks Default: 0.0 | Keep between 0...1 to maintain -1...1 output bounding - * @default 0.5 - * @param {number} weightedStrength - */ - SetFractalWeightedStrength(weightedStrength) { - this._WeightedStrength = weightedStrength; - } - - /** - * @description Sets strength of the fractal ping pong effect - * @remarks Default: 2.0 - * @default 2.0 - * @param {number} pingPongStrength - */ - SetFractalPingPongStrength(pingPongStrength) { - this._PingPongStrength = pingPongStrength; - } - - /** - * @description Sets distance function used in cellular noise calculations - * @remarks Default: EuclideanSq - * @default FastNoiseLite.CellularDistanceFunction.EuclideanSq - * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction - */ - SetCellularDistanceFunction(cellularDistanceFunction) { - this._CellularDistanceFunction = cellularDistanceFunction; - } - - /** - * @description Sets return type from cellular noise calculations - * @remarks Default: Distance - * @default FastNoiseLite.CellularReturnType.Distance - * @param {FastNoiseLite.CellularReturnType} cellularReturnType - */ - SetCellularReturnType(cellularReturnType) { - this._CellularReturnType = cellularReturnType; - } - - /** - * @description Sets the maximum distance a cellular point can move from it's grid position - * @remarks Default: 1.0 - * @default 1.0 - * @param {number} cellularJitter - */ - SetCellularJitter(cellularJitter) { - this._CellularJitterModifier = cellularJitter; - } - - /** - * @description Sets the warp algorithm when using DomainWarp(...) - * @remarks Default: OpenSimplex2 - * @default FastNoiseLite.DomainWarpType.OpenSimplex2 - * @param {FastNoiseLite.DomainWarpType} domainWarpType - */ - SetDomainWarpType(domainWarpType) { - this._DomainWarpType = domainWarpType; - this._UpdateWarpTransformType3D(); - } - - /** - * @description Sets the maximum warp distance from original position when using DomainWarp(...) - * @remarks Default: 1.0 - * @default 1.0 - * @param {number} domainWarpAmp - */ - SetDomainWarpAmp(domainWarpAmp) { - this._DomainWarpAmp = domainWarpAmp; - } - - /** - * @description 2D/3D noise at given position using current settings - * @param {number} x X coordinate - * @param {number} y Y coordinate - * @param {number} [z] Z coordinate - * @return {number} Noise output bounded between -1...1 - */ - GetNoise(x, y, z) { - /** - * @description 2D noise at given position using current settings - * @param {number} x - * @param {number} y - * @return {number} Noise output bounded between -1...1 - */ - let R2 = (x, y) => { - x *= this._Frequency; - y *= this._Frequency; - - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (x + y) * F2; - x += t; - y += t; - break; - } - default: - break; - } - - switch (this._FractalType) { - default: - return this._GenNoiseSingleR2(this._Seed, x, y); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR2(x, y); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR2(x, y); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR2(x, y); - } - }; - - /** - * @description 3D noise at given position using current settings - * @param {number} x - * @param {number} y - * @param {number} z - * @return {number} Noise output bounded between -1...1 - */ - let R3 = (x, y, z) => { - x *= this._Frequency; - y *= this._Frequency; - z *= this._Frequency; - - switch (this._TransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: { - let xy = x + y; - let s2 = xy * -0.211324865405187; - z *= 0.577350269189626; - x += s2 - z; - y += s2 - z; - z += xy * 0.577350269189626; - break; - } - case FastNoiseLite.TransformType3D.ImproveXZPlanes: { - let xz = x + z; - let s2 = xz * -0.211324865405187; - y *= 0.577350269189626; - x += s2 - y; - z += s2 - y; - y += xz * 0.577350269189626; - break; - } - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { - const R3 = 2.0 / 3.0; - let r = (x + y + z) * R3; - x = r - x; - y = r - y; - z = r - z; - break; - } - default: - break; - } - - switch (this._FractalType) { - default: - return this._GenNoiseSingleR3(this._Seed, x, y, z); - case FastNoiseLite.FractalType.FBm: - return this._GenFractalFBmR3(x, y, z); - case FastNoiseLite.FractalType.Ridged: - return this._GenFractalRidgedR3(x, y, z); - case FastNoiseLite.FractalType.PingPong: - return this._GenFractalPingPongR3(x, y, z); - } - }; - - if (arguments.length === 2) { - return R2(x, y); - } - - if (arguments.length === 3) { - return R3(x, y, z); - } - } - - /** - * @description 2D/3D warps the input position using current domain warp settings - * @param {Vector2|Vector3} coord - */ - DomainWrap(coord) { - switch (this._FractalType) { - default: - this._DomainWarpSingle(coord); - break; - case FastNoiseLite.FractalType.DomainWarpProgressive: - this._DomainWarpFractalProgressive(coord); - break; - case FastNoiseLite.FractalType.DomainWarpIndependent: - this._DomainWarpFractalIndependent(coord); - break; - } - } - - // prettier-ignore - _Gradients2D = [ - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, - 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, - 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, - -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, - -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, - -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, - 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, - -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, - ]; - - // prettier-ignore - _RandVecs2D = [ - -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, - -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, - -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, - -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, - -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, - 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, - 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, - -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, - 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, - 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, - -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, - 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, - -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, - -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, - 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, - -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, - 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, - 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, - 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, - -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, - 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, - 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, - 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, - -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, - 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, - -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, - 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, - -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, - 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, - -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, - 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, - 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, - ]; - - // prettier-ignore - _Gradients3D = [ - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, - 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, - 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, - 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 - ]; - - // prettier-ignore - _RandVecs3D = [ - -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, - 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, - -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, - -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, - 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, - -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, - 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, - 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, - -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, - 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, - -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, - -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, - 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, - 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, - -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, - 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, - 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, - -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, - -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, - -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, - -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, - 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, - 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, - 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, - -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, - -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, - -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, - 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, - 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, - 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, - 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, - -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 - ]; - - _PrimeX = 501125321; - _PrimeY = 1136930381; - _PrimeZ = 1720413743; - - /** - * @private - * @param {number} a - * @param {number} b - * @param {number} t - * @returns {number} - */ - static _Lerp(a, b, t) { - return a + t * (b - a); - } - - /** - * @private - * @param {number} t - * @returns {number} - */ - static _InterpHermite(t) { - return t * t * (3 - 2 * t); - } - - /** - * @private - * @param t - * @returns {number} - */ - static _InterpQuintic(t) { - return t * t * t * (t * (t * 6 - 15) + 10); - } - - /** - * @private - * @param {number} a - * @param {number} b - * @param {number} c - * @param {number} d - * @param {number} t - * @returns {number} - */ - static _CubicLerp(a, b, c, d, t) { - const p = d - c - (a - b); - return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; - } - - /** - * @private - * @param {number} t - * @returns {number} - */ - static _PingPong(t) { - t -= Math.trunc(t * 0.5) * 2; - return t < 1 ? t : 2 - t; - } - - /** - * @private - */ - _CalculateFractalBounding() { - let gain = Math.abs(this._Gain); - let amp = gain; - let ampFractal = 1.0; - for (let i = 1; i < this._Octaves; i++) { - ampFractal += amp; - amp *= gain; - } - this._FractalBounding = 1 / ampFractal; - } - - /** - * @private - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @returns {number} - */ - _HashR2(seed, xPrimed, yPrimed) { - let hash = seed ^ xPrimed ^ yPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @returns {number} - */ - _HashR3(seed, xPrimed, yPrimed, zPrimed) { - let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; - hash = Math.imul(hash, 0x27d4eb2d); - return hash; - } - - /** - * @private - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @returns {number} - */ - _ValCoordR2(seed, xPrimed, yPrimed) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @returns {number} - */ - _ValCoordR3(seed, xPrimed, yPrimed, zPrimed) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - - hash = Math.imul(hash, hash); - hash ^= hash << 19; - return hash * (1 / 2147483648.0); - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} xd - * @param {number} yd - * @returns {number} - */ - _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - hash ^= hash >> 15; - hash &= 127 << 1; - - let xg = this._Gradients2D[hash]; - let yg = this._Gradients2D[hash | 1]; - - return xd * xg + yd * yg; - } - - /** - * - * @param {number} seed - * @param {number} xPrimed - * @param {number} yPrimed - * @param {number} zPrimed - * @param {number} xd - * @param {number} yd - * @param {number} zd - * @returns {number} - */ - _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - hash ^= hash >> 15; - hash &= 63 << 2; - - let xg = this._Gradients3D[hash]; - let yg = this._Gradients3D[hash | 1]; - let zg = this._Gradients3D[hash | 2]; - - return xd * xg + yd * yg + zd * zg; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenNoiseSingleR2(seed, x, y) { - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R2(seed, x, y); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR2(seed, x, y); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR2(seed, x, y); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR2(seed, x, y); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR2(seed, x, y); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR2(seed, x, y); - default: - return 0; - } - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenNoiseSingleR3(seed, x, y, z) { - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - return this._SingleOpenSimplex2R3(seed, x, y, z); - case FastNoiseLite.NoiseType.OpenSimplex2S: - return this._SingleOpenSimplex2SR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Cellular: - return this._SingleCellularR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Perlin: - return this._SinglePerlinR3(seed, x, y, z); - case FastNoiseLite.NoiseType.ValueCubic: - return this._SingleValueCubicR3(seed, x, y, z); - case FastNoiseLite.NoiseType.Value: - return this._SingleValueR3(seed, x, y, z); - default: - return 0; - } - } - - /** - * @private - */ - _UpdateTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; - default: - switch (this._NoiseType) { - case FastNoiseLite.NoiseType.OpenSimplex2: - case FastNoiseLite.NoiseType.OpenSimplex2S: - this._TransformType3D = - FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - break; - default: - this._TransformType3D = FastNoiseLite.TransformType3D.None; - break; - } - break; - } - } - - /** - * @private - */ - _UpdateWarpTransformType3D() { - switch (this._RotationType3D) { - case FastNoiseLite.RotationType3D.ImproveXYPlanes: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.ImproveXYPlanes; - break; - case FastNoiseLite.RotationType3D.ImproveXZPlanes: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.ImproveXZPlanes; - break; - default: - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._WarpTransformType3D = - FastNoiseLite.TransformType3D.DefaultOpenSimplex2; - break; - default: - this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; - break; - } - break; - } - } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalFBmR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR2(seed++, x, y); - sum += noise * amp; - amp *= FastNoiseLite._Lerp( - 1.0, - Math.min(noise + 1, 2) * 0.5, - this._WeightedStrength - ); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; - } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalFBmR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = this._GenNoiseSingleR3(seed++, x, y, z); - sum += noise * amp; - amp *= FastNoiseLite._Lerp( - 1.0, - (noise + 1) * 0.5, - this._WeightedStrength - ); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; - } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalRidgedR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; - } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalRidgedR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); - sum += (noise * -2 + 1) * amp; - amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; - } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @returns {number} - */ - _GenFractalPingPongR2(x, y) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - amp *= this._Gain; - } - return sum; - } - - /** - * @private - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _GenFractalPingPongR3(x, y, z) { - let seed = this._Seed; - let sum = 0; - let amp = this._FractalBounding; - - for (let i = 0; i < this._Octaves; i++) { - let noise = FastNoiseLite._PingPong( - (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength - ); - sum += (noise - 0.5) * 2 * amp; - amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); - - x *= this._Lacunarity; - y *= this._Lacunarity; - z *= this._Lacunarity; - amp *= this._Gain; - } - return sum; - } - - /** - * - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleOpenSimplex2R2(seed, x, y) { - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let n0, n1, n2; - - let a = 0.5 - x0 * x0 - y0 * y0; - - if (a <= 0) { - n0 = 0; - } else { - n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); - } - - let c = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - - if (c <= 0) { - n2 = 0; - } else { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - n2 = - c * - c * - (c * c) * - this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); - } - - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = - b * - b * - (b * b) * - this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); - } - } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b <= 0) { - n1 = 0; - } else { - n1 = - b * - b * - (b * b) * - this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); - } - } - return (n0 + n1 + n2) * 99.83685446303647; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleOpenSimplex2R3(seed, x, y, z) { - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let yNSign = Math.trunc((-1.0 - y0) | 1); - let xNSign = Math.trunc((-1.0 - x0) | 1); - let zNSign = Math.trunc((-1.0 - z0) | 1); - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let value = 0; - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - - for (let l = 0; ; l++) { - if (a > 0) { - value += - a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); - } - - if (ax0 >= ay0 && ax0 >= az0) { - let b = a + ax0 + ax0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i - xNSign * this._PrimeX, - j, - k, - x0 + xNSign, - y0, - z0 - ); - } - } else if (ay0 > ax0 && ay0 >= az0) { - let b = a + ay0 + ay0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i, - j - yNSign * this._PrimeY, - k, - x0, - y0 + yNSign, - z0 - ); - } - } else { - let b = a + az0 + az0; - if (b > 1) { - b -= 1; - value += - b * - b * - (b * b) * - this._GradCoordR3( - seed, - i, - j, - k - zNSign * this._PrimeZ, - x0, - y0, - z0 + zNSign - ); - } - } - - if (l === 1) { - break; - } - - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; - - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; - - a += 0.75 - ax0 - (ay0 + az0); - - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; - - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; - - seed = ~seed; - } - return value * 32.69428253173828125; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleOpenSimplex2SR2(seed, x, y) { - // 2D OpenSimplex2S case is a modified 2D simplex noise. - - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - /* - * --- Skew moved to TransformNoiseCoordinate method --- - * final FNLfloat F2 = 0.5f * (SQRT3 - 1); - * FNLfloat s = (x + y) * F2; - * x += s; y += s; - */ - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - let i1 = i + this._PrimeX; - let j1 = j + this._PrimeY; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; - let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); - let a1 = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); - let x1 = x0 - (1 - 2 * G2); - let y1 = y0 - (1 - 2 * G2); - value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); - - // Nested conditionals were faster than compact bit logic/arithmetic. - let xmyi = xi - yi; - if (t > G2) { - if (xi + xmyi > 1) { - let x2 = x0 + (3 * G2 - 2); - let y2 = y0 + (3 * G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2( - seed, - i + (this._PrimeX << 1), - j + this._PrimeY, - x2, - y2 - ); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } - } - - if (yi - xmyi > 1) { - let x3 = x0 + (3 * G2 - 1); - let y3 = y0 + (3 * G2 - 2); - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR2( - seed, - i + this._PrimeX, - j + (this._PrimeY << 1), - x3, - y3 - ); - } - } else { - let x3 = x0 + (G2 - 1); - let y3 = y0 + G2; - let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; - if (a3 > 0) { - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); - } - } - } else { - if (xi + xmyi < 0) { - let x2 = x0 + (1 - G2); - let y2 = y0 - G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); - } - } else { - let x2 = x0 + (G2 - 1); - let y2 = y0 + G2; - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); - } - } - - if (yi < xmyi) { - let x2 = x0 - G2; - let y2 = y0 - (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); - } - } else { - let x2 = x0 + G2; - let y2 = y0 + (G2 - 1); - let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; - if (a2 > 0) { - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); - } - } - } - - return value * 18.24196194486065; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleOpenSimplex2SR3(seed, x, y, z) { - // 3D OpenSimplex2S case uses two offset rotated cube grids. - - /* - * --- Rotation moved to TransformNoiseCoordinate method --- - * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); - * FNLfloat r = (x + y + z) * R3; // Rotation, not skew - * x = r - x; y = r - y; z = r - z; - */ - - let i = Math.floor(x); - let j = Math.floor(y); - let k = Math.floor(z); - let xi = x - i; - let yi = y - j; - let zi = z - k; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - let seed2 = seed + 1293373; - - let xNMask = Math.trunc(-0.5 - xi); - let yNMask = Math.trunc(-0.5 - yi); - let zNMask = Math.trunc(-0.5 - zi); - - let x0 = xi + xNMask; - let y0 = yi + yNMask; - let z0 = zi + zNMask; - let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; - let value = - a0 * - a0 * - (a0 * a0) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x0, - y0, - z0 - ); - - let x1 = xi - 0.5; - let y1 = yi - 0.5; - let z1 = zi - 0.5; - let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; - value += - a1 * - a1 * - (a1 * a1) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + this._PrimeY, - k + this._PrimeZ, - x1, - y1, - z1 - ); - - let xAFlipMask0 = ((xNMask | 1) << 1) * x1; - let yAFlipMask0 = ((yNMask | 1) << 1) * y1; - let zAFlipMask0 = ((zNMask | 1) << 1) * z1; - let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; - let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; - let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; - - let skip5 = false; - let a2 = xAFlipMask0 + a0; - if (a2 > 0) { - let x2 = x0 - (xNMask | 1); - value += - a2 * - a2 * - (a2 * a2) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x2, - y0, - z0 - ); - } else { - let a3 = yAFlipMask0 + zAFlipMask0 + a0; - - if (a3 > 0) { - let x3 = x0; - let y3 = y0 - (yNMask | 1); - let z3 = z0 - (zNMask | 1); - value += - a3 * - a3 * - (a3 * a3) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x3, - y3, - z3 - ); - } - - let a4 = xAFlipMask1 + a1; - if (a4 > 0) { - let x4 = (xNMask | 1) + x1; - value += - a4 * - a4 * - (a4 * a4) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + this._PrimeZ, - x4, - y1, - z1 - ); - skip5 = true; - } - } - - let skip9 = false; - let a6 = yAFlipMask0 + a0; - if (a6 > 0) { - let x6 = x0; - let y6 = y0 - (yNMask | 1); - value += - a6 * - a6 * - (a6 * a6) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - x6, - y6, - z0 - ); - } else { - let a7 = xAFlipMask0 + zAFlipMask0 + a0; - if (a7 > 0) { - let x7 = x0 - (xNMask | 1); - let y7 = y0; - let z7 = z0 - (zNMask | 1); - value += - a7 * - a7 * - (a7 * a7) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - x7, - y7, - z7 - ); - } - - let a8 = yAFlipMask1 + a1; - if (a8 > 0) { - let x8 = x1; - let y8 = (yNMask | 1) + y1; - value += - a8 * - a8 * - (a8 * a8) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - x8, - y8, - z1 - ); - skip9 = true; - } - } - - let skipD = false; - let aA = zAFlipMask0 + a0; - if (aA > 0) { - let xA = x0; - let yA = y0; - let zA = z0 - (zNMask | 1); - value += - aA * - aA * - (aA * aA) * - this._GradCoordR3( - seed, - i + (xNMask & this._PrimeX), - j + (yNMask & this._PrimeY), - k + (~zNMask & this._PrimeZ), - xA, - yA, - zA - ); - } else { - let aB = xAFlipMask0 + yAFlipMask0 + a0; - if (aB > 0) { - let xB = x0 - (xNMask | 1); - let yB = y0 - (yNMask | 1); - value += - aB * - aB * - (aB * aB) * - this._GradCoordR3( - seed, - i + (~xNMask & this._PrimeX), - j + (~yNMask & this._PrimeY), - k + (zNMask & this._PrimeZ), - xB, - yB, - z0 - ); - } - - let aC = zAFlipMask1 + a1; - if (aC > 0) { - let xC = x1; - let yC = y1; - let zC = (zNMask | 1) + z1; - value += - aC * - aC * - (aC * aC) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - xC, - yC, - zC - ); - skipD = true; - } - } - - if (!skip5) { - let a5 = yAFlipMask1 + zAFlipMask1 + a1; - if (a5 > 0) { - let x5 = x1; - let y5 = (yNMask | 1) + y1; - let z5 = (zNMask | 1) + z1; - value += - a5 * - a5 * - (a5 * a5) * - this._GradCoordR3( - seed2, - i + this._PrimeX, - j + (yNMask & (this._PrimeY << 1)), - k + (zNMask & (this._PrimeZ << 1)), - x5, - y5, - z5 - ); - } - } - - if (!skip9) { - let a9 = xAFlipMask1 + zAFlipMask1 + a1; - if (a9 > 0) { - let x9 = (xNMask | 1) + x1; - let y9 = y1; - let z9 = (zNMask | 1) + z1; - value += - a9 * - a9 * - (a9 * a9) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX * 2)), - j + this._PrimeY, - k + (zNMask & (this._PrimeZ << 1)), - x9, - y9, - z9 - ); - } - } - - if (!skipD) { - let aD = xAFlipMask1 + yAFlipMask1 + a1; - if (aD > 0) { - let xD = (xNMask | 1) + x1; - let yD = (yNMask | 1) + y1; - value += - aD * - aD * - (aD * aD) * - this._GradCoordR3( - seed2, - i + (xNMask & (this._PrimeX << 1)), - j + (yNMask & (this._PrimeY << 1)), - k + this._PrimeZ, - xD, - yD, - z1 - ); - } - } - - return value * 9.046026385208288; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleCellularR2(seed, x, y) { - /** - * - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - let xr = Math.round(x); - let yr = Math.round(y); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - - let closestHash = 0; - - let cellularJitter = 0.43701595 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - - switch (this._CellularDistanceFunction) { - default: - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY; - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = Math.abs(vecX) + Math.abs(vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this._HashR2(seed, xPrimed, yPrimed); - let idx = hash & (255 << 1); - - let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; - - let newDistance = - Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); - - distance1 = Math.max(Math.min(distance1, newDistance), distance0); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - } - - if ( - this._CellularDistanceFunction === - FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue - ) { - distance0 = Math.sqrt(distance0); - - if ( - this._CellularReturnType !== - FastNoiseLite.CellularReturnType.CellValue - ) { - distance1 = Math.sqrt(distance1); - } - } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; - } - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleCellularR3(seed, x, y, z) { - let xr = Math.round(x); - let yr = Math.round(y); - let zr = Math.round(z); - - let distance0 = Number.MAX_VALUE; - let distance1 = Number.MAX_VALUE; - let closestHash = 0; - - let cellularJitter = 0.39614353 * this._CellularJitterModifier; - - let xPrimed = (xr - 1) * this._PrimeX; - let yPrimedBase = (yr - 1) * this._PrimeY; - let zPrimedBase = (zr - 1) * this._PrimeZ; - - switch (this._CellularDistanceFunction) { - case FastNoiseLite.CellularDistanceFunction.Euclidean: - case FastNoiseLite.CellularDistanceFunction.EuclideanSq: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 - ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Manhattan: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = - Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 - ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - case FastNoiseLite.CellularDistanceFunction.Hybrid: - for (let xi = xr - 1; xi <= xr + 1; xi++) { - let yPrimed = yPrimedBase; - - for (let yi = yr - 1; yi <= yr + 1; yi++) { - let zPrimed = zPrimedBase; - - for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); - let idx = hash & (255 << 2); - - let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; - - let newDistance = - Math.abs(vecX) + - Math.abs(vecY) + - Math.abs(vecZ) + - (vecX * vecX + vecY * vecY + vecZ * vecZ); - - distance1 = Math.max( - Math.min(distance1, newDistance), - distance0 - ); - if (newDistance < distance0) { - distance0 = newDistance; - closestHash = hash; - } - zPrimed += this._PrimeZ; - } - yPrimed += this._PrimeY; - } - xPrimed += this._PrimeX; - } - break; - default: - break; - } - - if ( - this._CellularDistanceFunction === - FastNoiseLite.CellularDistanceFunction.Euclidean && - this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue - ) { - distance0 = Math.sqrt(distance0); - - if ( - this._CellularReturnType !== - FastNoiseLite.CellularReturnType.CellValue - ) { - distance1 = Math.sqrt(distance1); - } - } - - switch (this._CellularReturnType) { - case FastNoiseLite.CellularReturnType.CellValue: - return closestHash * (1 / 2147483648.0); - case FastNoiseLite.CellularReturnType.Distance: - return distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2: - return distance1 - 1; - case FastNoiseLite.CellularReturnType.Distance2Add: - return (distance1 + distance0) * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Sub: - return distance1 - distance0 - 1; - case FastNoiseLite.CellularReturnType.Distance2Mul: - return distance1 * distance0 * 0.5 - 1; - case FastNoiseLite.CellularReturnType.Distance2Div: - return distance0 / distance1 - 1; - default: - return 0; - } - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SinglePerlinR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xd0 = x - x0; - let yd0 = y - y0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y0, xd0, yd0), - this._GradCoordR2(seed, x1, y0, xd1, yd0), - xs - ); - let xf1 = FastNoiseLite._Lerp( - this._GradCoordR2(seed, x0, y1, xd0, yd1), - this._GradCoordR2(seed, x1, y1, xd1, yd1), - xs - ); - - return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SinglePerlinR3(seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xd0 = x - x0; - let yd0 = y - y0; - let zd0 = z - z0; - let xd1 = xd0 - 1; - let yd1 = yd0 - 1; - let zd1 = zd0 - 1; - - let xs = FastNoiseLite._InterpQuintic(xd0); - let ys = FastNoiseLite._InterpQuintic(yd0); - let zs = FastNoiseLite._InterpQuintic(zd0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), - this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), - this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), - this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), - xs - ); - let xf11 = FastNoiseLite._Lerp( - this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), - this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), - xs - ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleValueCubicR2(seed, x, y) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - - let xs = x - x1; - let ys = y - y1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - - return ( - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y0), - this._ValCoordR2(seed, x1, y0), - this._ValCoordR2(seed, x2, y0), - this._ValCoordR2(seed, x3, y0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y1), - this._ValCoordR2(seed, x1, y1), - this._ValCoordR2(seed, x2, y1), - this._ValCoordR2(seed, x3, y1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y2), - this._ValCoordR2(seed, x1, y2), - this._ValCoordR2(seed, x2, y2), - this._ValCoordR2(seed, x3, y2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR2(seed, x0, y3), - this._ValCoordR2(seed, x1, y3), - this._ValCoordR2(seed, x2, y3), - this._ValCoordR2(seed, x3, y3), - xs - ), - ys - ) * - (1 / (1.5 * 1.5)) - ); - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleValueCubicR3(seed, x, y, z) { - let x1 = Math.floor(x); - let y1 = Math.floor(y); - let z1 = Math.floor(z); - - let xs = x - x1; - let ys = y - y1; - let zs = z - z1; - - x1 = Math.imul(x1, this._PrimeX); - y1 = Math.imul(y1, this._PrimeY); - z1 = Math.imul(z1, this._PrimeZ); - - let x0 = x1 - this._PrimeX; - let y0 = y1 - this._PrimeY; - let z0 = z1 - this._PrimeZ; - let x2 = x1 + this._PrimeX; - let y2 = y1 + this._PrimeY; - let z2 = z1 + this._PrimeZ; - let x3 = x1 + (this._PrimeX << 1); - let y3 = y1 + (this._PrimeY << 1); - let z3 = z1 + (this._PrimeZ << 1); - - return ( - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - this._ValCoordR3(seed, x2, y0, z0), - this._ValCoordR3(seed, x3, y0, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - this._ValCoordR3(seed, x2, y1, z0), - this._ValCoordR3(seed, x3, y1, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z0), - this._ValCoordR3(seed, x1, y2, z0), - this._ValCoordR3(seed, x2, y2, z0), - this._ValCoordR3(seed, x3, y2, z0), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z0), - this._ValCoordR3(seed, x1, y3, z0), - this._ValCoordR3(seed, x2, y3, z0), - this._ValCoordR3(seed, x3, y3, z0), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - this._ValCoordR3(seed, x2, y0, z1), - this._ValCoordR3(seed, x3, y0, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - this._ValCoordR3(seed, x2, y1, z1), - this._ValCoordR3(seed, x3, y1, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z1), - this._ValCoordR3(seed, x1, y2, z1), - this._ValCoordR3(seed, x2, y2, z1), - this._ValCoordR3(seed, x3, y2, z1), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z1), - this._ValCoordR3(seed, x1, y3, z1), - this._ValCoordR3(seed, x2, y3, z1), - this._ValCoordR3(seed, x3, y3, z1), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z2), - this._ValCoordR3(seed, x1, y0, z2), - this._ValCoordR3(seed, x2, y0, z2), - this._ValCoordR3(seed, x3, y0, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z2), - this._ValCoordR3(seed, x1, y1, z2), - this._ValCoordR3(seed, x2, y1, z2), - this._ValCoordR3(seed, x3, y1, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z2), - this._ValCoordR3(seed, x1, y2, z2), - this._ValCoordR3(seed, x2, y2, z2), - this._ValCoordR3(seed, x3, y2, z2), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z2), - this._ValCoordR3(seed, x1, y3, z2), - this._ValCoordR3(seed, x2, y3, z2), - this._ValCoordR3(seed, x3, y3, z2), - xs - ), - ys - ), - FastNoiseLite._CubicLerp( - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y0, z3), - this._ValCoordR3(seed, x1, y0, z3), - this._ValCoordR3(seed, x2, y0, z3), - this._ValCoordR3(seed, x3, y0, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y1, z3), - this._ValCoordR3(seed, x1, y1, z3), - this._ValCoordR3(seed, x2, y1, z3), - this._ValCoordR3(seed, x3, y1, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y2, z3), - this._ValCoordR3(seed, x1, y2, z3), - this._ValCoordR3(seed, x2, y2, z3), - this._ValCoordR3(seed, x3, y2, z3), - xs - ), - FastNoiseLite._CubicLerp( - this._ValCoordR3(seed, x0, y3, z3), - this._ValCoordR3(seed, x1, y3, z3), - this._ValCoordR3(seed, x2, y3, z3), - this._ValCoordR3(seed, x3, y3, z3), - xs - ), - ys - ), - zs - ) * - (1 / (1.5 * 1.5 * 1.5)) - ); - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @returns {number} - */ - _SingleValueR2(seed, x, y) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let xf0 = FastNoiseLite._Lerp( - this._ValCoordR2(seed, x0, y0), - this._ValCoordR2(seed, x1, y0), - xs - ); - let xf1 = FastNoiseLite._Lerp( - this._ValCoordR2(seed, x0, y1), - this._ValCoordR2(seed, x1, y1), - xs - ); - - return FastNoiseLite._Lerp(xf0, xf1, ys); - } - - /** - * @private - * @param {number} seed - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {number} - */ - _SingleValueR3(seed, x, y, z) { - let x0 = Math.floor(x); - let y0 = Math.floor(y); - let z0 = Math.floor(z); - - let xs = FastNoiseLite._InterpHermite(x - x0); - let ys = FastNoiseLite._InterpHermite(y - y0); - let zs = FastNoiseLite._InterpHermite(z - z0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let xf00 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z0), - this._ValCoordR3(seed, x1, y0, z0), - xs - ); - let xf10 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z0), - this._ValCoordR3(seed, x1, y1, z0), - xs - ); - let xf01 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y0, z1), - this._ValCoordR3(seed, x1, y0, z1), - xs - ); - let xf11 = FastNoiseLite._Lerp( - this._ValCoordR3(seed, x0, y1, z1), - this._ValCoordR3(seed, x1, y1, z1), - xs - ); - - let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); - let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); - - return FastNoiseLite._Lerp(yf0, yf1, zs); - } - - /** - * @private - */ - _DoSingleDomainWarp() { - /** - * - * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector2} coord - * @param {number} x - * @param {number} y - */ - let R2 = (seed, amp, freq, coord, x, y) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 38.283687591552734375, - freq, - coord, - false, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 16.0, - freq, - coord, - true, - x, - y - ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); - break; - } - }; - - /** - * - * @param {number} seed - * @param {number} amp - * @param {number} freq - * @param {Vector3} coord - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, amp, freq, coord, x, y, z) => { - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 32.69428253173828125, - freq, - coord, - false, - x, - y, - z - ); - break; - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: - this._SingleDomainWarpOpenSimplex2Gradient( - seed, - amp * 7.71604938271605, - freq, - coord, - true, - x, - y, - z - ); - break; - case FastNoiseLite.DomainWarpType.BasicGrid: - this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); - break; - } - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - return R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5] - ); - } - - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - return R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); - } - } - - /** - * @private - */ - _DomainWarpSingle() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - } - default: - break; - } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - break; - } - default: - break; - } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } - } - - _DomainWarpFractalProgressive() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - } - default: - break; - } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - } - break; - default: - break; - } - - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } - } - - /** - * @private - */ - _DomainWarpFractalIndependent() { - /** - * - * @param {Vector2} coord - */ - let R2 = (coord) => { - let xs = coord.x; - let ys = coord.y; - switch (this._DomainWarpType) { - case FastNoiseLite.DomainWarpType.OpenSimplex2: - case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { - const SQRT3 = 1.7320508075688772; - const F2 = 0.5 * (SQRT3 - 1); - let t = (xs + ys) * F2; - xs += t; - ys += t; - break; - } - default: - break; - } - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; - - /** - * - * @param {Vector3} coord - */ - let R3 = (coord) => { - let xs = coord.x; - let ys = coord.y; - let zs = coord.z; - switch (this._WarpTransformType3D) { - case FastNoiseLite.TransformType3D.ImproveXYPlanes: - { - let xy = xs + ys; - let s2 = xy * -0.211324865405187; - zs *= 0.577350269189626; - xs += s2 - zs; - ys = ys + s2 - zs; - zs += xy * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.ImproveXZPlanes: - { - let xz = xs + zs; - let s2 = xz * -0.211324865405187; - ys *= 0.577350269189626; - xs += s2 - ys; - zs += s2 - ys; - ys += xz * 0.577350269189626; - } - break; - case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: - { - const R3 = 2.0 / 3.0; - let r = (xs + ys + zs) * R3; // Rotation, not skew - xs = r - xs; - ys = r - ys; - zs = r - zs; - } - break; - default: - break; - } - - let seed = this._Seed; - let amp = this._DomainWarpAmp * this._FractalBounding; - let freq = this._Frequency; - for (let i = 0; i < this._Octaves; i++) { - this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); - - seed++; - amp *= this._Gain; - freq *= this._Lacunarity; - } - }; - - if (arguments.length === 1 && arguments[0] instanceof Vector2) { - return R2(arguments[0]); - } - - if (arguments.length === 1 && arguments[0] instanceof Vector3) { - return R3(arguments[0]); - } - } - - /** - * @private - */ - _SingleDomainWarpBasicGrid() { - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord - * @param {number} x - * @param {number} y - */ - - let R2 = (seed, warpAmp, frequency, coord, x, y) => { - let xf = x * frequency; - let yf = y * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - - let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); - let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); - - let lx0x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0], - this._RandVecs2D[hash1], - xs - ); - let ly0x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0 | 1], - this._RandVecs2D[hash1 | 1], - xs - ); - - hash0 = this._HashR2(seed, x0, y1) & (255 << 1); - hash1 = this._HashR2(seed, x1, y1) & (255 << 1); - - let lx1x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0], - this._RandVecs2D[hash1], - xs - ); - let ly1x = FastNoiseLite._Lerp( - this._RandVecs2D[hash0 | 1], - this._RandVecs2D[hash1 | 1], - xs - ); - - coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; - coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; - }; - - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { - let xf = x * frequency; - let yf = y * frequency; - let zf = z * frequency; - - let x0 = Math.floor(xf); - let y0 = Math.floor(yf); - let z0 = Math.floor(zf); - - let xs = FastNoiseLite._InterpHermite(xf - x0); - let ys = FastNoiseLite._InterpHermite(yf - y0); - let zs = FastNoiseLite._InterpHermite(zf - z0); - - x0 = Math.imul(x0, this._PrimeX); - y0 = Math.imul(y0, this._PrimeY); - z0 = Math.imul(z0, this._PrimeZ); - let x1 = x0 + this._PrimeX; - let y1 = y0 + this._PrimeY; - let z1 = z0 + this._PrimeZ; - - let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); - let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); - - let lx0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - let ly0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - let lz0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); - - let lx1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - let ly1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - let lz1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); - let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); - let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); - - hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); - - lx0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - ly0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - lz0x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); - hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); - - lx1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0], - this._RandVecs3D[hash1], - xs - ); - ly1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 1], - this._RandVecs3D[hash1 | 1], - xs - ); - lz1x = FastNoiseLite._Lerp( - this._RandVecs3D[hash0 | 2], - this._RandVecs3D[hash1 | 2], - xs - ); - - coord.x += - FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * - warpAmp; - coord.y += - FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * - warpAmp; - coord.z += - FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * - warpAmp; - }; - - if (arguments.length === 6 && arguments[3] instanceof Vector2) { - R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5] - ); - } - - if (arguments.length === 7 && arguments[3] instanceof Vector3) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); - } - } - - /** - * @private - */ - _SingleDomainWarpOpenSimplex2Gradient() { - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector2} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y - */ - let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { - const SQRT3 = 1.7320508075688772; - const G2 = (3 - SQRT3) / 6; - - x *= frequency; - y *= frequency; - - let i = Math.floor(x); - let j = Math.floor(y); - let xi = x - i; - let yi = y - j; - - let t = (xi + yi) * G2; - let x0 = xi - t; - let y0 = yi - t; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - - let vx, vy; - vx = vy = 0; - - let a = 0.5 - x0 * x0 - y0 * y0; - if (a > 0) { - let aaaa = a * a * (a * a); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i, j) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i, j); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x0 * xg + y0 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += aaaa * xo; - vy += aaaa * yo; - } - - let c = - 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + - (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); - if (c > 0) { - let x2 = x0 + (2 * G2 - 1); - let y2 = y0 + (2 * G2 - 1); - let cccc = c * c * (c * c); - let xo, yo; - if (outGradOnly) { - let hash = - this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & - (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x2 * xg + y2 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += cccc * xo; - vy += cccc * yo; - } - - if (y0 > x0) { - let x1 = x0 + G2; - let y1 = y0 + (G2 - 1); - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i, j + this._PrimeY); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += bbbb * xo; - vy += bbbb * yo; - } - } else { - let x1 = x0 + (G2 - 1); - let y1 = y0 + G2; - let b = 0.5 - x1 * x1 - y1 * y1; - if (b > 0) { - let bbbb = b * b * (b * b); - let xo, yo; - if (outGradOnly) { - let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); - xo = this._RandVecs2D[hash]; - yo = this._RandVecs2D[hash | 1]; - } else { - let hash = this._HashR2(seed, i + this._PrimeX, j); - let index1 = hash & (127 << 1); - let index2 = (hash >> 7) & (255 << 1); - let xg = this._Gradients2D[index1]; - let yg = this._Gradients2D[index1 | 1]; - let value = x1 * xg + y1 * yg; - let xgo = this._RandVecs2D[index2]; - let ygo = this._RandVecs2D[index2 | 1]; - xo = value * xgo; - yo = value * ygo; - } - vx += bbbb * xo; - vy += bbbb * yo; - } - } - - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - }; - - /** - * - * @param {number} seed - * @param {number} warpAmp - * @param {number} frequency - * @param {Vector3} coord - * @param {boolean} outGradOnly - * @param {number} x - * @param {number} y - * @param {number} z - */ - let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { - x *= frequency; - y *= frequency; - z *= frequency; - - let i = Math.round(x); - let j = Math.round(y); - let k = Math.round(z); - let x0 = x - i; - let y0 = y - j; - let z0 = z - k; - - let xNSign = (-x0 - 1.0) | 1; - let yNSign = (-y0 - 1.0) | 1; - let zNSign = (-z0 - 1.0) | 1; - - let ax0 = xNSign * -x0; - let ay0 = yNSign * -y0; - let az0 = zNSign * -z0; - - i = Math.imul(i, this._PrimeX); - j = Math.imul(j, this._PrimeY); - k = Math.imul(k, this._PrimeZ); - - let vx, vy, vz; - vx = vy = vz = 0; - - let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); - for (let l = 0; ; l++) { - if (a > 0) { - let aaaa = a * a * (a * a); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i, j, k) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; - } else { - let hash = this._HashR3(seed, i, j, k); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x0 * xg + y0 * yg + z0 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; - } - vx += aaaa * xo; - vy += aaaa * yo; - vz += aaaa * zo; - } - - let b = a; - let i1 = i; - let j1 = j; - let k1 = k; - let x1 = x0; - let y1 = y0; - let z1 = z0; - - if (ax0 >= ay0 && ax0 >= az0) { - x1 += xNSign; - b = b + ax0 + ax0; - i1 -= xNSign * this._PrimeX; - } else if (ay0 > ax0 && ay0 >= az0) { - y1 += yNSign; - b = b + ay0 + ay0; - j1 -= yNSign * this._PrimeY; - } else { - z1 += zNSign; - b = b + az0 + az0; - k1 -= zNSign * this._PrimeZ; - } - - if (b > 1) { - b -= 1; - let bbbb = b * b * (b * b); - let xo, yo, zo; - if (outGradOnly) { - let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); - xo = this._RandVecs3D[hash]; - yo = this._RandVecs3D[hash | 1]; - zo = this._RandVecs3D[hash | 2]; - } else { - let hash = this._HashR3(seed, i1, j1, k1); - let index1 = hash & (63 << 2); - let index2 = (hash >> 6) & (255 << 2); - let xg = this._Gradients3D[index1]; - let yg = this._Gradients3D[index1 | 1]; - let zg = this._Gradients3D[index1 | 2]; - let value = x1 * xg + y1 * yg + z1 * zg; - let xgo = this._RandVecs3D[index2]; - let ygo = this._RandVecs3D[index2 | 1]; - let zgo = this._RandVecs3D[index2 | 2]; - xo = value * xgo; - yo = value * ygo; - zo = value * zgo; - } - vx += bbbb * xo; - vy += bbbb * yo; - vz += bbbb * zo; - } - - if (l === 1) break; - - ax0 = 0.5 - ax0; - ay0 = 0.5 - ay0; - az0 = 0.5 - az0; - - x0 = xNSign * ax0; - y0 = yNSign * ay0; - z0 = zNSign * az0; - - a += 0.75 - ax0 - (ay0 + az0); - - i += (xNSign >> 1) & this._PrimeX; - j += (yNSign >> 1) & this._PrimeY; - k += (zNSign >> 1) & this._PrimeZ; - - xNSign = -xNSign; - yNSign = -yNSign; - zNSign = -zNSign; - - seed += 1293373; - } - - coord.x += vx * warpAmp; - coord.y += vy * warpAmp; - coord.z += vz * warpAmp; - }; - - if (arguments.length === 7) { - R2( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); - } - - if (arguments.length === 8) { - R3( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6], - arguments[7] - ); - } - } - } - - class Vector2 { - /** - * 2d Vector - * @param {number} x - * @param {number} y - */ - constructor(x, y) { - this.x = x; - this.y = y; - } - } - - class Vector3 { - /** - * 3d Vector - * @param {number} x - * @param {number} y - * @param {number} z - */ - constructor(x, y, z) { - this.x = x; - this.y = y; - this.z = z; - } - } - - Scratch.extensions.register(new Noise()); -})(Scratch); +class FastNoiseLite{static NoiseType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2S:"OpenSimplex2S",Cellular:"Cellular",Perlin:"Perlin",ValueCubic:"ValueCubic",Value:"Value"});static RotationType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes"});static FractalType=Object.freeze({None:"None",FBm:"FBm",Ridged:"Ridged",PingPong:"PingPong",DomainWarpProgressive:"DomainWarpProgressive",DomainWarpIndependent:"DomainWarpIndependent"});static CellularDistanceFunction=Object.freeze({Euclidean:"Euclidean",EuclideanSq:"EuclideanSq",Manhattan:"Manhattan",Hybrid:"Hybrid"});static CellularReturnType=Object.freeze({CellValue:"CellValue",Distance:"Distance",Distance2:"Distance2",Distance2Add:"Distance2Add",Distance2Sub:"Distance2Sub",Distance2Mul:"Distance2Mul",Distance2Div:"Distance2Div"});static DomainWarpType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2Reduced:"OpenSimplex2Reduced",BasicGrid:"BasicGrid"});static TransformType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes",DefaultOpenSimplex2:"DefaultOpenSimplex2"});_Seed=1337;_Frequency=.01;_NoiseType=FastNoiseLite.NoiseType.OpenSimplex2;_RotationType3D=FastNoiseLite.RotationType3D.None;_TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;_DomainWarpAmp=1;_FractalType=FastNoiseLite.FractalType.None;_Octaves=3;_Lacunarity=2;_Gain=.5;_WeightedStrength=0;_PingPongStrength=2;_FractalBounding=1/1.75;_CellularDistanceFunction=FastNoiseLite.CellularDistanceFunction.EuclideanSq;_CellularReturnType=FastNoiseLite.CellularReturnType.Distance;_CellularJitterModifier=1;_DomainWarpType=FastNoiseLite.DomainWarpType.OpenSimplex2;_WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;constructor(e){void 0!==e&&(this._Seed=e)}SetSeed(e){this._Seed=e}SetFrequency(e){this._Frequency=e}SetNoiseType(e){this._NoiseType=e,this._UpdateTransformType3D()}SetRotationType3D(e){this._RotationType3D=e,this._UpdateTransformType3D(),this._UpdateWarpTransformType3D()}SetFractalType(e){this._FractalType=e}SetFractalOctaves(e){this._Octaves=e,this._CalculateFractalBounding()}SetFractalLacunarity(e){this._Lacunarity=e}SetFractalGain(e){this._Gain=e,this._CalculateFractalBounding()}SetFractalWeightedStrength(e){this._WeightedStrength=e}SetFractalPingPongStrength(e){this._PingPongStrength=e}SetCellularDistanceFunction(e){this._CellularDistanceFunction=e}SetCellularReturnType(e){this._CellularReturnType=e}SetCellularJitter(e){this._CellularJitterModifier=e}SetDomainWarpType(e){this._DomainWarpType=e,this._UpdateWarpTransformType3D()}SetDomainWarpAmp(e){this._DomainWarpAmp=e}GetNoise(e,t,i){let s=(e,t)=>{switch(e*=this._Frequency,t*=this._Frequency,this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:let i=(e+t)*(.5*(1.7320508075688772-1));e+=i,t+=i}switch(this._FractalType){default:return this._GenNoiseSingleR2(this._Seed,e,t);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR2(e,t);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR2(e,t);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR2(e,t)}},a=(e,t,i)=>{switch(e*=this._Frequency,t*=this._Frequency,i*=this._Frequency,this._TransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let s=e+t,a=-.211324865405187*s;e+=a-(i*=.577350269189626),t+=a-i,i+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let s=e+i,a=-.211324865405187*s;e+=a-(t*=.577350269189626),i+=a-t,t+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let s=(e+t+i)*(2/3);e=s-e,t=s-t,i=s-i}switch(this._FractalType){default:return this._GenNoiseSingleR3(this._Seed,e,t,i);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR3(e,t,i);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR3(e,t,i);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR3(e,t,i)}};return 2===arguments.length?s(e,t):3===arguments.length?a(e,t,i):void 0}DomainWrap(e){switch(this._FractalType){default:this._DomainWarpSingle(e);break;case FastNoiseLite.FractalType.DomainWarpProgressive:this._DomainWarpFractalProgressive(e);break;case FastNoiseLite.FractalType.DomainWarpIndependent:this._DomainWarpFractalIndependent(e)}}_Gradients2D=[.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.38268343236509,.923879532511287,.923879532511287,.38268343236509,.923879532511287,-.38268343236509,.38268343236509,-.923879532511287,-.38268343236509,-.923879532511287,-.923879532511287,-.38268343236509,-.923879532511287,.38268343236509,-.38268343236509,.923879532511287];_RandVecs2D=[-.2700222198,-.9628540911,.3863092627,-.9223693152,.04444859006,-.999011673,-.5992523158,-.8005602176,-.7819280288,.6233687174,.9464672271,.3227999196,-.6514146797,-.7587218957,.9378472289,.347048376,-.8497875957,-.5271252623,-.879042592,.4767432447,-.892300288,-.4514423508,-.379844434,-.9250503802,-.9951650832,.0982163789,.7724397808,-.6350880136,.7573283322,-.6530343002,-.9928004525,-.119780055,-.0532665713,.9985803285,.9754253726,-.2203300762,-.7665018163,.6422421394,.991636706,.1290606184,-.994696838,.1028503788,-.5379205513,-.84299554,.5022815471,-.8647041387,.4559821461,-.8899889226,-.8659131224,-.5001944266,.0879458407,-.9961252577,-.5051684983,.8630207346,.7753185226,-.6315704146,-.6921944612,.7217110418,-.5191659449,-.8546734591,.8978622882,-.4402764035,-.1706774107,.9853269617,-.9353430106,-.3537420705,-.9992404798,.03896746794,-.2882064021,-.9575683108,-.9663811329,.2571137995,-.8759714238,-.4823630009,-.8303123018,-.5572983775,.05110133755,-.9986934731,-.8558373281,-.5172450752,.09887025282,.9951003332,.9189016087,.3944867976,-.2439375892,-.9697909324,-.8121409387,-.5834613061,-.9910431363,.1335421355,.8492423985,-.5280031709,-.9717838994,-.2358729591,.9949457207,.1004142068,.6241065508,-.7813392434,.662910307,.7486988212,-.7197418176,.6942418282,-.8143370775,-.5803922158,.104521054,-.9945226741,-.1065926113,-.9943027784,.445799684,-.8951327509,.105547406,.9944142724,-.992790267,.1198644477,-.8334366408,.552615025,.9115561563,-.4111755999,.8285544909,-.5599084351,.7217097654,-.6921957921,.4940492677,-.8694339084,-.3652321272,-.9309164803,-.9696606758,.2444548501,.08925509731,-.996008799,.5354071276,-.8445941083,-.1053576186,.9944343981,-.9890284586,.1477251101,.004856104961,.9999882091,.9885598478,.1508291331,.9286129562,-.3710498316,-.5832393863,-.8123003252,.3015207509,.9534596146,-.9575110528,.2883965738,.9715802154,-.2367105511,.229981792,.9731949318,.955763816,-.2941352207,.740956116,.6715534485,-.9971513787,-.07542630764,.6905710663,-.7232645452,-.290713703,-.9568100872,.5912777791,-.8064679708,-.9454592212,-.325740481,.6664455681,.74555369,.6236134912,.7817328275,.9126993851,-.4086316587,-.8191762011,.5735419353,-.8812745759,-.4726046147,.9953313627,.09651672651,.9855650846,-.1692969699,-.8495980887,.5274306472,.6174853946,-.7865823463,.8508156371,.52546432,.9985032451,-.05469249926,.1971371563,-.9803759185,.6607855748,-.7505747292,-.03097494063,.9995201614,-.6731660801,.739491331,-.7195018362,-.6944905383,.9727511689,.2318515979,.9997059088,-.0242506907,.4421787429,-.8969269532,.9981350961,-.061043673,-.9173660799,-.3980445648,-.8150056635,-.5794529907,-.8789331304,.4769450202,.0158605829,.999874213,-.8095464474,.5870558317,-.9165898907,-.3998286786,-.8023542565,.5968480938,-.5176737917,.8555780767,-.8154407307,-.5788405779,.4022010347,-.9155513791,-.9052556868,-.4248672045,.7317445619,.6815789728,-.5647632201,-.8252529947,-.8403276335,-.5420788397,-.9314281527,.363925262,.5238198472,.8518290719,.7432803869,-.6689800195,-.985371561,-.1704197369,.4601468731,.88784281,.825855404,.5638819483,.6182366099,.7859920446,.8331502863,-.553046653,.1500307506,.9886813308,-.662330369,-.7492119075,-.668598664,.743623444,.7025606278,.7116238924,-.5419389763,-.8404178401,-.3388616456,.9408362159,.8331530315,.5530425174,-.2989720662,-.9542618632,.2638522993,.9645630949,.124108739,-.9922686234,-.7282649308,-.6852956957,.6962500149,.7177993569,-.9183535368,.3957610156,-.6326102274,-.7744703352,-.9331891859,-.359385508,-.1153779357,-.9933216659,.9514974788,-.3076565421,-.08987977445,-.9959526224,.6678496916,.7442961705,.7952400393,-.6062947138,-.6462007402,-.7631674805,-.2733598753,.9619118351,.9669590226,-.254931851,-.9792894595,.2024651934,-.5369502995,-.8436138784,-.270036471,-.9628500944,-.6400277131,.7683518247,-.7854537493,-.6189203566,.06005905383,-.9981948257,-.02455770378,.9996984141,-.65983623,.751409442,-.6253894466,-.7803127835,-.6210408851,-.7837781695,.8348888491,.5504185768,-.1592275245,.9872419133,.8367622488,.5475663786,-.8675753916,-.4973056806,-.2022662628,-.9793305667,.9399189937,.3413975472,.9877404807,-.1561049093,-.9034455656,.4287028224,.1269804218,-.9919052235,-.3819600854,.924178821,.9754625894,.2201652486,-.3204015856,-.9472818081,-.9874760884,.1577687387,.02535348474,-.9996785487,.4835130794,-.8753371362,-.2850799925,-.9585037287,-.06805516006,-.99768156,-.7885244045,-.6150034663,.3185392127,-.9479096845,.8880043089,.4598351306,.6476921488,-.7619021462,.9820241299,.1887554194,.9357275128,-.3527237187,-.8894895414,.4569555293,.7922791302,.6101588153,.7483818261,.6632681526,-.7288929755,-.6846276581,.8729032783,-.4878932944,.8288345784,.5594937369,.08074567077,.9967347374,.9799148216,-.1994165048,-.580730673,-.8140957471,-.4700049791,-.8826637636,.2409492979,.9705377045,.9437816757,-.3305694308,-.8927998638,-.4504535528,-.8069622304,.5906030467,.06258973166,.9980393407,-.9312597469,.3643559849,.5777449785,.8162173362,-.3360095855,-.941858566,.697932075,-.7161639607,-.002008157227,-.9999979837,-.1827294312,-.9831632392,-.6523911722,.7578824173,-.4302626911,-.9027037258,-.9985126289,-.05452091251,-.01028102172,-.9999471489,-.4946071129,.8691166802,-.2999350194,.9539596344,.8165471961,.5772786819,.2697460475,.962931498,-.7306287391,-.6827749597,-.7590952064,-.6509796216,-.907053853,.4210146171,-.5104861064,-.8598860013,.8613350597,.5080373165,.5007881595,-.8655698812,-.654158152,.7563577938,-.8382755311,-.545246856,.6940070834,.7199681717,.06950936031,.9975812994,.1702942185,-.9853932612,.2695973274,.9629731466,.5519612192,-.8338697815,.225657487,-.9742067022,.4215262855,-.9068161835,.4881873305,-.8727388672,-.3683854996,-.9296731273,-.9825390578,.1860564427,.81256471,.5828709909,.3196460933,-.9475370046,.9570913859,.2897862643,-.6876655497,-.7260276109,-.9988770922,-.047376731,-.1250179027,.992154486,-.8280133617,.560708367,.9324863769,-.3612051451,.6394653183,.7688199442,-.01623847064,-.9998681473,-.9955014666,-.09474613458,-.81453315,.580117012,.4037327978,-.9148769469,.9944263371,.1054336766,-.1624711654,.9867132919,-.9949487814,-.100383875,-.6995302564,.7146029809,.5263414922,-.85027327,-.5395221479,.841971408,.6579370318,.7530729462,.01426758847,-.9998982128,-.6734383991,.7392433447,.639412098,-.7688642071,.9211571421,.3891908523,-.146637214,-.9891903394,-.782318098,.6228791163,-.5039610839,-.8637263605,-.7743120191,-.6328039957];_Gradients3D=[0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,1,1,0,0,0,-1,1,0,-1,1,0,0,0,-1,-1,0];_RandVecs3D=[-.7292736885,-.6618439697,.1735581948,0,.790292081,-.5480887466,-.2739291014,0,.7217578935,.6226212466,-.3023380997,0,.565683137,-.8208298145,-.0790000257,0,.760049034,-.5555979497,-.3370999617,0,.3713945616,.5011264475,.7816254623,0,-.1277062463,-.4254438999,-.8959289049,0,-.2881560924,-.5815838982,.7607405838,0,.5849561111,-.662820239,-.4674352136,0,.3307171178,.0391653737,.94291689,0,.8712121778,-.4113374369,-.2679381538,0,.580981015,.7021915846,.4115677815,0,.503756873,.6330056931,-.5878203852,0,.4493712205,.601390195,.6606022552,0,-.6878403724,.09018890807,-.7202371714,0,-.5958956522,-.6469350577,.475797649,0,-.5127052122,.1946921978,-.8361987284,0,-.9911507142,-.05410276466,-.1212153153,0,-.2149721042,.9720882117,-.09397607749,0,-.7518650936,-.5428057603,.3742469607,0,.5237068895,.8516377189,-.02107817834,0,.6333504779,.1926167129,-.7495104896,0,-.06788241606,.3998305789,.9140719259,0,-.5538628599,-.4729896695,-.6852128902,0,-.7261455366,-.5911990757,.3509933228,0,-.9229274737,-.1782808786,.3412049336,0,-.6968815002,.6511274338,.3006480328,0,.9608044783,-.2098363234,-.1811724921,0,.06817146062,-.9743405129,.2145069156,0,-.3577285196,-.6697087264,-.6507845481,0,-.1868621131,.7648617052,-.6164974636,0,-.6541697588,.3967914832,.6439087246,0,.6993340405,-.6164538506,.3618239211,0,-.1546665739,.6291283928,.7617583057,0,-.6841612949,-.2580482182,-.6821542638,0,.5383980957,.4258654885,.7271630328,0,-.5026987823,-.7939832935,-.3418836993,0,.3202971715,.2834415347,.9039195862,0,.8683227101,-.0003762656404,-.4959995258,0,.791120031,-.08511045745,.6057105799,0,-.04011016052,-.4397248749,.8972364289,0,.9145119872,.3579346169,-.1885487608,0,-.9612039066,-.2756484276,.01024666929,0,.6510361721,-.2877799159,-.7023778346,0,-.2041786351,.7365237271,.644859585,0,-.7718263711,.3790626912,.5104855816,0,-.3060082741,-.7692987727,.5608371729,0,.454007341,-.5024843065,.7357899537,0,.4816795475,.6021208291,-.6367380315,0,.6961980369,-.3222197429,.641469197,0,-.6532160499,-.6781148932,.3368515753,0,.5089301236,-.6154662304,-.6018234363,0,-.1635919754,-.9133604627,-.372840892,0,.52408019,-.8437664109,.1157505864,0,.5902587356,.4983817807,-.6349883666,0,.5863227872,.494764745,.6414307729,0,.6779335087,.2341345225,.6968408593,0,.7177054546,-.6858979348,.120178631,0,-.5328819713,-.5205125012,.6671608058,0,-.8654874251,-.0700727088,-.4960053754,0,-.2861810166,.7952089234,.5345495242,0,-.04849529634,.9810836427,-.1874115585,0,-.6358521667,.6058348682,.4781800233,0,.6254794696,-.2861619734,.7258696564,0,-.2585259868,.5061949264,-.8227581726,0,.02136306781,.5064016808,-.8620330371,0,.200111773,.8599263484,.4695550591,0,.4743561372,.6014985084,-.6427953014,0,.6622993731,-.5202474575,-.5391679918,0,.08084972818,-.6532720452,.7527940996,0,-.6893687501,.0592860349,.7219805347,0,-.1121887082,-.9673185067,.2273952515,0,.7344116094,.5979668656,-.3210532909,0,.5789393465,-.2488849713,.7764570201,0,.6988182827,.3557169806,-.6205791146,0,-.8636845529,-.2748771249,-.4224826141,0,-.4247027957,-.4640880967,.777335046,0,.5257722489,-.8427017621,.1158329937,0,.9343830603,.316302472,-.1639543925,0,-.1016836419,-.8057303073,-.5834887393,0,-.6529238969,.50602126,-.5635892736,0,-.2465286165,-.9668205684,-.06694497494,0,-.9776897119,-.2099250524,-.007368825344,0,.7736893337,.5734244712,.2694238123,0,-.6095087895,.4995678998,.6155736747,0,.5794535482,.7434546771,.3339292269,0,-.8226211154,.08142581855,.5627293636,0,-.510385483,.4703667658,.7199039967,0,-.5764971849,-.07231656274,-.8138926898,0,.7250628871,.3949971505,-.5641463116,0,-.1525424005,.4860840828,-.8604958341,0,-.5550976208,-.4957820792,.667882296,0,-.1883614327,.9145869398,.357841725,0,.7625556724,-.5414408243,-.3540489801,0,-.5870231946,-.3226498013,-.7424963803,0,.3051124198,.2262544068,-.9250488391,0,.6379576059,.577242424,-.5097070502,0,-.5966775796,.1454852398,-.7891830656,0,-.658330573,.6555487542,-.3699414651,0,.7434892426,.2351084581,.6260573129,0,.5562114096,.8264360377,-.0873632843,0,-.3028940016,-.8251527185,.4768419182,0,.1129343818,-.985888439,-.1235710781,0,.5937652891,-.5896813806,.5474656618,0,.6757964092,-.5835758614,-.4502648413,0,.7242302609,-.1152719764,.6798550586,0,-.9511914166,.0753623979,-.2992580792,0,.2539470961,-.1886339355,.9486454084,0,.571433621,-.1679450851,-.8032795685,0,-.06778234979,.3978269256,.9149531629,0,.6074972649,.733060024,-.3058922593,0,-.5435478392,.1675822484,.8224791405,0,-.5876678086,-.3380045064,-.7351186982,0,-.7967562402,.04097822706,-.6029098428,0,-.1996350917,.8706294745,.4496111079,0,-.02787660336,-.9106232682,-.4122962022,0,-.7797625996,-.6257634692,.01975775581,0,-.5211232846,.7401644346,-.4249554471,0,.8575424857,.4053272873,-.3167501783,0,.1045223322,.8390195772,-.5339674439,0,.3501822831,.9242524096,-.1520850155,0,.1987849858,.07647613266,.9770547224,0,.7845996363,.6066256811,-.1280964233,0,.09006737436,-.9750989929,-.2026569073,0,-.8274343547,-.542299559,.1458203587,0,-.3485797732,-.415802277,.840000362,0,-.2471778936,-.7304819962,-.6366310879,0,-.3700154943,.8577948156,.3567584454,0,.5913394901,-.548311967,-.5913303597,0,.1204873514,-.7626472379,-.6354935001,0,.616959265,.03079647928,.7863922953,0,.1258156836,-.6640829889,-.7369967419,0,-.6477565124,-.1740147258,-.7417077429,0,.6217889313,-.7804430448,-.06547655076,0,.6589943422,-.6096987708,.4404473475,0,-.2689837504,-.6732403169,-.6887635427,0,-.3849775103,.5676542638,.7277093879,0,.5754444408,.8110471154,-.1051963504,0,.9141593684,.3832947817,.131900567,0,-.107925319,.9245493968,.3654593525,0,.377977089,.3043148782,.8743716458,0,-.2142885215,-.8259286236,.5214617324,0,.5802544474,.4148098596,-.7008834116,0,-.1982660881,.8567161266,-.4761596756,0,-.03381553704,.3773180787,-.9254661404,0,-.6867922841,-.6656597827,.2919133642,0,.7731742607,-.2875793547,-.5652430251,0,-.09655941928,.9193708367,-.3813575004,0,.2715702457,-.9577909544,-.09426605581,0,.2451015704,-.6917998565,-.6792188003,0,.977700782,-.1753855374,.1155036542,0,-.5224739938,.8521606816,.02903615945,0,-.7734880599,-.5261292347,.3534179531,0,-.7134492443,-.269547243,.6467878011,0,.1644037271,.5105846203,-.8439637196,0,.6494635788,.05585611296,.7583384168,0,-.4711970882,.5017280509,-.7254255765,0,-.6335764307,-.2381686273,-.7361091029,0,-.9021533097,-.270947803,-.3357181763,0,-.3793711033,.872258117,.3086152025,0,-.6855598966,-.3250143309,.6514394162,0,.2900942212,-.7799057743,-.5546100667,0,-.2098319339,.85037073,.4825351604,0,-.4592603758,.6598504336,-.5947077538,0,.8715945488,.09616365406,-.4807031248,0,-.6776666319,.7118504878,-.1844907016,0,.7044377633,.312427597,.637304036,0,-.7052318886,-.2401093292,-.6670798253,0,.081921007,-.7207336136,-.6883545647,0,-.6993680906,-.5875763221,-.4069869034,0,-.1281454481,.6419895885,.7559286424,0,-.6337388239,-.6785471501,-.3714146849,0,.5565051903,-.2168887573,-.8020356851,0,-.5791554484,.7244372011,-.3738578718,0,.1175779076,-.7096451073,.6946792478,0,-.6134619607,.1323631078,.7785527795,0,.6984635305,-.02980516237,-.715024719,0,.8318082963,-.3930171956,.3919597455,0,.1469576422,.05541651717,-.9875892167,0,.708868575,-.2690503865,.6520101478,0,.2726053183,.67369766,-.68688995,0,-.6591295371,.3035458599,-.6880466294,0,.4815131379,-.7528270071,.4487723203,0,.9430009463,.1675647412,-.2875261255,0,.434802957,.7695304522,-.4677277752,0,.3931996188,.594473625,.7014236729,0,.7254336655,-.603925654,.3301814672,0,.7590235227,-.6506083235,.02433313207,0,-.8552768592,-.3430042733,.3883935666,0,-.6139746835,.6981725247,.3682257648,0,-.7465905486,-.5752009504,.3342849376,0,.5730065677,.810555537,-.1210916791,0,-.9225877367,-.3475211012,-.167514036,0,-.7105816789,-.4719692027,-.5218416899,0,-.08564609717,.3583001386,.929669703,0,-.8279697606,-.2043157126,.5222271202,0,.427944023,.278165994,.8599346446,0,.5399079671,-.7857120652,-.3019204161,0,.5678404253,-.5495413974,-.6128307303,0,-.9896071041,.1365639107,-.04503418428,0,-.6154342638,-.6440875597,.4543037336,0,.1074204368,-.7946340692,.5975094525,0,-.3595449969,-.8885529948,.28495784,0,-.2180405296,.1529888965,.9638738118,0,-.7277432317,-.6164050508,-.3007234646,0,.7249729114,-.00669719484,.6887448187,0,-.5553659455,-.5336586252,.6377908264,0,.5137558015,.7976208196,-.3160000073,0,-.3794024848,.9245608561,-.03522751494,0,.8229248658,.2745365933,-.4974176556,0,-.5404114394,.6091141441,.5804613989,0,.8036581901,-.2703029469,.5301601931,0,.6044318879,.6832968393,.4095943388,0,.06389988817,.9658208605,-.2512108074,0,.1087113286,.7402471173,-.6634877936,0,-.713427712,-.6926784018,.1059128479,0,.6458897819,-.5724548511,-.5050958653,0,-.6553931414,.7381471625,.159995615,0,.3910961323,.9188871375,-.05186755998,0,-.4879022471,-.5904376907,.6429111375,0,.6014790094,.7707441366,-.2101820095,0,-.5677173047,.7511360995,.3368851762,0,.7858573506,.226674665,.5753666838,0,-.4520345543,-.604222686,-.6561857263,0,.002272116345,.4132844051,-.9105991643,0,-.5815751419,-.5162925989,.6286591339,0,-.03703704785,.8273785755,.5604221175,0,-.5119692504,.7953543429,-.3244980058,0,-.2682417366,-.9572290247,-.1084387619,0,-.2322482736,-.9679131102,-.09594243324,0,.3554328906,-.8881505545,.2913006227,0,.7346520519,-.4371373164,.5188422971,0,.9985120116,.04659011161,-.02833944577,0,-.3727687496,-.9082481361,.1900757285,0,.91737377,-.3483642108,.1925298489,0,.2714911074,.4147529736,-.8684886582,0,.5131763485,-.7116334161,.4798207128,0,-.8737353606,.18886992,-.4482350644,0,.8460043821,-.3725217914,.3814499973,0,.8978727456,-.1780209141,-.4026575304,0,.2178065647,-.9698322841,-.1094789531,0,-.1518031304,-.7788918132,-.6085091231,0,-.2600384876,-.4755398075,-.8403819825,0,.572313509,-.7474340931,-.3373418503,0,-.7174141009,.1699017182,-.6756111411,0,-.684180784,.02145707593,-.7289967412,0,-.2007447902,.06555605789,-.9774476623,0,-.1148803697,-.8044887315,.5827524187,0,-.7870349638,.03447489231,.6159443543,0,-.2015596421,.6859872284,.6991389226,0,-.08581082512,-.10920836,-.9903080513,0,.5532693395,.7325250401,-.396610771,0,-.1842489331,-.9777375055,-.1004076743,0,.0775473789,-.9111505856,.4047110257,0,.1399838409,.7601631212,-.6344734459,0,.4484419361,-.845289248,.2904925424,0];_PrimeX=501125321;_PrimeY=1136930381;_PrimeZ=1720413743;static _Lerp(e,t,i){return e+i*(t-e)}static _InterpHermite(e){return e*e*(3-2*e)}static _InterpQuintic(e){return e*e*e*(e*(6*e-15)+10)}static _CubicLerp(e,t,i,s,a){let r=s-i-(e-t);return a*a*a*r+a*a*(e-t-r)+a*(i-e)+t}static _PingPong(e){return(e-=2*Math.trunc(.5*e))<1?e:2-e}_CalculateFractalBounding(){let e=Math.abs(this._Gain),t=e,i=1;for(let s=1;s>15,r&=254,s*this._Gradients2D[r]+a*this._Gradients2D[1|r]}_GradCoordR3(e,t,i,s,a,r,o){let l=this._HashR3(e,t,i,s);return l^=l>>15,l&=252,a*this._Gradients3D[l]+r*this._Gradients3D[1|l]+o*this._Gradients3D[2|l]}_GenNoiseSingleR2(e,t,i){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R2(e,t,i);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR2(e,t,i);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR2(e,t,i);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR2(e,t,i);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR2(e,t,i);case FastNoiseLite.NoiseType.Value:return this._SingleValueR2(e,t,i);default:return 0}}_GenNoiseSingleR3(e,t,i,s){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R3(e,t,i,s);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR3(e,t,i,s);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR3(e,t,i,s);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR3(e,t,i,s);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR3(e,t,i,s);case FastNoiseLite.NoiseType.Value:return this._SingleValueR3(e,t,i,s);default:return 0}}_UpdateTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:this._TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._TransformType3D=FastNoiseLite.TransformType3D.None}}}_UpdateWarpTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._WarpTransformType3D=FastNoiseLite.TransformType3D.None}}}_GenFractalFBmR2(e,t){let i=this._Seed,s=0,a=this._FractalBounding;for(let r=0;rp){let t=p+s,i=d+(s-1),a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l,h+this._PrimeY,t,i)}else{let t=p+(s-1),i=d+s,a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l+this._PrimeX,h,t,i)}return 99.83685446303647*(a+r+o)}_SingleOpenSimplex2R3(e,t,i,s){let a=Math.round(t),r=Math.round(i),o=Math.round(s),l=t-a,h=i-r,n=s-o,_=Math.trunc(-1-h|1),c=Math.trunc(-1-l|1),p=Math.trunc(-1-n|1),d=c*-l,m=_*-h,u=p*-n;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let R=0,L=.6-l*l-(h*h+n*n);for(let t=0;;t++){if(L>0&&(R+=L*L*(L*L)*this._GradCoordR3(e,a,r,o,l,h,n)),d>=m&&d>=u){let t=L+d+d;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a-c*this._PrimeX,r,o,l+c,h,n))}else if(m>d&&m>=u){let t=L+m+m;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r-_*this._PrimeY,o,l,h+_,n))}else{let t=L+u+u;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r,o-p*this._PrimeZ,l,h,n+p))}if(1===t)break;d=.5-d,m=.5-m,u=.5-u,l=c*d,h=_*m,n=p*u,L+=.75-d-(m+u),a+=c>>1&this._PrimeX,r+=_>>1&this._PrimeY,o+=p>>1&this._PrimeZ,c=-c,_=-_,p=-p,e=~e}return 32.69428253173828*R}_SingleOpenSimplex2SR2(e,t,i){const s=.21132486540518713;let a=Math.floor(t),r=Math.floor(i),o=t-a,l=i-r;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY);let h=a+this._PrimeX,n=r+this._PrimeY,_=(o+l)*s,c=o-_,p=l-_,d=2/3-c*c-p*p,m=d*d*(d*d)*this._GradCoordR2(e,a,r,c,p),u=3.1547005383792506*_+(-.6666666666666666+d),R=c-(1-2*s),L=p-(1-2*s);m+=u*u*(u*u)*this._GradCoordR2(e,h,n,R,L);let F=o-l;if(_>s){if(o+F>1){let t=c+(3*s-2),i=p+(3*s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+(this._PrimeX<<1),r+this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}if(l-F>1){let t=c+(3*s-1),i=p+(3*s-2),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r+(this._PrimeY<<1),t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}}else{if(o+F<0){let t=c+(1-s),i=p-s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a-this._PrimeX,r,t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}if(l0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r-this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}}return 18.24196194486065*m}_SingleOpenSimplex2SR3(e,t,i,s){let a=Math.floor(t),r=Math.floor(i),o=Math.floor(s),l=t-a,h=i-r,n=s-o;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let _=e+1293373,c=Math.trunc(-.5-l),p=Math.trunc(-.5-h),d=Math.trunc(-.5-n),m=l+c,u=h+p,R=n+d,L=.75-m*m-u*u-R*R,F=L*L*(L*L)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),m,u,R),D=l-.5,C=h-.5,N=n-.5,P=.75-D*D-C*C-N*N;F+=P*P*(P*P)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+this._PrimeZ,D,C,N);let V=((1|c)<<1)*D,y=((1|p)<<1)*C,T=((1|d)<<1)*N,f=(-2-(c<<2))*D-1,S=(-2-(p<<2))*C-1,g=(-2-(d<<2))*N-1,M=!1,G=V+L;if(G>0){let t=m-(1|c);F+=G*G*(G*G)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),t,u,R)}else{let t=y+T+L;if(t>0){let i=m,s=u-(1|p),l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=f+P;if(i>0){let e=(1|c)+D;F+=i*i*(i*i)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+this._PrimeZ,e,C,N),M=!0}}let b=!1,X=y+L;if(X>0){let t=m,i=u-(1|p);F+=X*X*(X*X)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),t,i,R)}else{let t=V+T+L;if(t>0){let i=m-(1|c),s=u,l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=S+P;if(i>0){let e=D,t=(1|p)+C;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+this._PrimeZ,e,t,N),b=!0}}let W=!1,Y=T+L;if(Y>0){let t=m,i=u,s=R-(1|d);F+=Y*Y*(Y*Y)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),t,i,s)}else{let t=V+y+L;if(t>0){let i=m-(1|c),s=u-(1|p);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),i,s,R)}let i=g+P;if(i>0){let e=D,t=C,s=(1|d)+N;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+(d&this._PrimeZ<<1),e,t,s),W=!0}}if(!M){let e=S+g+P;if(e>0){let t=D,i=(1|p)+C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+(d&this._PrimeZ<<1),t,i,s)}}if(!b){let e=f+g+P;if(e>0){let t=(1|c)+D,i=C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+(d&this._PrimeZ<<1),t,i,s)}}if(!W){let e=f+S+P;if(e>0){let t=(1|c)+D,i=(1|p)+C;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&this._PrimeX<<1),r+(p&this._PrimeY<<1),o+this._PrimeZ,t,i,N)}}return 9.046026385208288*F}_SingleCellularR2(e,t,i){let s=Math.round(t),a=Math.round(i),r=Number.MAX_VALUE,o=Number.MAX_VALUE,l=0,h=.43701595*this._CellularJitterModifier,n=(s-1)*this._PrimeX,_=(a-1)*this._PrimeY;switch(this._CellularDistanceFunction){default:case FastNoiseLite.CellularDistanceFunction.Euclidean:case FastNoiseLite.CellularDistanceFunction.EuclideanSq:for(let c=s-1;c<=s+1;c++){let s=_;for(let _=a-1;_<=a+1;_++){let a=this._HashR2(e,n,s),p=510&a,d=c-t+this._RandVecs2D[p]*h,m=_-i+this._RandVecs2D[1|p]*h,u=d*d+m*m;o=Math.max(Math.min(o,u),r),u{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,32.69428253173828*t,i,s,!1,a,r,o);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,7.71604938271605*t,i,s,!0,a,r,o);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r,o)}};return 6===arguments.length&&arguments[3]instanceof Vector2?((e,t,i,s,a,r)=>{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,38.283687591552734*t,i,s,!1,a,r);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,16*t,i,s,!0,a,r);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r)}})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]):7===arguments.length&&arguments[3]instanceof Vector3?e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]):void 0}_DomainWarpSingle(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y,o=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=a+r,t=-.211324865405187*e;o*=.577350269189626,a+=t-o,r=r+t-o,o+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=a+o,t=-.211324865405187*e;r*=.577350269189626,a+=t-r,o+=t-r,r+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let e=(a+r+o)*(2/3);a=e-a,r=e-r,o=e-o}this._DoSingleDomainWarp(t,i,s,e,a,r,o)};return 1===arguments.length&&arguments[0]instanceof Vector2?(e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(a+r)*(.5*(1.7320508075688772-1));a+=e,r+=e}this._DoSingleDomainWarp(t,i,s,e,a,r)})(arguments[0]):1===arguments.length&&arguments[0]instanceof Vector3?e(arguments[0]):void 0}_DomainWarpFractalProgressive(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=e.x,i=e.y,s=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=t+i,a=-.211324865405187*e;s*=.577350269189626,t+=a-s,i=i+a-s,s+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=t+s,a=-.211324865405187*e;i*=.577350269189626,t+=a-i,s+=a-i,i+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:{let e=(t+i+s)*(2/3);t=e-t,i=e-i,s=e-s}}let a=this._Seed,r=this._DomainWarpAmp*this._FractalBounding,o=this._Frequency;for(let l=0;l{let t=e.x,i=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(t+i)*(.5*(1.7320508075688772-1));t+=e,i+=e}let s=this._Seed,a=this._DomainWarpAmp*this._FractalBounding,r=this._Frequency;for(let o=0;o{let l=a*i,h=r*i,n=o*i,_=Math.floor(l),c=Math.floor(h),p=Math.floor(n),d=FastNoiseLite._InterpHermite(l-_),m=FastNoiseLite._InterpHermite(h-c),u=FastNoiseLite._InterpHermite(n-p);_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),p=Math.imul(p,this._PrimeZ);let R=_+this._PrimeX,L=c+this._PrimeY,F=p+this._PrimeZ,D=1020&this._HashR3(e,_,c,p),C=1020&this._HashR3(e,R,c,p),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d);D=1020&this._HashR3(e,_,L,p),C=1020&this._HashR3(e,R,L,p);let y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),S=FastNoiseLite._Lerp(N,y,m),g=FastNoiseLite._Lerp(P,T,m),M=FastNoiseLite._Lerp(V,f,m);D=1020&this._HashR3(e,_,c,F),C=1020&this._HashR3(e,R,c,F),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),D=1020&this._HashR3(e,_,L,F),C=1020&this._HashR3(e,R,L,F),y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),s.x+=FastNoiseLite._Lerp(S,FastNoiseLite._Lerp(N,y,m),u)*t,s.y+=FastNoiseLite._Lerp(g,FastNoiseLite._Lerp(P,T,m),u)*t,s.z+=FastNoiseLite._Lerp(M,FastNoiseLite._Lerp(V,f,m),u)*t};6===arguments.length&&arguments[3]instanceof Vector2&&((e,t,i,s,a,r)=>{let o=a*i,l=r*i,h=Math.floor(o),n=Math.floor(l),_=FastNoiseLite._InterpHermite(o-h),c=FastNoiseLite._InterpHermite(l-n);h=Math.imul(h,this._PrimeX),n=Math.imul(n,this._PrimeY);let p=h+this._PrimeX,d=n+this._PrimeY,m=510&this._HashR2(e,h,n),u=510&this._HashR2(e,p,n),R=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),L=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);m=510&this._HashR2(e,h,d),u=510&this._HashR2(e,p,d);let F=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),D=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);s.x+=FastNoiseLite._Lerp(R,F,c)*t,s.y+=FastNoiseLite._Lerp(L,D,c)*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]),7===arguments.length&&arguments[3]instanceof Vector3&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6])}_SingleDomainWarpOpenSimplex2Gradient(){let e=(e,t,i,s,a,r,o,l)=>{r*=i,o*=i,l*=i;let h,n,_,c=Math.round(r),p=Math.round(o),d=Math.round(l),m=r-c,u=o-p,R=l-d,L=-m-1|1,F=-u-1|1,D=-R-1|1,C=L*-m,N=F*-u,P=D*-R;c=Math.imul(c,this._PrimeX),p=Math.imul(p,this._PrimeY),d=Math.imul(d,this._PrimeZ),h=n=_=0;let V=.6-m*m-(u*u+R*R);for(let t=0;;t++){if(V>0){let t,i,s,r=V*V*(V*V);if(a){let a=1020&this._HashR3(e,c,p,d);t=this._RandVecs3D[a],i=this._RandVecs3D[1|a],s=this._RandVecs3D[2|a]}else{let a=this._HashR3(e,c,p,d),r=252&a,o=a>>6&1020,l=m*this._Gradients3D[r]+u*this._Gradients3D[1|r]+R*this._Gradients3D[2|r];t=l*this._RandVecs3D[o],i=l*this._RandVecs3D[1|o],s=l*this._RandVecs3D[2|o]}h+=r*t,n+=r*i,_+=r*s}let i=V,s=c,r=p,o=d,l=m,y=u,T=R;if(C>=N&&C>=P?(l+=L,i=i+C+C,s-=L*this._PrimeX):N>C&&N>=P?(y+=F,i=i+N+N,r-=F*this._PrimeY):(T+=D,i=i+P+P,o-=D*this._PrimeZ),i>1){i-=1;let t,c,p,d=i*i*(i*i);if(a){let i=1020&this._HashR3(e,s,r,o);t=this._RandVecs3D[i],c=this._RandVecs3D[1|i],p=this._RandVecs3D[2|i]}else{let i=this._HashR3(e,s,r,o),a=252&i,h=i>>6&1020,n=l*this._Gradients3D[a]+y*this._Gradients3D[1|a]+T*this._Gradients3D[2|a];t=n*this._RandVecs3D[h],c=n*this._RandVecs3D[1|h],p=n*this._RandVecs3D[2|h]}h+=d*t,n+=d*c,_+=d*p}if(1===t)break;C=.5-C,N=.5-N,P=.5-P,m=L*C,u=F*N,R=D*P,V+=.75-C-(N+P),c+=L>>1&this._PrimeX,p+=F>>1&this._PrimeY,d+=D>>1&this._PrimeZ,L=-L,F=-F,D=-D,e+=1293373}s.x+=h*t,s.y+=n*t,s.z+=_*t};7===arguments.length&&((e,t,i,s,a,r,o)=>{const l=.21132486540518713;r*=i,o*=i;let h,n,_=Math.floor(r),c=Math.floor(o),p=r-_,d=o-c,m=(p+d)*l,u=p-m,R=d-m;_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),h=n=0;let L=.5-u*u-R*R;if(L>0){let t,i,s=L*L*(L*L);if(a){let s=510&this._HashR2(e,_,c);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let s=this._HashR2(e,_,c),a=254&s,r=s>>7&510,o=u*this._Gradients2D[a]+R*this._Gradients2D[1|a];t=o*this._RandVecs2D[r],i=o*this._RandVecs2D[1|r]}h+=s*t,n+=s*i}let F=3.1547005383792506*m+(-.6666666666666666+L);if(F>0){let t,i,s=u+(2*l-1),r=R+(2*l-1),o=F*F*(F*F);if(a){let s=510&this._HashR2(e,_+this._PrimeX,c+this._PrimeY);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let a=this._HashR2(e,_+this._PrimeX,c+this._PrimeY),o=254&a,l=a>>7&510,h=s*this._Gradients2D[o]+r*this._Gradients2D[1|o];t=h*this._RandVecs2D[l],i=h*this._RandVecs2D[1|l]}h+=o*t,n+=o*i}if(R>u){let t=u+l,i=R+(l-1),s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_,c+this._PrimeY);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_,c+this._PrimeY),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}else{let t=u+(l-1),i=R+l,s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_+this._PrimeX,c);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_+this._PrimeX,c),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}s.x+=h*t,s.y+=n*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]),8===arguments.length&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7])}}class Vector2{constructor(e,t){this.x=e,this.y=t}}class Vector3{constructor(e,t,i){this.x=e,this.y=t,this.z=i}} \ No newline at end of file From 69b8a4914059e2617efa50a68d267fa53915e4c3 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 19:53:48 -0700 Subject: [PATCH 27/36] correct minified --- extensions/Corbnorb/noise.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index ef446667a1..9109f64b49 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -16,6 +16,12 @@ const Translate = Scratch.translate; class Noise { + constructor() { + this.noiseSeed = 0; + this.worleySeed = 0; + this.time = performance.now(); + } + getInfo() { return { id: "corbnorbsnoise", @@ -183,7 +189,7 @@ const inverted = Cast.toBoolean(args.INVERTED); if (id in noises) { let value = noises[id].GetNoise(args.X, args.Y, args.Z); - value = inverted == true ? -value : value; + value = (inverted == true) ? -value : value; value = (value + 1) / 2; switch (easing) { case "linear": @@ -232,7 +238,10 @@ // SOFTWARE. // - // minified, find original here: + //minified code. find original here: // https://raw.githubusercontent.com/Auburn/FastNoiseLite/refs/heads/master/JavaScript/FastNoiseLite.js -class FastNoiseLite{static NoiseType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2S:"OpenSimplex2S",Cellular:"Cellular",Perlin:"Perlin",ValueCubic:"ValueCubic",Value:"Value"});static RotationType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes"});static FractalType=Object.freeze({None:"None",FBm:"FBm",Ridged:"Ridged",PingPong:"PingPong",DomainWarpProgressive:"DomainWarpProgressive",DomainWarpIndependent:"DomainWarpIndependent"});static CellularDistanceFunction=Object.freeze({Euclidean:"Euclidean",EuclideanSq:"EuclideanSq",Manhattan:"Manhattan",Hybrid:"Hybrid"});static CellularReturnType=Object.freeze({CellValue:"CellValue",Distance:"Distance",Distance2:"Distance2",Distance2Add:"Distance2Add",Distance2Sub:"Distance2Sub",Distance2Mul:"Distance2Mul",Distance2Div:"Distance2Div"});static DomainWarpType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2Reduced:"OpenSimplex2Reduced",BasicGrid:"BasicGrid"});static TransformType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes",DefaultOpenSimplex2:"DefaultOpenSimplex2"});_Seed=1337;_Frequency=.01;_NoiseType=FastNoiseLite.NoiseType.OpenSimplex2;_RotationType3D=FastNoiseLite.RotationType3D.None;_TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;_DomainWarpAmp=1;_FractalType=FastNoiseLite.FractalType.None;_Octaves=3;_Lacunarity=2;_Gain=.5;_WeightedStrength=0;_PingPongStrength=2;_FractalBounding=1/1.75;_CellularDistanceFunction=FastNoiseLite.CellularDistanceFunction.EuclideanSq;_CellularReturnType=FastNoiseLite.CellularReturnType.Distance;_CellularJitterModifier=1;_DomainWarpType=FastNoiseLite.DomainWarpType.OpenSimplex2;_WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;constructor(e){void 0!==e&&(this._Seed=e)}SetSeed(e){this._Seed=e}SetFrequency(e){this._Frequency=e}SetNoiseType(e){this._NoiseType=e,this._UpdateTransformType3D()}SetRotationType3D(e){this._RotationType3D=e,this._UpdateTransformType3D(),this._UpdateWarpTransformType3D()}SetFractalType(e){this._FractalType=e}SetFractalOctaves(e){this._Octaves=e,this._CalculateFractalBounding()}SetFractalLacunarity(e){this._Lacunarity=e}SetFractalGain(e){this._Gain=e,this._CalculateFractalBounding()}SetFractalWeightedStrength(e){this._WeightedStrength=e}SetFractalPingPongStrength(e){this._PingPongStrength=e}SetCellularDistanceFunction(e){this._CellularDistanceFunction=e}SetCellularReturnType(e){this._CellularReturnType=e}SetCellularJitter(e){this._CellularJitterModifier=e}SetDomainWarpType(e){this._DomainWarpType=e,this._UpdateWarpTransformType3D()}SetDomainWarpAmp(e){this._DomainWarpAmp=e}GetNoise(e,t,i){let s=(e,t)=>{switch(e*=this._Frequency,t*=this._Frequency,this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:let i=(e+t)*(.5*(1.7320508075688772-1));e+=i,t+=i}switch(this._FractalType){default:return this._GenNoiseSingleR2(this._Seed,e,t);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR2(e,t);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR2(e,t);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR2(e,t)}},a=(e,t,i)=>{switch(e*=this._Frequency,t*=this._Frequency,i*=this._Frequency,this._TransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let s=e+t,a=-.211324865405187*s;e+=a-(i*=.577350269189626),t+=a-i,i+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let s=e+i,a=-.211324865405187*s;e+=a-(t*=.577350269189626),i+=a-t,t+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let s=(e+t+i)*(2/3);e=s-e,t=s-t,i=s-i}switch(this._FractalType){default:return this._GenNoiseSingleR3(this._Seed,e,t,i);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR3(e,t,i);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR3(e,t,i);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR3(e,t,i)}};return 2===arguments.length?s(e,t):3===arguments.length?a(e,t,i):void 0}DomainWrap(e){switch(this._FractalType){default:this._DomainWarpSingle(e);break;case FastNoiseLite.FractalType.DomainWarpProgressive:this._DomainWarpFractalProgressive(e);break;case FastNoiseLite.FractalType.DomainWarpIndependent:this._DomainWarpFractalIndependent(e)}}_Gradients2D=[.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.38268343236509,.923879532511287,.923879532511287,.38268343236509,.923879532511287,-.38268343236509,.38268343236509,-.923879532511287,-.38268343236509,-.923879532511287,-.923879532511287,-.38268343236509,-.923879532511287,.38268343236509,-.38268343236509,.923879532511287];_RandVecs2D=[-.2700222198,-.9628540911,.3863092627,-.9223693152,.04444859006,-.999011673,-.5992523158,-.8005602176,-.7819280288,.6233687174,.9464672271,.3227999196,-.6514146797,-.7587218957,.9378472289,.347048376,-.8497875957,-.5271252623,-.879042592,.4767432447,-.892300288,-.4514423508,-.379844434,-.9250503802,-.9951650832,.0982163789,.7724397808,-.6350880136,.7573283322,-.6530343002,-.9928004525,-.119780055,-.0532665713,.9985803285,.9754253726,-.2203300762,-.7665018163,.6422421394,.991636706,.1290606184,-.994696838,.1028503788,-.5379205513,-.84299554,.5022815471,-.8647041387,.4559821461,-.8899889226,-.8659131224,-.5001944266,.0879458407,-.9961252577,-.5051684983,.8630207346,.7753185226,-.6315704146,-.6921944612,.7217110418,-.5191659449,-.8546734591,.8978622882,-.4402764035,-.1706774107,.9853269617,-.9353430106,-.3537420705,-.9992404798,.03896746794,-.2882064021,-.9575683108,-.9663811329,.2571137995,-.8759714238,-.4823630009,-.8303123018,-.5572983775,.05110133755,-.9986934731,-.8558373281,-.5172450752,.09887025282,.9951003332,.9189016087,.3944867976,-.2439375892,-.9697909324,-.8121409387,-.5834613061,-.9910431363,.1335421355,.8492423985,-.5280031709,-.9717838994,-.2358729591,.9949457207,.1004142068,.6241065508,-.7813392434,.662910307,.7486988212,-.7197418176,.6942418282,-.8143370775,-.5803922158,.104521054,-.9945226741,-.1065926113,-.9943027784,.445799684,-.8951327509,.105547406,.9944142724,-.992790267,.1198644477,-.8334366408,.552615025,.9115561563,-.4111755999,.8285544909,-.5599084351,.7217097654,-.6921957921,.4940492677,-.8694339084,-.3652321272,-.9309164803,-.9696606758,.2444548501,.08925509731,-.996008799,.5354071276,-.8445941083,-.1053576186,.9944343981,-.9890284586,.1477251101,.004856104961,.9999882091,.9885598478,.1508291331,.9286129562,-.3710498316,-.5832393863,-.8123003252,.3015207509,.9534596146,-.9575110528,.2883965738,.9715802154,-.2367105511,.229981792,.9731949318,.955763816,-.2941352207,.740956116,.6715534485,-.9971513787,-.07542630764,.6905710663,-.7232645452,-.290713703,-.9568100872,.5912777791,-.8064679708,-.9454592212,-.325740481,.6664455681,.74555369,.6236134912,.7817328275,.9126993851,-.4086316587,-.8191762011,.5735419353,-.8812745759,-.4726046147,.9953313627,.09651672651,.9855650846,-.1692969699,-.8495980887,.5274306472,.6174853946,-.7865823463,.8508156371,.52546432,.9985032451,-.05469249926,.1971371563,-.9803759185,.6607855748,-.7505747292,-.03097494063,.9995201614,-.6731660801,.739491331,-.7195018362,-.6944905383,.9727511689,.2318515979,.9997059088,-.0242506907,.4421787429,-.8969269532,.9981350961,-.061043673,-.9173660799,-.3980445648,-.8150056635,-.5794529907,-.8789331304,.4769450202,.0158605829,.999874213,-.8095464474,.5870558317,-.9165898907,-.3998286786,-.8023542565,.5968480938,-.5176737917,.8555780767,-.8154407307,-.5788405779,.4022010347,-.9155513791,-.9052556868,-.4248672045,.7317445619,.6815789728,-.5647632201,-.8252529947,-.8403276335,-.5420788397,-.9314281527,.363925262,.5238198472,.8518290719,.7432803869,-.6689800195,-.985371561,-.1704197369,.4601468731,.88784281,.825855404,.5638819483,.6182366099,.7859920446,.8331502863,-.553046653,.1500307506,.9886813308,-.662330369,-.7492119075,-.668598664,.743623444,.7025606278,.7116238924,-.5419389763,-.8404178401,-.3388616456,.9408362159,.8331530315,.5530425174,-.2989720662,-.9542618632,.2638522993,.9645630949,.124108739,-.9922686234,-.7282649308,-.6852956957,.6962500149,.7177993569,-.9183535368,.3957610156,-.6326102274,-.7744703352,-.9331891859,-.359385508,-.1153779357,-.9933216659,.9514974788,-.3076565421,-.08987977445,-.9959526224,.6678496916,.7442961705,.7952400393,-.6062947138,-.6462007402,-.7631674805,-.2733598753,.9619118351,.9669590226,-.254931851,-.9792894595,.2024651934,-.5369502995,-.8436138784,-.270036471,-.9628500944,-.6400277131,.7683518247,-.7854537493,-.6189203566,.06005905383,-.9981948257,-.02455770378,.9996984141,-.65983623,.751409442,-.6253894466,-.7803127835,-.6210408851,-.7837781695,.8348888491,.5504185768,-.1592275245,.9872419133,.8367622488,.5475663786,-.8675753916,-.4973056806,-.2022662628,-.9793305667,.9399189937,.3413975472,.9877404807,-.1561049093,-.9034455656,.4287028224,.1269804218,-.9919052235,-.3819600854,.924178821,.9754625894,.2201652486,-.3204015856,-.9472818081,-.9874760884,.1577687387,.02535348474,-.9996785487,.4835130794,-.8753371362,-.2850799925,-.9585037287,-.06805516006,-.99768156,-.7885244045,-.6150034663,.3185392127,-.9479096845,.8880043089,.4598351306,.6476921488,-.7619021462,.9820241299,.1887554194,.9357275128,-.3527237187,-.8894895414,.4569555293,.7922791302,.6101588153,.7483818261,.6632681526,-.7288929755,-.6846276581,.8729032783,-.4878932944,.8288345784,.5594937369,.08074567077,.9967347374,.9799148216,-.1994165048,-.580730673,-.8140957471,-.4700049791,-.8826637636,.2409492979,.9705377045,.9437816757,-.3305694308,-.8927998638,-.4504535528,-.8069622304,.5906030467,.06258973166,.9980393407,-.9312597469,.3643559849,.5777449785,.8162173362,-.3360095855,-.941858566,.697932075,-.7161639607,-.002008157227,-.9999979837,-.1827294312,-.9831632392,-.6523911722,.7578824173,-.4302626911,-.9027037258,-.9985126289,-.05452091251,-.01028102172,-.9999471489,-.4946071129,.8691166802,-.2999350194,.9539596344,.8165471961,.5772786819,.2697460475,.962931498,-.7306287391,-.6827749597,-.7590952064,-.6509796216,-.907053853,.4210146171,-.5104861064,-.8598860013,.8613350597,.5080373165,.5007881595,-.8655698812,-.654158152,.7563577938,-.8382755311,-.545246856,.6940070834,.7199681717,.06950936031,.9975812994,.1702942185,-.9853932612,.2695973274,.9629731466,.5519612192,-.8338697815,.225657487,-.9742067022,.4215262855,-.9068161835,.4881873305,-.8727388672,-.3683854996,-.9296731273,-.9825390578,.1860564427,.81256471,.5828709909,.3196460933,-.9475370046,.9570913859,.2897862643,-.6876655497,-.7260276109,-.9988770922,-.047376731,-.1250179027,.992154486,-.8280133617,.560708367,.9324863769,-.3612051451,.6394653183,.7688199442,-.01623847064,-.9998681473,-.9955014666,-.09474613458,-.81453315,.580117012,.4037327978,-.9148769469,.9944263371,.1054336766,-.1624711654,.9867132919,-.9949487814,-.100383875,-.6995302564,.7146029809,.5263414922,-.85027327,-.5395221479,.841971408,.6579370318,.7530729462,.01426758847,-.9998982128,-.6734383991,.7392433447,.639412098,-.7688642071,.9211571421,.3891908523,-.146637214,-.9891903394,-.782318098,.6228791163,-.5039610839,-.8637263605,-.7743120191,-.6328039957];_Gradients3D=[0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,1,1,0,0,0,-1,1,0,-1,1,0,0,0,-1,-1,0];_RandVecs3D=[-.7292736885,-.6618439697,.1735581948,0,.790292081,-.5480887466,-.2739291014,0,.7217578935,.6226212466,-.3023380997,0,.565683137,-.8208298145,-.0790000257,0,.760049034,-.5555979497,-.3370999617,0,.3713945616,.5011264475,.7816254623,0,-.1277062463,-.4254438999,-.8959289049,0,-.2881560924,-.5815838982,.7607405838,0,.5849561111,-.662820239,-.4674352136,0,.3307171178,.0391653737,.94291689,0,.8712121778,-.4113374369,-.2679381538,0,.580981015,.7021915846,.4115677815,0,.503756873,.6330056931,-.5878203852,0,.4493712205,.601390195,.6606022552,0,-.6878403724,.09018890807,-.7202371714,0,-.5958956522,-.6469350577,.475797649,0,-.5127052122,.1946921978,-.8361987284,0,-.9911507142,-.05410276466,-.1212153153,0,-.2149721042,.9720882117,-.09397607749,0,-.7518650936,-.5428057603,.3742469607,0,.5237068895,.8516377189,-.02107817834,0,.6333504779,.1926167129,-.7495104896,0,-.06788241606,.3998305789,.9140719259,0,-.5538628599,-.4729896695,-.6852128902,0,-.7261455366,-.5911990757,.3509933228,0,-.9229274737,-.1782808786,.3412049336,0,-.6968815002,.6511274338,.3006480328,0,.9608044783,-.2098363234,-.1811724921,0,.06817146062,-.9743405129,.2145069156,0,-.3577285196,-.6697087264,-.6507845481,0,-.1868621131,.7648617052,-.6164974636,0,-.6541697588,.3967914832,.6439087246,0,.6993340405,-.6164538506,.3618239211,0,-.1546665739,.6291283928,.7617583057,0,-.6841612949,-.2580482182,-.6821542638,0,.5383980957,.4258654885,.7271630328,0,-.5026987823,-.7939832935,-.3418836993,0,.3202971715,.2834415347,.9039195862,0,.8683227101,-.0003762656404,-.4959995258,0,.791120031,-.08511045745,.6057105799,0,-.04011016052,-.4397248749,.8972364289,0,.9145119872,.3579346169,-.1885487608,0,-.9612039066,-.2756484276,.01024666929,0,.6510361721,-.2877799159,-.7023778346,0,-.2041786351,.7365237271,.644859585,0,-.7718263711,.3790626912,.5104855816,0,-.3060082741,-.7692987727,.5608371729,0,.454007341,-.5024843065,.7357899537,0,.4816795475,.6021208291,-.6367380315,0,.6961980369,-.3222197429,.641469197,0,-.6532160499,-.6781148932,.3368515753,0,.5089301236,-.6154662304,-.6018234363,0,-.1635919754,-.9133604627,-.372840892,0,.52408019,-.8437664109,.1157505864,0,.5902587356,.4983817807,-.6349883666,0,.5863227872,.494764745,.6414307729,0,.6779335087,.2341345225,.6968408593,0,.7177054546,-.6858979348,.120178631,0,-.5328819713,-.5205125012,.6671608058,0,-.8654874251,-.0700727088,-.4960053754,0,-.2861810166,.7952089234,.5345495242,0,-.04849529634,.9810836427,-.1874115585,0,-.6358521667,.6058348682,.4781800233,0,.6254794696,-.2861619734,.7258696564,0,-.2585259868,.5061949264,-.8227581726,0,.02136306781,.5064016808,-.8620330371,0,.200111773,.8599263484,.4695550591,0,.4743561372,.6014985084,-.6427953014,0,.6622993731,-.5202474575,-.5391679918,0,.08084972818,-.6532720452,.7527940996,0,-.6893687501,.0592860349,.7219805347,0,-.1121887082,-.9673185067,.2273952515,0,.7344116094,.5979668656,-.3210532909,0,.5789393465,-.2488849713,.7764570201,0,.6988182827,.3557169806,-.6205791146,0,-.8636845529,-.2748771249,-.4224826141,0,-.4247027957,-.4640880967,.777335046,0,.5257722489,-.8427017621,.1158329937,0,.9343830603,.316302472,-.1639543925,0,-.1016836419,-.8057303073,-.5834887393,0,-.6529238969,.50602126,-.5635892736,0,-.2465286165,-.9668205684,-.06694497494,0,-.9776897119,-.2099250524,-.007368825344,0,.7736893337,.5734244712,.2694238123,0,-.6095087895,.4995678998,.6155736747,0,.5794535482,.7434546771,.3339292269,0,-.8226211154,.08142581855,.5627293636,0,-.510385483,.4703667658,.7199039967,0,-.5764971849,-.07231656274,-.8138926898,0,.7250628871,.3949971505,-.5641463116,0,-.1525424005,.4860840828,-.8604958341,0,-.5550976208,-.4957820792,.667882296,0,-.1883614327,.9145869398,.357841725,0,.7625556724,-.5414408243,-.3540489801,0,-.5870231946,-.3226498013,-.7424963803,0,.3051124198,.2262544068,-.9250488391,0,.6379576059,.577242424,-.5097070502,0,-.5966775796,.1454852398,-.7891830656,0,-.658330573,.6555487542,-.3699414651,0,.7434892426,.2351084581,.6260573129,0,.5562114096,.8264360377,-.0873632843,0,-.3028940016,-.8251527185,.4768419182,0,.1129343818,-.985888439,-.1235710781,0,.5937652891,-.5896813806,.5474656618,0,.6757964092,-.5835758614,-.4502648413,0,.7242302609,-.1152719764,.6798550586,0,-.9511914166,.0753623979,-.2992580792,0,.2539470961,-.1886339355,.9486454084,0,.571433621,-.1679450851,-.8032795685,0,-.06778234979,.3978269256,.9149531629,0,.6074972649,.733060024,-.3058922593,0,-.5435478392,.1675822484,.8224791405,0,-.5876678086,-.3380045064,-.7351186982,0,-.7967562402,.04097822706,-.6029098428,0,-.1996350917,.8706294745,.4496111079,0,-.02787660336,-.9106232682,-.4122962022,0,-.7797625996,-.6257634692,.01975775581,0,-.5211232846,.7401644346,-.4249554471,0,.8575424857,.4053272873,-.3167501783,0,.1045223322,.8390195772,-.5339674439,0,.3501822831,.9242524096,-.1520850155,0,.1987849858,.07647613266,.9770547224,0,.7845996363,.6066256811,-.1280964233,0,.09006737436,-.9750989929,-.2026569073,0,-.8274343547,-.542299559,.1458203587,0,-.3485797732,-.415802277,.840000362,0,-.2471778936,-.7304819962,-.6366310879,0,-.3700154943,.8577948156,.3567584454,0,.5913394901,-.548311967,-.5913303597,0,.1204873514,-.7626472379,-.6354935001,0,.616959265,.03079647928,.7863922953,0,.1258156836,-.6640829889,-.7369967419,0,-.6477565124,-.1740147258,-.7417077429,0,.6217889313,-.7804430448,-.06547655076,0,.6589943422,-.6096987708,.4404473475,0,-.2689837504,-.6732403169,-.6887635427,0,-.3849775103,.5676542638,.7277093879,0,.5754444408,.8110471154,-.1051963504,0,.9141593684,.3832947817,.131900567,0,-.107925319,.9245493968,.3654593525,0,.377977089,.3043148782,.8743716458,0,-.2142885215,-.8259286236,.5214617324,0,.5802544474,.4148098596,-.7008834116,0,-.1982660881,.8567161266,-.4761596756,0,-.03381553704,.3773180787,-.9254661404,0,-.6867922841,-.6656597827,.2919133642,0,.7731742607,-.2875793547,-.5652430251,0,-.09655941928,.9193708367,-.3813575004,0,.2715702457,-.9577909544,-.09426605581,0,.2451015704,-.6917998565,-.6792188003,0,.977700782,-.1753855374,.1155036542,0,-.5224739938,.8521606816,.02903615945,0,-.7734880599,-.5261292347,.3534179531,0,-.7134492443,-.269547243,.6467878011,0,.1644037271,.5105846203,-.8439637196,0,.6494635788,.05585611296,.7583384168,0,-.4711970882,.5017280509,-.7254255765,0,-.6335764307,-.2381686273,-.7361091029,0,-.9021533097,-.270947803,-.3357181763,0,-.3793711033,.872258117,.3086152025,0,-.6855598966,-.3250143309,.6514394162,0,.2900942212,-.7799057743,-.5546100667,0,-.2098319339,.85037073,.4825351604,0,-.4592603758,.6598504336,-.5947077538,0,.8715945488,.09616365406,-.4807031248,0,-.6776666319,.7118504878,-.1844907016,0,.7044377633,.312427597,.637304036,0,-.7052318886,-.2401093292,-.6670798253,0,.081921007,-.7207336136,-.6883545647,0,-.6993680906,-.5875763221,-.4069869034,0,-.1281454481,.6419895885,.7559286424,0,-.6337388239,-.6785471501,-.3714146849,0,.5565051903,-.2168887573,-.8020356851,0,-.5791554484,.7244372011,-.3738578718,0,.1175779076,-.7096451073,.6946792478,0,-.6134619607,.1323631078,.7785527795,0,.6984635305,-.02980516237,-.715024719,0,.8318082963,-.3930171956,.3919597455,0,.1469576422,.05541651717,-.9875892167,0,.708868575,-.2690503865,.6520101478,0,.2726053183,.67369766,-.68688995,0,-.6591295371,.3035458599,-.6880466294,0,.4815131379,-.7528270071,.4487723203,0,.9430009463,.1675647412,-.2875261255,0,.434802957,.7695304522,-.4677277752,0,.3931996188,.594473625,.7014236729,0,.7254336655,-.603925654,.3301814672,0,.7590235227,-.6506083235,.02433313207,0,-.8552768592,-.3430042733,.3883935666,0,-.6139746835,.6981725247,.3682257648,0,-.7465905486,-.5752009504,.3342849376,0,.5730065677,.810555537,-.1210916791,0,-.9225877367,-.3475211012,-.167514036,0,-.7105816789,-.4719692027,-.5218416899,0,-.08564609717,.3583001386,.929669703,0,-.8279697606,-.2043157126,.5222271202,0,.427944023,.278165994,.8599346446,0,.5399079671,-.7857120652,-.3019204161,0,.5678404253,-.5495413974,-.6128307303,0,-.9896071041,.1365639107,-.04503418428,0,-.6154342638,-.6440875597,.4543037336,0,.1074204368,-.7946340692,.5975094525,0,-.3595449969,-.8885529948,.28495784,0,-.2180405296,.1529888965,.9638738118,0,-.7277432317,-.6164050508,-.3007234646,0,.7249729114,-.00669719484,.6887448187,0,-.5553659455,-.5336586252,.6377908264,0,.5137558015,.7976208196,-.3160000073,0,-.3794024848,.9245608561,-.03522751494,0,.8229248658,.2745365933,-.4974176556,0,-.5404114394,.6091141441,.5804613989,0,.8036581901,-.2703029469,.5301601931,0,.6044318879,.6832968393,.4095943388,0,.06389988817,.9658208605,-.2512108074,0,.1087113286,.7402471173,-.6634877936,0,-.713427712,-.6926784018,.1059128479,0,.6458897819,-.5724548511,-.5050958653,0,-.6553931414,.7381471625,.159995615,0,.3910961323,.9188871375,-.05186755998,0,-.4879022471,-.5904376907,.6429111375,0,.6014790094,.7707441366,-.2101820095,0,-.5677173047,.7511360995,.3368851762,0,.7858573506,.226674665,.5753666838,0,-.4520345543,-.604222686,-.6561857263,0,.002272116345,.4132844051,-.9105991643,0,-.5815751419,-.5162925989,.6286591339,0,-.03703704785,.8273785755,.5604221175,0,-.5119692504,.7953543429,-.3244980058,0,-.2682417366,-.9572290247,-.1084387619,0,-.2322482736,-.9679131102,-.09594243324,0,.3554328906,-.8881505545,.2913006227,0,.7346520519,-.4371373164,.5188422971,0,.9985120116,.04659011161,-.02833944577,0,-.3727687496,-.9082481361,.1900757285,0,.91737377,-.3483642108,.1925298489,0,.2714911074,.4147529736,-.8684886582,0,.5131763485,-.7116334161,.4798207128,0,-.8737353606,.18886992,-.4482350644,0,.8460043821,-.3725217914,.3814499973,0,.8978727456,-.1780209141,-.4026575304,0,.2178065647,-.9698322841,-.1094789531,0,-.1518031304,-.7788918132,-.6085091231,0,-.2600384876,-.4755398075,-.8403819825,0,.572313509,-.7474340931,-.3373418503,0,-.7174141009,.1699017182,-.6756111411,0,-.684180784,.02145707593,-.7289967412,0,-.2007447902,.06555605789,-.9774476623,0,-.1148803697,-.8044887315,.5827524187,0,-.7870349638,.03447489231,.6159443543,0,-.2015596421,.6859872284,.6991389226,0,-.08581082512,-.10920836,-.9903080513,0,.5532693395,.7325250401,-.396610771,0,-.1842489331,-.9777375055,-.1004076743,0,.0775473789,-.9111505856,.4047110257,0,.1399838409,.7601631212,-.6344734459,0,.4484419361,-.845289248,.2904925424,0];_PrimeX=501125321;_PrimeY=1136930381;_PrimeZ=1720413743;static _Lerp(e,t,i){return e+i*(t-e)}static _InterpHermite(e){return e*e*(3-2*e)}static _InterpQuintic(e){return e*e*e*(e*(6*e-15)+10)}static _CubicLerp(e,t,i,s,a){let r=s-i-(e-t);return a*a*a*r+a*a*(e-t-r)+a*(i-e)+t}static _PingPong(e){return(e-=2*Math.trunc(.5*e))<1?e:2-e}_CalculateFractalBounding(){let e=Math.abs(this._Gain),t=e,i=1;for(let s=1;s>15,r&=254,s*this._Gradients2D[r]+a*this._Gradients2D[1|r]}_GradCoordR3(e,t,i,s,a,r,o){let l=this._HashR3(e,t,i,s);return l^=l>>15,l&=252,a*this._Gradients3D[l]+r*this._Gradients3D[1|l]+o*this._Gradients3D[2|l]}_GenNoiseSingleR2(e,t,i){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R2(e,t,i);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR2(e,t,i);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR2(e,t,i);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR2(e,t,i);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR2(e,t,i);case FastNoiseLite.NoiseType.Value:return this._SingleValueR2(e,t,i);default:return 0}}_GenNoiseSingleR3(e,t,i,s){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R3(e,t,i,s);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR3(e,t,i,s);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR3(e,t,i,s);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR3(e,t,i,s);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR3(e,t,i,s);case FastNoiseLite.NoiseType.Value:return this._SingleValueR3(e,t,i,s);default:return 0}}_UpdateTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:this._TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._TransformType3D=FastNoiseLite.TransformType3D.None}}}_UpdateWarpTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._WarpTransformType3D=FastNoiseLite.TransformType3D.None}}}_GenFractalFBmR2(e,t){let i=this._Seed,s=0,a=this._FractalBounding;for(let r=0;rp){let t=p+s,i=d+(s-1),a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l,h+this._PrimeY,t,i)}else{let t=p+(s-1),i=d+s,a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l+this._PrimeX,h,t,i)}return 99.83685446303647*(a+r+o)}_SingleOpenSimplex2R3(e,t,i,s){let a=Math.round(t),r=Math.round(i),o=Math.round(s),l=t-a,h=i-r,n=s-o,_=Math.trunc(-1-h|1),c=Math.trunc(-1-l|1),p=Math.trunc(-1-n|1),d=c*-l,m=_*-h,u=p*-n;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let R=0,L=.6-l*l-(h*h+n*n);for(let t=0;;t++){if(L>0&&(R+=L*L*(L*L)*this._GradCoordR3(e,a,r,o,l,h,n)),d>=m&&d>=u){let t=L+d+d;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a-c*this._PrimeX,r,o,l+c,h,n))}else if(m>d&&m>=u){let t=L+m+m;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r-_*this._PrimeY,o,l,h+_,n))}else{let t=L+u+u;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r,o-p*this._PrimeZ,l,h,n+p))}if(1===t)break;d=.5-d,m=.5-m,u=.5-u,l=c*d,h=_*m,n=p*u,L+=.75-d-(m+u),a+=c>>1&this._PrimeX,r+=_>>1&this._PrimeY,o+=p>>1&this._PrimeZ,c=-c,_=-_,p=-p,e=~e}return 32.69428253173828*R}_SingleOpenSimplex2SR2(e,t,i){const s=.21132486540518713;let a=Math.floor(t),r=Math.floor(i),o=t-a,l=i-r;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY);let h=a+this._PrimeX,n=r+this._PrimeY,_=(o+l)*s,c=o-_,p=l-_,d=2/3-c*c-p*p,m=d*d*(d*d)*this._GradCoordR2(e,a,r,c,p),u=3.1547005383792506*_+(-.6666666666666666+d),R=c-(1-2*s),L=p-(1-2*s);m+=u*u*(u*u)*this._GradCoordR2(e,h,n,R,L);let F=o-l;if(_>s){if(o+F>1){let t=c+(3*s-2),i=p+(3*s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+(this._PrimeX<<1),r+this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}if(l-F>1){let t=c+(3*s-1),i=p+(3*s-2),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r+(this._PrimeY<<1),t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}}else{if(o+F<0){let t=c+(1-s),i=p-s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a-this._PrimeX,r,t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}if(l0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r-this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}}return 18.24196194486065*m}_SingleOpenSimplex2SR3(e,t,i,s){let a=Math.floor(t),r=Math.floor(i),o=Math.floor(s),l=t-a,h=i-r,n=s-o;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let _=e+1293373,c=Math.trunc(-.5-l),p=Math.trunc(-.5-h),d=Math.trunc(-.5-n),m=l+c,u=h+p,R=n+d,L=.75-m*m-u*u-R*R,F=L*L*(L*L)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),m,u,R),D=l-.5,C=h-.5,N=n-.5,P=.75-D*D-C*C-N*N;F+=P*P*(P*P)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+this._PrimeZ,D,C,N);let V=((1|c)<<1)*D,y=((1|p)<<1)*C,T=((1|d)<<1)*N,f=(-2-(c<<2))*D-1,S=(-2-(p<<2))*C-1,g=(-2-(d<<2))*N-1,M=!1,G=V+L;if(G>0){let t=m-(1|c);F+=G*G*(G*G)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),t,u,R)}else{let t=y+T+L;if(t>0){let i=m,s=u-(1|p),l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=f+P;if(i>0){let e=(1|c)+D;F+=i*i*(i*i)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+this._PrimeZ,e,C,N),M=!0}}let b=!1,X=y+L;if(X>0){let t=m,i=u-(1|p);F+=X*X*(X*X)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),t,i,R)}else{let t=V+T+L;if(t>0){let i=m-(1|c),s=u,l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=S+P;if(i>0){let e=D,t=(1|p)+C;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+this._PrimeZ,e,t,N),b=!0}}let W=!1,Y=T+L;if(Y>0){let t=m,i=u,s=R-(1|d);F+=Y*Y*(Y*Y)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),t,i,s)}else{let t=V+y+L;if(t>0){let i=m-(1|c),s=u-(1|p);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),i,s,R)}let i=g+P;if(i>0){let e=D,t=C,s=(1|d)+N;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+(d&this._PrimeZ<<1),e,t,s),W=!0}}if(!M){let e=S+g+P;if(e>0){let t=D,i=(1|p)+C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+(d&this._PrimeZ<<1),t,i,s)}}if(!b){let e=f+g+P;if(e>0){let t=(1|c)+D,i=C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+(d&this._PrimeZ<<1),t,i,s)}}if(!W){let e=f+S+P;if(e>0){let t=(1|c)+D,i=(1|p)+C;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&this._PrimeX<<1),r+(p&this._PrimeY<<1),o+this._PrimeZ,t,i,N)}}return 9.046026385208288*F}_SingleCellularR2(e,t,i){let s=Math.round(t),a=Math.round(i),r=Number.MAX_VALUE,o=Number.MAX_VALUE,l=0,h=.43701595*this._CellularJitterModifier,n=(s-1)*this._PrimeX,_=(a-1)*this._PrimeY;switch(this._CellularDistanceFunction){default:case FastNoiseLite.CellularDistanceFunction.Euclidean:case FastNoiseLite.CellularDistanceFunction.EuclideanSq:for(let c=s-1;c<=s+1;c++){let s=_;for(let _=a-1;_<=a+1;_++){let a=this._HashR2(e,n,s),p=510&a,d=c-t+this._RandVecs2D[p]*h,m=_-i+this._RandVecs2D[1|p]*h,u=d*d+m*m;o=Math.max(Math.min(o,u),r),u{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,32.69428253173828*t,i,s,!1,a,r,o);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,7.71604938271605*t,i,s,!0,a,r,o);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r,o)}};return 6===arguments.length&&arguments[3]instanceof Vector2?((e,t,i,s,a,r)=>{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,38.283687591552734*t,i,s,!1,a,r);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,16*t,i,s,!0,a,r);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r)}})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]):7===arguments.length&&arguments[3]instanceof Vector3?e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]):void 0}_DomainWarpSingle(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y,o=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=a+r,t=-.211324865405187*e;o*=.577350269189626,a+=t-o,r=r+t-o,o+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=a+o,t=-.211324865405187*e;r*=.577350269189626,a+=t-r,o+=t-r,r+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let e=(a+r+o)*(2/3);a=e-a,r=e-r,o=e-o}this._DoSingleDomainWarp(t,i,s,e,a,r,o)};return 1===arguments.length&&arguments[0]instanceof Vector2?(e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(a+r)*(.5*(1.7320508075688772-1));a+=e,r+=e}this._DoSingleDomainWarp(t,i,s,e,a,r)})(arguments[0]):1===arguments.length&&arguments[0]instanceof Vector3?e(arguments[0]):void 0}_DomainWarpFractalProgressive(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=e.x,i=e.y,s=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=t+i,a=-.211324865405187*e;s*=.577350269189626,t+=a-s,i=i+a-s,s+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=t+s,a=-.211324865405187*e;i*=.577350269189626,t+=a-i,s+=a-i,i+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:{let e=(t+i+s)*(2/3);t=e-t,i=e-i,s=e-s}}let a=this._Seed,r=this._DomainWarpAmp*this._FractalBounding,o=this._Frequency;for(let l=0;l{let t=e.x,i=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(t+i)*(.5*(1.7320508075688772-1));t+=e,i+=e}let s=this._Seed,a=this._DomainWarpAmp*this._FractalBounding,r=this._Frequency;for(let o=0;o{let l=a*i,h=r*i,n=o*i,_=Math.floor(l),c=Math.floor(h),p=Math.floor(n),d=FastNoiseLite._InterpHermite(l-_),m=FastNoiseLite._InterpHermite(h-c),u=FastNoiseLite._InterpHermite(n-p);_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),p=Math.imul(p,this._PrimeZ);let R=_+this._PrimeX,L=c+this._PrimeY,F=p+this._PrimeZ,D=1020&this._HashR3(e,_,c,p),C=1020&this._HashR3(e,R,c,p),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d);D=1020&this._HashR3(e,_,L,p),C=1020&this._HashR3(e,R,L,p);let y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),S=FastNoiseLite._Lerp(N,y,m),g=FastNoiseLite._Lerp(P,T,m),M=FastNoiseLite._Lerp(V,f,m);D=1020&this._HashR3(e,_,c,F),C=1020&this._HashR3(e,R,c,F),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),D=1020&this._HashR3(e,_,L,F),C=1020&this._HashR3(e,R,L,F),y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),s.x+=FastNoiseLite._Lerp(S,FastNoiseLite._Lerp(N,y,m),u)*t,s.y+=FastNoiseLite._Lerp(g,FastNoiseLite._Lerp(P,T,m),u)*t,s.z+=FastNoiseLite._Lerp(M,FastNoiseLite._Lerp(V,f,m),u)*t};6===arguments.length&&arguments[3]instanceof Vector2&&((e,t,i,s,a,r)=>{let o=a*i,l=r*i,h=Math.floor(o),n=Math.floor(l),_=FastNoiseLite._InterpHermite(o-h),c=FastNoiseLite._InterpHermite(l-n);h=Math.imul(h,this._PrimeX),n=Math.imul(n,this._PrimeY);let p=h+this._PrimeX,d=n+this._PrimeY,m=510&this._HashR2(e,h,n),u=510&this._HashR2(e,p,n),R=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),L=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);m=510&this._HashR2(e,h,d),u=510&this._HashR2(e,p,d);let F=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),D=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);s.x+=FastNoiseLite._Lerp(R,F,c)*t,s.y+=FastNoiseLite._Lerp(L,D,c)*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]),7===arguments.length&&arguments[3]instanceof Vector3&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6])}_SingleDomainWarpOpenSimplex2Gradient(){let e=(e,t,i,s,a,r,o,l)=>{r*=i,o*=i,l*=i;let h,n,_,c=Math.round(r),p=Math.round(o),d=Math.round(l),m=r-c,u=o-p,R=l-d,L=-m-1|1,F=-u-1|1,D=-R-1|1,C=L*-m,N=F*-u,P=D*-R;c=Math.imul(c,this._PrimeX),p=Math.imul(p,this._PrimeY),d=Math.imul(d,this._PrimeZ),h=n=_=0;let V=.6-m*m-(u*u+R*R);for(let t=0;;t++){if(V>0){let t,i,s,r=V*V*(V*V);if(a){let a=1020&this._HashR3(e,c,p,d);t=this._RandVecs3D[a],i=this._RandVecs3D[1|a],s=this._RandVecs3D[2|a]}else{let a=this._HashR3(e,c,p,d),r=252&a,o=a>>6&1020,l=m*this._Gradients3D[r]+u*this._Gradients3D[1|r]+R*this._Gradients3D[2|r];t=l*this._RandVecs3D[o],i=l*this._RandVecs3D[1|o],s=l*this._RandVecs3D[2|o]}h+=r*t,n+=r*i,_+=r*s}let i=V,s=c,r=p,o=d,l=m,y=u,T=R;if(C>=N&&C>=P?(l+=L,i=i+C+C,s-=L*this._PrimeX):N>C&&N>=P?(y+=F,i=i+N+N,r-=F*this._PrimeY):(T+=D,i=i+P+P,o-=D*this._PrimeZ),i>1){i-=1;let t,c,p,d=i*i*(i*i);if(a){let i=1020&this._HashR3(e,s,r,o);t=this._RandVecs3D[i],c=this._RandVecs3D[1|i],p=this._RandVecs3D[2|i]}else{let i=this._HashR3(e,s,r,o),a=252&i,h=i>>6&1020,n=l*this._Gradients3D[a]+y*this._Gradients3D[1|a]+T*this._Gradients3D[2|a];t=n*this._RandVecs3D[h],c=n*this._RandVecs3D[1|h],p=n*this._RandVecs3D[2|h]}h+=d*t,n+=d*c,_+=d*p}if(1===t)break;C=.5-C,N=.5-N,P=.5-P,m=L*C,u=F*N,R=D*P,V+=.75-C-(N+P),c+=L>>1&this._PrimeX,p+=F>>1&this._PrimeY,d+=D>>1&this._PrimeZ,L=-L,F=-F,D=-D,e+=1293373}s.x+=h*t,s.y+=n*t,s.z+=_*t};7===arguments.length&&((e,t,i,s,a,r,o)=>{const l=.21132486540518713;r*=i,o*=i;let h,n,_=Math.floor(r),c=Math.floor(o),p=r-_,d=o-c,m=(p+d)*l,u=p-m,R=d-m;_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),h=n=0;let L=.5-u*u-R*R;if(L>0){let t,i,s=L*L*(L*L);if(a){let s=510&this._HashR2(e,_,c);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let s=this._HashR2(e,_,c),a=254&s,r=s>>7&510,o=u*this._Gradients2D[a]+R*this._Gradients2D[1|a];t=o*this._RandVecs2D[r],i=o*this._RandVecs2D[1|r]}h+=s*t,n+=s*i}let F=3.1547005383792506*m+(-.6666666666666666+L);if(F>0){let t,i,s=u+(2*l-1),r=R+(2*l-1),o=F*F*(F*F);if(a){let s=510&this._HashR2(e,_+this._PrimeX,c+this._PrimeY);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let a=this._HashR2(e,_+this._PrimeX,c+this._PrimeY),o=254&a,l=a>>7&510,h=s*this._Gradients2D[o]+r*this._Gradients2D[1|o];t=h*this._RandVecs2D[l],i=h*this._RandVecs2D[1|l]}h+=o*t,n+=o*i}if(R>u){let t=u+l,i=R+(l-1),s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_,c+this._PrimeY);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_,c+this._PrimeY),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}else{let t=u+(l-1),i=R+l,s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_+this._PrimeX,c);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_+this._PrimeX,c),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}s.x+=h*t,s.y+=n*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]),8===arguments.length&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7])}}class Vector2{constructor(e,t){this.x=e,this.y=t}}class Vector3{constructor(e,t,i){this.x=e,this.y=t,this.z=i}} \ No newline at end of file + class FastNoiseLite{static NoiseType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2S:"OpenSimplex2S",Cellular:"Cellular",Perlin:"Perlin",ValueCubic:"ValueCubic",Value:"Value"});static RotationType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes"});static FractalType=Object.freeze({None:"None",FBm:"FBm",Ridged:"Ridged",PingPong:"PingPong",DomainWarpProgressive:"DomainWarpProgressive",DomainWarpIndependent:"DomainWarpIndependent"});static CellularDistanceFunction=Object.freeze({Euclidean:"Euclidean",EuclideanSq:"EuclideanSq",Manhattan:"Manhattan",Hybrid:"Hybrid"});static CellularReturnType=Object.freeze({CellValue:"CellValue",Distance:"Distance",Distance2:"Distance2",Distance2Add:"Distance2Add",Distance2Sub:"Distance2Sub",Distance2Mul:"Distance2Mul",Distance2Div:"Distance2Div"});static DomainWarpType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2Reduced:"OpenSimplex2Reduced",BasicGrid:"BasicGrid"});static TransformType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes",DefaultOpenSimplex2:"DefaultOpenSimplex2"});_Seed=1337;_Frequency=.01;_NoiseType=FastNoiseLite.NoiseType.OpenSimplex2;_RotationType3D=FastNoiseLite.RotationType3D.None;_TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;_DomainWarpAmp=1;_FractalType=FastNoiseLite.FractalType.None;_Octaves=3;_Lacunarity=2;_Gain=.5;_WeightedStrength=0;_PingPongStrength=2;_FractalBounding=1/1.75;_CellularDistanceFunction=FastNoiseLite.CellularDistanceFunction.EuclideanSq;_CellularReturnType=FastNoiseLite.CellularReturnType.Distance;_CellularJitterModifier=1;_DomainWarpType=FastNoiseLite.DomainWarpType.OpenSimplex2;_WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;constructor(e){void 0!==e&&(this._Seed=e)}SetSeed(e){this._Seed=e}SetFrequency(e){this._Frequency=e}SetNoiseType(e){this._NoiseType=e,this._UpdateTransformType3D()}SetRotationType3D(e){this._RotationType3D=e,this._UpdateTransformType3D(),this._UpdateWarpTransformType3D()}SetFractalType(e){this._FractalType=e}SetFractalOctaves(e){this._Octaves=e,this._CalculateFractalBounding()}SetFractalLacunarity(e){this._Lacunarity=e}SetFractalGain(e){this._Gain=e,this._CalculateFractalBounding()}SetFractalWeightedStrength(e){this._WeightedStrength=e}SetFractalPingPongStrength(e){this._PingPongStrength=e}SetCellularDistanceFunction(e){this._CellularDistanceFunction=e}SetCellularReturnType(e){this._CellularReturnType=e}SetCellularJitter(e){this._CellularJitterModifier=e}SetDomainWarpType(e){this._DomainWarpType=e,this._UpdateWarpTransformType3D()}SetDomainWarpAmp(e){this._DomainWarpAmp=e}GetNoise(e,t,i){let s=(e,t)=>{switch(e*=this._Frequency,t*=this._Frequency,this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:let i=(e+t)*(.5*(1.7320508075688772-1));e+=i,t+=i}switch(this._FractalType){default:return this._GenNoiseSingleR2(this._Seed,e,t);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR2(e,t);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR2(e,t);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR2(e,t)}},a=(e,t,i)=>{switch(e*=this._Frequency,t*=this._Frequency,i*=this._Frequency,this._TransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let s=e+t,a=-.211324865405187*s;e+=a-(i*=.577350269189626),t+=a-i,i+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let s=e+i,a=-.211324865405187*s;e+=a-(t*=.577350269189626),i+=a-t,t+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let s=(e+t+i)*(2/3);e=s-e,t=s-t,i=s-i}switch(this._FractalType){default:return this._GenNoiseSingleR3(this._Seed,e,t,i);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR3(e,t,i);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR3(e,t,i);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR3(e,t,i)}};return 2===arguments.length?s(e,t):3===arguments.length?a(e,t,i):void 0}DomainWrap(e){switch(this._FractalType){default:this._DomainWarpSingle(e);break;case FastNoiseLite.FractalType.DomainWarpProgressive:this._DomainWarpFractalProgressive(e);break;case FastNoiseLite.FractalType.DomainWarpIndependent:this._DomainWarpFractalIndependent(e)}}_Gradients2D=[.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.38268343236509,.923879532511287,.923879532511287,.38268343236509,.923879532511287,-.38268343236509,.38268343236509,-.923879532511287,-.38268343236509,-.923879532511287,-.923879532511287,-.38268343236509,-.923879532511287,.38268343236509,-.38268343236509,.923879532511287];_RandVecs2D=[-.2700222198,-.9628540911,.3863092627,-.9223693152,.04444859006,-.999011673,-.5992523158,-.8005602176,-.7819280288,.6233687174,.9464672271,.3227999196,-.6514146797,-.7587218957,.9378472289,.347048376,-.8497875957,-.5271252623,-.879042592,.4767432447,-.892300288,-.4514423508,-.379844434,-.9250503802,-.9951650832,.0982163789,.7724397808,-.6350880136,.7573283322,-.6530343002,-.9928004525,-.119780055,-.0532665713,.9985803285,.9754253726,-.2203300762,-.7665018163,.6422421394,.991636706,.1290606184,-.994696838,.1028503788,-.5379205513,-.84299554,.5022815471,-.8647041387,.4559821461,-.8899889226,-.8659131224,-.5001944266,.0879458407,-.9961252577,-.5051684983,.8630207346,.7753185226,-.6315704146,-.6921944612,.7217110418,-.5191659449,-.8546734591,.8978622882,-.4402764035,-.1706774107,.9853269617,-.9353430106,-.3537420705,-.9992404798,.03896746794,-.2882064021,-.9575683108,-.9663811329,.2571137995,-.8759714238,-.4823630009,-.8303123018,-.5572983775,.05110133755,-.9986934731,-.8558373281,-.5172450752,.09887025282,.9951003332,.9189016087,.3944867976,-.2439375892,-.9697909324,-.8121409387,-.5834613061,-.9910431363,.1335421355,.8492423985,-.5280031709,-.9717838994,-.2358729591,.9949457207,.1004142068,.6241065508,-.7813392434,.662910307,.7486988212,-.7197418176,.6942418282,-.8143370775,-.5803922158,.104521054,-.9945226741,-.1065926113,-.9943027784,.445799684,-.8951327509,.105547406,.9944142724,-.992790267,.1198644477,-.8334366408,.552615025,.9115561563,-.4111755999,.8285544909,-.5599084351,.7217097654,-.6921957921,.4940492677,-.8694339084,-.3652321272,-.9309164803,-.9696606758,.2444548501,.08925509731,-.996008799,.5354071276,-.8445941083,-.1053576186,.9944343981,-.9890284586,.1477251101,.004856104961,.9999882091,.9885598478,.1508291331,.9286129562,-.3710498316,-.5832393863,-.8123003252,.3015207509,.9534596146,-.9575110528,.2883965738,.9715802154,-.2367105511,.229981792,.9731949318,.955763816,-.2941352207,.740956116,.6715534485,-.9971513787,-.07542630764,.6905710663,-.7232645452,-.290713703,-.9568100872,.5912777791,-.8064679708,-.9454592212,-.325740481,.6664455681,.74555369,.6236134912,.7817328275,.9126993851,-.4086316587,-.8191762011,.5735419353,-.8812745759,-.4726046147,.9953313627,.09651672651,.9855650846,-.1692969699,-.8495980887,.5274306472,.6174853946,-.7865823463,.8508156371,.52546432,.9985032451,-.05469249926,.1971371563,-.9803759185,.6607855748,-.7505747292,-.03097494063,.9995201614,-.6731660801,.739491331,-.7195018362,-.6944905383,.9727511689,.2318515979,.9997059088,-.0242506907,.4421787429,-.8969269532,.9981350961,-.061043673,-.9173660799,-.3980445648,-.8150056635,-.5794529907,-.8789331304,.4769450202,.0158605829,.999874213,-.8095464474,.5870558317,-.9165898907,-.3998286786,-.8023542565,.5968480938,-.5176737917,.8555780767,-.8154407307,-.5788405779,.4022010347,-.9155513791,-.9052556868,-.4248672045,.7317445619,.6815789728,-.5647632201,-.8252529947,-.8403276335,-.5420788397,-.9314281527,.363925262,.5238198472,.8518290719,.7432803869,-.6689800195,-.985371561,-.1704197369,.4601468731,.88784281,.825855404,.5638819483,.6182366099,.7859920446,.8331502863,-.553046653,.1500307506,.9886813308,-.662330369,-.7492119075,-.668598664,.743623444,.7025606278,.7116238924,-.5419389763,-.8404178401,-.3388616456,.9408362159,.8331530315,.5530425174,-.2989720662,-.9542618632,.2638522993,.9645630949,.124108739,-.9922686234,-.7282649308,-.6852956957,.6962500149,.7177993569,-.9183535368,.3957610156,-.6326102274,-.7744703352,-.9331891859,-.359385508,-.1153779357,-.9933216659,.9514974788,-.3076565421,-.08987977445,-.9959526224,.6678496916,.7442961705,.7952400393,-.6062947138,-.6462007402,-.7631674805,-.2733598753,.9619118351,.9669590226,-.254931851,-.9792894595,.2024651934,-.5369502995,-.8436138784,-.270036471,-.9628500944,-.6400277131,.7683518247,-.7854537493,-.6189203566,.06005905383,-.9981948257,-.02455770378,.9996984141,-.65983623,.751409442,-.6253894466,-.7803127835,-.6210408851,-.7837781695,.8348888491,.5504185768,-.1592275245,.9872419133,.8367622488,.5475663786,-.8675753916,-.4973056806,-.2022662628,-.9793305667,.9399189937,.3413975472,.9877404807,-.1561049093,-.9034455656,.4287028224,.1269804218,-.9919052235,-.3819600854,.924178821,.9754625894,.2201652486,-.3204015856,-.9472818081,-.9874760884,.1577687387,.02535348474,-.9996785487,.4835130794,-.8753371362,-.2850799925,-.9585037287,-.06805516006,-.99768156,-.7885244045,-.6150034663,.3185392127,-.9479096845,.8880043089,.4598351306,.6476921488,-.7619021462,.9820241299,.1887554194,.9357275128,-.3527237187,-.8894895414,.4569555293,.7922791302,.6101588153,.7483818261,.6632681526,-.7288929755,-.6846276581,.8729032783,-.4878932944,.8288345784,.5594937369,.08074567077,.9967347374,.9799148216,-.1994165048,-.580730673,-.8140957471,-.4700049791,-.8826637636,.2409492979,.9705377045,.9437816757,-.3305694308,-.8927998638,-.4504535528,-.8069622304,.5906030467,.06258973166,.9980393407,-.9312597469,.3643559849,.5777449785,.8162173362,-.3360095855,-.941858566,.697932075,-.7161639607,-.002008157227,-.9999979837,-.1827294312,-.9831632392,-.6523911722,.7578824173,-.4302626911,-.9027037258,-.9985126289,-.05452091251,-.01028102172,-.9999471489,-.4946071129,.8691166802,-.2999350194,.9539596344,.8165471961,.5772786819,.2697460475,.962931498,-.7306287391,-.6827749597,-.7590952064,-.6509796216,-.907053853,.4210146171,-.5104861064,-.8598860013,.8613350597,.5080373165,.5007881595,-.8655698812,-.654158152,.7563577938,-.8382755311,-.545246856,.6940070834,.7199681717,.06950936031,.9975812994,.1702942185,-.9853932612,.2695973274,.9629731466,.5519612192,-.8338697815,.225657487,-.9742067022,.4215262855,-.9068161835,.4881873305,-.8727388672,-.3683854996,-.9296731273,-.9825390578,.1860564427,.81256471,.5828709909,.3196460933,-.9475370046,.9570913859,.2897862643,-.6876655497,-.7260276109,-.9988770922,-.047376731,-.1250179027,.992154486,-.8280133617,.560708367,.9324863769,-.3612051451,.6394653183,.7688199442,-.01623847064,-.9998681473,-.9955014666,-.09474613458,-.81453315,.580117012,.4037327978,-.9148769469,.9944263371,.1054336766,-.1624711654,.9867132919,-.9949487814,-.100383875,-.6995302564,.7146029809,.5263414922,-.85027327,-.5395221479,.841971408,.6579370318,.7530729462,.01426758847,-.9998982128,-.6734383991,.7392433447,.639412098,-.7688642071,.9211571421,.3891908523,-.146637214,-.9891903394,-.782318098,.6228791163,-.5039610839,-.8637263605,-.7743120191,-.6328039957];_Gradients3D=[0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,1,1,0,0,0,-1,1,0,-1,1,0,0,0,-1,-1,0];_RandVecs3D=[-.7292736885,-.6618439697,.1735581948,0,.790292081,-.5480887466,-.2739291014,0,.7217578935,.6226212466,-.3023380997,0,.565683137,-.8208298145,-.0790000257,0,.760049034,-.5555979497,-.3370999617,0,.3713945616,.5011264475,.7816254623,0,-.1277062463,-.4254438999,-.8959289049,0,-.2881560924,-.5815838982,.7607405838,0,.5849561111,-.662820239,-.4674352136,0,.3307171178,.0391653737,.94291689,0,.8712121778,-.4113374369,-.2679381538,0,.580981015,.7021915846,.4115677815,0,.503756873,.6330056931,-.5878203852,0,.4493712205,.601390195,.6606022552,0,-.6878403724,.09018890807,-.7202371714,0,-.5958956522,-.6469350577,.475797649,0,-.5127052122,.1946921978,-.8361987284,0,-.9911507142,-.05410276466,-.1212153153,0,-.2149721042,.9720882117,-.09397607749,0,-.7518650936,-.5428057603,.3742469607,0,.5237068895,.8516377189,-.02107817834,0,.6333504779,.1926167129,-.7495104896,0,-.06788241606,.3998305789,.9140719259,0,-.5538628599,-.4729896695,-.6852128902,0,-.7261455366,-.5911990757,.3509933228,0,-.9229274737,-.1782808786,.3412049336,0,-.6968815002,.6511274338,.3006480328,0,.9608044783,-.2098363234,-.1811724921,0,.06817146062,-.9743405129,.2145069156,0,-.3577285196,-.6697087264,-.6507845481,0,-.1868621131,.7648617052,-.6164974636,0,-.6541697588,.3967914832,.6439087246,0,.6993340405,-.6164538506,.3618239211,0,-.1546665739,.6291283928,.7617583057,0,-.6841612949,-.2580482182,-.6821542638,0,.5383980957,.4258654885,.7271630328,0,-.5026987823,-.7939832935,-.3418836993,0,.3202971715,.2834415347,.9039195862,0,.8683227101,-.0003762656404,-.4959995258,0,.791120031,-.08511045745,.6057105799,0,-.04011016052,-.4397248749,.8972364289,0,.9145119872,.3579346169,-.1885487608,0,-.9612039066,-.2756484276,.01024666929,0,.6510361721,-.2877799159,-.7023778346,0,-.2041786351,.7365237271,.644859585,0,-.7718263711,.3790626912,.5104855816,0,-.3060082741,-.7692987727,.5608371729,0,.454007341,-.5024843065,.7357899537,0,.4816795475,.6021208291,-.6367380315,0,.6961980369,-.3222197429,.641469197,0,-.6532160499,-.6781148932,.3368515753,0,.5089301236,-.6154662304,-.6018234363,0,-.1635919754,-.9133604627,-.372840892,0,.52408019,-.8437664109,.1157505864,0,.5902587356,.4983817807,-.6349883666,0,.5863227872,.494764745,.6414307729,0,.6779335087,.2341345225,.6968408593,0,.7177054546,-.6858979348,.120178631,0,-.5328819713,-.5205125012,.6671608058,0,-.8654874251,-.0700727088,-.4960053754,0,-.2861810166,.7952089234,.5345495242,0,-.04849529634,.9810836427,-.1874115585,0,-.6358521667,.6058348682,.4781800233,0,.6254794696,-.2861619734,.7258696564,0,-.2585259868,.5061949264,-.8227581726,0,.02136306781,.5064016808,-.8620330371,0,.200111773,.8599263484,.4695550591,0,.4743561372,.6014985084,-.6427953014,0,.6622993731,-.5202474575,-.5391679918,0,.08084972818,-.6532720452,.7527940996,0,-.6893687501,.0592860349,.7219805347,0,-.1121887082,-.9673185067,.2273952515,0,.7344116094,.5979668656,-.3210532909,0,.5789393465,-.2488849713,.7764570201,0,.6988182827,.3557169806,-.6205791146,0,-.8636845529,-.2748771249,-.4224826141,0,-.4247027957,-.4640880967,.777335046,0,.5257722489,-.8427017621,.1158329937,0,.9343830603,.316302472,-.1639543925,0,-.1016836419,-.8057303073,-.5834887393,0,-.6529238969,.50602126,-.5635892736,0,-.2465286165,-.9668205684,-.06694497494,0,-.9776897119,-.2099250524,-.007368825344,0,.7736893337,.5734244712,.2694238123,0,-.6095087895,.4995678998,.6155736747,0,.5794535482,.7434546771,.3339292269,0,-.8226211154,.08142581855,.5627293636,0,-.510385483,.4703667658,.7199039967,0,-.5764971849,-.07231656274,-.8138926898,0,.7250628871,.3949971505,-.5641463116,0,-.1525424005,.4860840828,-.8604958341,0,-.5550976208,-.4957820792,.667882296,0,-.1883614327,.9145869398,.357841725,0,.7625556724,-.5414408243,-.3540489801,0,-.5870231946,-.3226498013,-.7424963803,0,.3051124198,.2262544068,-.9250488391,0,.6379576059,.577242424,-.5097070502,0,-.5966775796,.1454852398,-.7891830656,0,-.658330573,.6555487542,-.3699414651,0,.7434892426,.2351084581,.6260573129,0,.5562114096,.8264360377,-.0873632843,0,-.3028940016,-.8251527185,.4768419182,0,.1129343818,-.985888439,-.1235710781,0,.5937652891,-.5896813806,.5474656618,0,.6757964092,-.5835758614,-.4502648413,0,.7242302609,-.1152719764,.6798550586,0,-.9511914166,.0753623979,-.2992580792,0,.2539470961,-.1886339355,.9486454084,0,.571433621,-.1679450851,-.8032795685,0,-.06778234979,.3978269256,.9149531629,0,.6074972649,.733060024,-.3058922593,0,-.5435478392,.1675822484,.8224791405,0,-.5876678086,-.3380045064,-.7351186982,0,-.7967562402,.04097822706,-.6029098428,0,-.1996350917,.8706294745,.4496111079,0,-.02787660336,-.9106232682,-.4122962022,0,-.7797625996,-.6257634692,.01975775581,0,-.5211232846,.7401644346,-.4249554471,0,.8575424857,.4053272873,-.3167501783,0,.1045223322,.8390195772,-.5339674439,0,.3501822831,.9242524096,-.1520850155,0,.1987849858,.07647613266,.9770547224,0,.7845996363,.6066256811,-.1280964233,0,.09006737436,-.9750989929,-.2026569073,0,-.8274343547,-.542299559,.1458203587,0,-.3485797732,-.415802277,.840000362,0,-.2471778936,-.7304819962,-.6366310879,0,-.3700154943,.8577948156,.3567584454,0,.5913394901,-.548311967,-.5913303597,0,.1204873514,-.7626472379,-.6354935001,0,.616959265,.03079647928,.7863922953,0,.1258156836,-.6640829889,-.7369967419,0,-.6477565124,-.1740147258,-.7417077429,0,.6217889313,-.7804430448,-.06547655076,0,.6589943422,-.6096987708,.4404473475,0,-.2689837504,-.6732403169,-.6887635427,0,-.3849775103,.5676542638,.7277093879,0,.5754444408,.8110471154,-.1051963504,0,.9141593684,.3832947817,.131900567,0,-.107925319,.9245493968,.3654593525,0,.377977089,.3043148782,.8743716458,0,-.2142885215,-.8259286236,.5214617324,0,.5802544474,.4148098596,-.7008834116,0,-.1982660881,.8567161266,-.4761596756,0,-.03381553704,.3773180787,-.9254661404,0,-.6867922841,-.6656597827,.2919133642,0,.7731742607,-.2875793547,-.5652430251,0,-.09655941928,.9193708367,-.3813575004,0,.2715702457,-.9577909544,-.09426605581,0,.2451015704,-.6917998565,-.6792188003,0,.977700782,-.1753855374,.1155036542,0,-.5224739938,.8521606816,.02903615945,0,-.7734880599,-.5261292347,.3534179531,0,-.7134492443,-.269547243,.6467878011,0,.1644037271,.5105846203,-.8439637196,0,.6494635788,.05585611296,.7583384168,0,-.4711970882,.5017280509,-.7254255765,0,-.6335764307,-.2381686273,-.7361091029,0,-.9021533097,-.270947803,-.3357181763,0,-.3793711033,.872258117,.3086152025,0,-.6855598966,-.3250143309,.6514394162,0,.2900942212,-.7799057743,-.5546100667,0,-.2098319339,.85037073,.4825351604,0,-.4592603758,.6598504336,-.5947077538,0,.8715945488,.09616365406,-.4807031248,0,-.6776666319,.7118504878,-.1844907016,0,.7044377633,.312427597,.637304036,0,-.7052318886,-.2401093292,-.6670798253,0,.081921007,-.7207336136,-.6883545647,0,-.6993680906,-.5875763221,-.4069869034,0,-.1281454481,.6419895885,.7559286424,0,-.6337388239,-.6785471501,-.3714146849,0,.5565051903,-.2168887573,-.8020356851,0,-.5791554484,.7244372011,-.3738578718,0,.1175779076,-.7096451073,.6946792478,0,-.6134619607,.1323631078,.7785527795,0,.6984635305,-.02980516237,-.715024719,0,.8318082963,-.3930171956,.3919597455,0,.1469576422,.05541651717,-.9875892167,0,.708868575,-.2690503865,.6520101478,0,.2726053183,.67369766,-.68688995,0,-.6591295371,.3035458599,-.6880466294,0,.4815131379,-.7528270071,.4487723203,0,.9430009463,.1675647412,-.2875261255,0,.434802957,.7695304522,-.4677277752,0,.3931996188,.594473625,.7014236729,0,.7254336655,-.603925654,.3301814672,0,.7590235227,-.6506083235,.02433313207,0,-.8552768592,-.3430042733,.3883935666,0,-.6139746835,.6981725247,.3682257648,0,-.7465905486,-.5752009504,.3342849376,0,.5730065677,.810555537,-.1210916791,0,-.9225877367,-.3475211012,-.167514036,0,-.7105816789,-.4719692027,-.5218416899,0,-.08564609717,.3583001386,.929669703,0,-.8279697606,-.2043157126,.5222271202,0,.427944023,.278165994,.8599346446,0,.5399079671,-.7857120652,-.3019204161,0,.5678404253,-.5495413974,-.6128307303,0,-.9896071041,.1365639107,-.04503418428,0,-.6154342638,-.6440875597,.4543037336,0,.1074204368,-.7946340692,.5975094525,0,-.3595449969,-.8885529948,.28495784,0,-.2180405296,.1529888965,.9638738118,0,-.7277432317,-.6164050508,-.3007234646,0,.7249729114,-.00669719484,.6887448187,0,-.5553659455,-.5336586252,.6377908264,0,.5137558015,.7976208196,-.3160000073,0,-.3794024848,.9245608561,-.03522751494,0,.8229248658,.2745365933,-.4974176556,0,-.5404114394,.6091141441,.5804613989,0,.8036581901,-.2703029469,.5301601931,0,.6044318879,.6832968393,.4095943388,0,.06389988817,.9658208605,-.2512108074,0,.1087113286,.7402471173,-.6634877936,0,-.713427712,-.6926784018,.1059128479,0,.6458897819,-.5724548511,-.5050958653,0,-.6553931414,.7381471625,.159995615,0,.3910961323,.9188871375,-.05186755998,0,-.4879022471,-.5904376907,.6429111375,0,.6014790094,.7707441366,-.2101820095,0,-.5677173047,.7511360995,.3368851762,0,.7858573506,.226674665,.5753666838,0,-.4520345543,-.604222686,-.6561857263,0,.002272116345,.4132844051,-.9105991643,0,-.5815751419,-.5162925989,.6286591339,0,-.03703704785,.8273785755,.5604221175,0,-.5119692504,.7953543429,-.3244980058,0,-.2682417366,-.9572290247,-.1084387619,0,-.2322482736,-.9679131102,-.09594243324,0,.3554328906,-.8881505545,.2913006227,0,.7346520519,-.4371373164,.5188422971,0,.9985120116,.04659011161,-.02833944577,0,-.3727687496,-.9082481361,.1900757285,0,.91737377,-.3483642108,.1925298489,0,.2714911074,.4147529736,-.8684886582,0,.5131763485,-.7116334161,.4798207128,0,-.8737353606,.18886992,-.4482350644,0,.8460043821,-.3725217914,.3814499973,0,.8978727456,-.1780209141,-.4026575304,0,.2178065647,-.9698322841,-.1094789531,0,-.1518031304,-.7788918132,-.6085091231,0,-.2600384876,-.4755398075,-.8403819825,0,.572313509,-.7474340931,-.3373418503,0,-.7174141009,.1699017182,-.6756111411,0,-.684180784,.02145707593,-.7289967412,0,-.2007447902,.06555605789,-.9774476623,0,-.1148803697,-.8044887315,.5827524187,0,-.7870349638,.03447489231,.6159443543,0,-.2015596421,.6859872284,.6991389226,0,-.08581082512,-.10920836,-.9903080513,0,.5532693395,.7325250401,-.396610771,0,-.1842489331,-.9777375055,-.1004076743,0,.0775473789,-.9111505856,.4047110257,0,.1399838409,.7601631212,-.6344734459,0,.4484419361,-.845289248,.2904925424,0];_PrimeX=501125321;_PrimeY=1136930381;_PrimeZ=1720413743;static _Lerp(e,t,i){return e+i*(t-e)}static _InterpHermite(e){return e*e*(3-2*e)}static _InterpQuintic(e){return e*e*e*(e*(6*e-15)+10)}static _CubicLerp(e,t,i,s,a){let r=s-i-(e-t);return a*a*a*r+a*a*(e-t-r)+a*(i-e)+t}static _PingPong(e){return(e-=2*Math.trunc(.5*e))<1?e:2-e}_CalculateFractalBounding(){let e=Math.abs(this._Gain),t=e,i=1;for(let s=1;s>15,r&=254,s*this._Gradients2D[r]+a*this._Gradients2D[1|r]}_GradCoordR3(e,t,i,s,a,r,o){let l=this._HashR3(e,t,i,s);return l^=l>>15,l&=252,a*this._Gradients3D[l]+r*this._Gradients3D[1|l]+o*this._Gradients3D[2|l]}_GenNoiseSingleR2(e,t,i){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R2(e,t,i);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR2(e,t,i);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR2(e,t,i);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR2(e,t,i);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR2(e,t,i);case FastNoiseLite.NoiseType.Value:return this._SingleValueR2(e,t,i);default:return 0}}_GenNoiseSingleR3(e,t,i,s){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R3(e,t,i,s);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR3(e,t,i,s);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR3(e,t,i,s);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR3(e,t,i,s);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR3(e,t,i,s);case FastNoiseLite.NoiseType.Value:return this._SingleValueR3(e,t,i,s);default:return 0}}_UpdateTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:this._TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._TransformType3D=FastNoiseLite.TransformType3D.None}}}_UpdateWarpTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._WarpTransformType3D=FastNoiseLite.TransformType3D.None}}}_GenFractalFBmR2(e,t){let i=this._Seed,s=0,a=this._FractalBounding;for(let r=0;rp){let t=p+s,i=d+(s-1),a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l,h+this._PrimeY,t,i)}else{let t=p+(s-1),i=d+s,a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l+this._PrimeX,h,t,i)}return 99.83685446303647*(a+r+o)}_SingleOpenSimplex2R3(e,t,i,s){let a=Math.round(t),r=Math.round(i),o=Math.round(s),l=t-a,h=i-r,n=s-o,_=Math.trunc(-1-h|1),c=Math.trunc(-1-l|1),p=Math.trunc(-1-n|1),d=c*-l,m=_*-h,u=p*-n;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let R=0,L=.6-l*l-(h*h+n*n);for(let t=0;;t++){if(L>0&&(R+=L*L*(L*L)*this._GradCoordR3(e,a,r,o,l,h,n)),d>=m&&d>=u){let t=L+d+d;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a-c*this._PrimeX,r,o,l+c,h,n))}else if(m>d&&m>=u){let t=L+m+m;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r-_*this._PrimeY,o,l,h+_,n))}else{let t=L+u+u;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r,o-p*this._PrimeZ,l,h,n+p))}if(1===t)break;d=.5-d,m=.5-m,u=.5-u,l=c*d,h=_*m,n=p*u,L+=.75-d-(m+u),a+=c>>1&this._PrimeX,r+=_>>1&this._PrimeY,o+=p>>1&this._PrimeZ,c=-c,_=-_,p=-p,e=~e}return 32.69428253173828*R}_SingleOpenSimplex2SR2(e,t,i){const s=.21132486540518713;let a=Math.floor(t),r=Math.floor(i),o=t-a,l=i-r;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY);let h=a+this._PrimeX,n=r+this._PrimeY,_=(o+l)*s,c=o-_,p=l-_,d=2/3-c*c-p*p,m=d*d*(d*d)*this._GradCoordR2(e,a,r,c,p),u=3.1547005383792506*_+(-.6666666666666666+d),R=c-(1-2*s),L=p-(1-2*s);m+=u*u*(u*u)*this._GradCoordR2(e,h,n,R,L);let F=o-l;if(_>s){if(o+F>1){let t=c+(3*s-2),i=p+(3*s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+(this._PrimeX<<1),r+this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}if(l-F>1){let t=c+(3*s-1),i=p+(3*s-2),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r+(this._PrimeY<<1),t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}}else{if(o+F<0){let t=c+(1-s),i=p-s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a-this._PrimeX,r,t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}if(l0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r-this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}}return 18.24196194486065*m}_SingleOpenSimplex2SR3(e,t,i,s){let a=Math.floor(t),r=Math.floor(i),o=Math.floor(s),l=t-a,h=i-r,n=s-o;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let _=e+1293373,c=Math.trunc(-.5-l),p=Math.trunc(-.5-h),d=Math.trunc(-.5-n),m=l+c,u=h+p,R=n+d,L=.75-m*m-u*u-R*R,F=L*L*(L*L)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),m,u,R),D=l-.5,C=h-.5,N=n-.5,P=.75-D*D-C*C-N*N;F+=P*P*(P*P)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+this._PrimeZ,D,C,N);let V=((1|c)<<1)*D,y=((1|p)<<1)*C,T=((1|d)<<1)*N,f=(-2-(c<<2))*D-1,S=(-2-(p<<2))*C-1,g=(-2-(d<<2))*N-1,M=!1,G=V+L;if(G>0){let t=m-(1|c);F+=G*G*(G*G)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),t,u,R)}else{let t=y+T+L;if(t>0){let i=m,s=u-(1|p),l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=f+P;if(i>0){let e=(1|c)+D;F+=i*i*(i*i)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+this._PrimeZ,e,C,N),M=!0}}let b=!1,X=y+L;if(X>0){let t=m,i=u-(1|p);F+=X*X*(X*X)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),t,i,R)}else{let t=V+T+L;if(t>0){let i=m-(1|c),s=u,l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=S+P;if(i>0){let e=D,t=(1|p)+C;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+this._PrimeZ,e,t,N),b=!0}}let W=!1,Y=T+L;if(Y>0){let t=m,i=u,s=R-(1|d);F+=Y*Y*(Y*Y)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),t,i,s)}else{let t=V+y+L;if(t>0){let i=m-(1|c),s=u-(1|p);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),i,s,R)}let i=g+P;if(i>0){let e=D,t=C,s=(1|d)+N;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+(d&this._PrimeZ<<1),e,t,s),W=!0}}if(!M){let e=S+g+P;if(e>0){let t=D,i=(1|p)+C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+(d&this._PrimeZ<<1),t,i,s)}}if(!b){let e=f+g+P;if(e>0){let t=(1|c)+D,i=C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+(d&this._PrimeZ<<1),t,i,s)}}if(!W){let e=f+S+P;if(e>0){let t=(1|c)+D,i=(1|p)+C;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&this._PrimeX<<1),r+(p&this._PrimeY<<1),o+this._PrimeZ,t,i,N)}}return 9.046026385208288*F}_SingleCellularR2(e,t,i){let s=Math.round(t),a=Math.round(i),r=Number.MAX_VALUE,o=Number.MAX_VALUE,l=0,h=.43701595*this._CellularJitterModifier,n=(s-1)*this._PrimeX,_=(a-1)*this._PrimeY;switch(this._CellularDistanceFunction){default:case FastNoiseLite.CellularDistanceFunction.Euclidean:case FastNoiseLite.CellularDistanceFunction.EuclideanSq:for(let c=s-1;c<=s+1;c++){let s=_;for(let _=a-1;_<=a+1;_++){let a=this._HashR2(e,n,s),p=510&a,d=c-t+this._RandVecs2D[p]*h,m=_-i+this._RandVecs2D[1|p]*h,u=d*d+m*m;o=Math.max(Math.min(o,u),r),u{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,32.69428253173828*t,i,s,!1,a,r,o);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,7.71604938271605*t,i,s,!0,a,r,o);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r,o)}};return 6===arguments.length&&arguments[3]instanceof Vector2?((e,t,i,s,a,r)=>{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,38.283687591552734*t,i,s,!1,a,r);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,16*t,i,s,!0,a,r);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r)}})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]):7===arguments.length&&arguments[3]instanceof Vector3?e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]):void 0}_DomainWarpSingle(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y,o=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=a+r,t=-.211324865405187*e;o*=.577350269189626,a+=t-o,r=r+t-o,o+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=a+o,t=-.211324865405187*e;r*=.577350269189626,a+=t-r,o+=t-r,r+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let e=(a+r+o)*(2/3);a=e-a,r=e-r,o=e-o}this._DoSingleDomainWarp(t,i,s,e,a,r,o)};return 1===arguments.length&&arguments[0]instanceof Vector2?(e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(a+r)*(.5*(1.7320508075688772-1));a+=e,r+=e}this._DoSingleDomainWarp(t,i,s,e,a,r)})(arguments[0]):1===arguments.length&&arguments[0]instanceof Vector3?e(arguments[0]):void 0}_DomainWarpFractalProgressive(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=e.x,i=e.y,s=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=t+i,a=-.211324865405187*e;s*=.577350269189626,t+=a-s,i=i+a-s,s+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=t+s,a=-.211324865405187*e;i*=.577350269189626,t+=a-i,s+=a-i,i+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:{let e=(t+i+s)*(2/3);t=e-t,i=e-i,s=e-s}}let a=this._Seed,r=this._DomainWarpAmp*this._FractalBounding,o=this._Frequency;for(let l=0;l{let t=e.x,i=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(t+i)*(.5*(1.7320508075688772-1));t+=e,i+=e}let s=this._Seed,a=this._DomainWarpAmp*this._FractalBounding,r=this._Frequency;for(let o=0;o{let l=a*i,h=r*i,n=o*i,_=Math.floor(l),c=Math.floor(h),p=Math.floor(n),d=FastNoiseLite._InterpHermite(l-_),m=FastNoiseLite._InterpHermite(h-c),u=FastNoiseLite._InterpHermite(n-p);_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),p=Math.imul(p,this._PrimeZ);let R=_+this._PrimeX,L=c+this._PrimeY,F=p+this._PrimeZ,D=1020&this._HashR3(e,_,c,p),C=1020&this._HashR3(e,R,c,p),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d);D=1020&this._HashR3(e,_,L,p),C=1020&this._HashR3(e,R,L,p);let y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),S=FastNoiseLite._Lerp(N,y,m),g=FastNoiseLite._Lerp(P,T,m),M=FastNoiseLite._Lerp(V,f,m);D=1020&this._HashR3(e,_,c,F),C=1020&this._HashR3(e,R,c,F),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),D=1020&this._HashR3(e,_,L,F),C=1020&this._HashR3(e,R,L,F),y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),s.x+=FastNoiseLite._Lerp(S,FastNoiseLite._Lerp(N,y,m),u)*t,s.y+=FastNoiseLite._Lerp(g,FastNoiseLite._Lerp(P,T,m),u)*t,s.z+=FastNoiseLite._Lerp(M,FastNoiseLite._Lerp(V,f,m),u)*t};6===arguments.length&&arguments[3]instanceof Vector2&&((e,t,i,s,a,r)=>{let o=a*i,l=r*i,h=Math.floor(o),n=Math.floor(l),_=FastNoiseLite._InterpHermite(o-h),c=FastNoiseLite._InterpHermite(l-n);h=Math.imul(h,this._PrimeX),n=Math.imul(n,this._PrimeY);let p=h+this._PrimeX,d=n+this._PrimeY,m=510&this._HashR2(e,h,n),u=510&this._HashR2(e,p,n),R=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),L=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);m=510&this._HashR2(e,h,d),u=510&this._HashR2(e,p,d);let F=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),D=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);s.x+=FastNoiseLite._Lerp(R,F,c)*t,s.y+=FastNoiseLite._Lerp(L,D,c)*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]),7===arguments.length&&arguments[3]instanceof Vector3&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6])}_SingleDomainWarpOpenSimplex2Gradient(){let e=(e,t,i,s,a,r,o,l)=>{r*=i,o*=i,l*=i;let h,n,_,c=Math.round(r),p=Math.round(o),d=Math.round(l),m=r-c,u=o-p,R=l-d,L=-m-1|1,F=-u-1|1,D=-R-1|1,C=L*-m,N=F*-u,P=D*-R;c=Math.imul(c,this._PrimeX),p=Math.imul(p,this._PrimeY),d=Math.imul(d,this._PrimeZ),h=n=_=0;let V=.6-m*m-(u*u+R*R);for(let t=0;;t++){if(V>0){let t,i,s,r=V*V*(V*V);if(a){let a=1020&this._HashR3(e,c,p,d);t=this._RandVecs3D[a],i=this._RandVecs3D[1|a],s=this._RandVecs3D[2|a]}else{let a=this._HashR3(e,c,p,d),r=252&a,o=a>>6&1020,l=m*this._Gradients3D[r]+u*this._Gradients3D[1|r]+R*this._Gradients3D[2|r];t=l*this._RandVecs3D[o],i=l*this._RandVecs3D[1|o],s=l*this._RandVecs3D[2|o]}h+=r*t,n+=r*i,_+=r*s}let i=V,s=c,r=p,o=d,l=m,y=u,T=R;if(C>=N&&C>=P?(l+=L,i=i+C+C,s-=L*this._PrimeX):N>C&&N>=P?(y+=F,i=i+N+N,r-=F*this._PrimeY):(T+=D,i=i+P+P,o-=D*this._PrimeZ),i>1){i-=1;let t,c,p,d=i*i*(i*i);if(a){let i=1020&this._HashR3(e,s,r,o);t=this._RandVecs3D[i],c=this._RandVecs3D[1|i],p=this._RandVecs3D[2|i]}else{let i=this._HashR3(e,s,r,o),a=252&i,h=i>>6&1020,n=l*this._Gradients3D[a]+y*this._Gradients3D[1|a]+T*this._Gradients3D[2|a];t=n*this._RandVecs3D[h],c=n*this._RandVecs3D[1|h],p=n*this._RandVecs3D[2|h]}h+=d*t,n+=d*c,_+=d*p}if(1===t)break;C=.5-C,N=.5-N,P=.5-P,m=L*C,u=F*N,R=D*P,V+=.75-C-(N+P),c+=L>>1&this._PrimeX,p+=F>>1&this._PrimeY,d+=D>>1&this._PrimeZ,L=-L,F=-F,D=-D,e+=1293373}s.x+=h*t,s.y+=n*t,s.z+=_*t};7===arguments.length&&((e,t,i,s,a,r,o)=>{const l=.21132486540518713;r*=i,o*=i;let h,n,_=Math.floor(r),c=Math.floor(o),p=r-_,d=o-c,m=(p+d)*l,u=p-m,R=d-m;_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),h=n=0;let L=.5-u*u-R*R;if(L>0){let t,i,s=L*L*(L*L);if(a){let s=510&this._HashR2(e,_,c);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let s=this._HashR2(e,_,c),a=254&s,r=s>>7&510,o=u*this._Gradients2D[a]+R*this._Gradients2D[1|a];t=o*this._RandVecs2D[r],i=o*this._RandVecs2D[1|r]}h+=s*t,n+=s*i}let F=3.1547005383792506*m+(-.6666666666666666+L);if(F>0){let t,i,s=u+(2*l-1),r=R+(2*l-1),o=F*F*(F*F);if(a){let s=510&this._HashR2(e,_+this._PrimeX,c+this._PrimeY);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let a=this._HashR2(e,_+this._PrimeX,c+this._PrimeY),o=254&a,l=a>>7&510,h=s*this._Gradients2D[o]+r*this._Gradients2D[1|o];t=h*this._RandVecs2D[l],i=h*this._RandVecs2D[1|l]}h+=o*t,n+=o*i}if(R>u){let t=u+l,i=R+(l-1),s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_,c+this._PrimeY);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_,c+this._PrimeY),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}else{let t=u+(l-1),i=R+l,s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_+this._PrimeX,c);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_+this._PrimeX,c),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}s.x+=h*t,s.y+=n*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]),8===arguments.length&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7])}}class Vector2{constructor(e,t){this.x=e,this.y=t}}class Vector3{constructor(e,t,i){this.x=e,this.y=t,this.z=i}} + + Scratch.extensions.register(new Noise()); +})(Scratch); From 96bdeccf91d2a3df1758c475b2a95916934dd1d3 Mon Sep 17 00:00:00 2001 From: Cubester Date: Wed, 25 Dec 2024 22:00:29 -0500 Subject: [PATCH 28/36] Fix these AGAIN --- extensions/Corbnorb/noise.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 9109f64b49..e6fa05ed51 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -16,12 +16,6 @@ const Translate = Scratch.translate; class Noise { - constructor() { - this.noiseSeed = 0; - this.worleySeed = 0; - this.time = performance.now(); - } - getInfo() { return { id: "corbnorbsnoise", @@ -189,7 +183,7 @@ const inverted = Cast.toBoolean(args.INVERTED); if (id in noises) { let value = noises[id].GetNoise(args.X, args.Y, args.Z); - value = (inverted == true) ? -value : value; + value = inverted == true ? -value : value; value = (value + 1) / 2; switch (easing) { case "linear": From 91ba77f4ba270f821258fce6997884729c42a03a Mon Sep 17 00:00:00 2001 From: Cubester Date: Wed, 25 Dec 2024 22:01:32 -0500 Subject: [PATCH 29/36] Skip the library --- extensions/Corbnorb/noise.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index e6fa05ed51..4fa5fabf5e 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -235,7 +235,10 @@ //minified code. find original here: // https://raw.githubusercontent.com/Auburn/FastNoiseLite/refs/heads/master/JavaScript/FastNoiseLite.js + /* eslint-disable */ + // prettier-ignore class FastNoiseLite{static NoiseType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2S:"OpenSimplex2S",Cellular:"Cellular",Perlin:"Perlin",ValueCubic:"ValueCubic",Value:"Value"});static RotationType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes"});static FractalType=Object.freeze({None:"None",FBm:"FBm",Ridged:"Ridged",PingPong:"PingPong",DomainWarpProgressive:"DomainWarpProgressive",DomainWarpIndependent:"DomainWarpIndependent"});static CellularDistanceFunction=Object.freeze({Euclidean:"Euclidean",EuclideanSq:"EuclideanSq",Manhattan:"Manhattan",Hybrid:"Hybrid"});static CellularReturnType=Object.freeze({CellValue:"CellValue",Distance:"Distance",Distance2:"Distance2",Distance2Add:"Distance2Add",Distance2Sub:"Distance2Sub",Distance2Mul:"Distance2Mul",Distance2Div:"Distance2Div"});static DomainWarpType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2Reduced:"OpenSimplex2Reduced",BasicGrid:"BasicGrid"});static TransformType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes",DefaultOpenSimplex2:"DefaultOpenSimplex2"});_Seed=1337;_Frequency=.01;_NoiseType=FastNoiseLite.NoiseType.OpenSimplex2;_RotationType3D=FastNoiseLite.RotationType3D.None;_TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;_DomainWarpAmp=1;_FractalType=FastNoiseLite.FractalType.None;_Octaves=3;_Lacunarity=2;_Gain=.5;_WeightedStrength=0;_PingPongStrength=2;_FractalBounding=1/1.75;_CellularDistanceFunction=FastNoiseLite.CellularDistanceFunction.EuclideanSq;_CellularReturnType=FastNoiseLite.CellularReturnType.Distance;_CellularJitterModifier=1;_DomainWarpType=FastNoiseLite.DomainWarpType.OpenSimplex2;_WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;constructor(e){void 0!==e&&(this._Seed=e)}SetSeed(e){this._Seed=e}SetFrequency(e){this._Frequency=e}SetNoiseType(e){this._NoiseType=e,this._UpdateTransformType3D()}SetRotationType3D(e){this._RotationType3D=e,this._UpdateTransformType3D(),this._UpdateWarpTransformType3D()}SetFractalType(e){this._FractalType=e}SetFractalOctaves(e){this._Octaves=e,this._CalculateFractalBounding()}SetFractalLacunarity(e){this._Lacunarity=e}SetFractalGain(e){this._Gain=e,this._CalculateFractalBounding()}SetFractalWeightedStrength(e){this._WeightedStrength=e}SetFractalPingPongStrength(e){this._PingPongStrength=e}SetCellularDistanceFunction(e){this._CellularDistanceFunction=e}SetCellularReturnType(e){this._CellularReturnType=e}SetCellularJitter(e){this._CellularJitterModifier=e}SetDomainWarpType(e){this._DomainWarpType=e,this._UpdateWarpTransformType3D()}SetDomainWarpAmp(e){this._DomainWarpAmp=e}GetNoise(e,t,i){let s=(e,t)=>{switch(e*=this._Frequency,t*=this._Frequency,this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:let i=(e+t)*(.5*(1.7320508075688772-1));e+=i,t+=i}switch(this._FractalType){default:return this._GenNoiseSingleR2(this._Seed,e,t);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR2(e,t);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR2(e,t);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR2(e,t)}},a=(e,t,i)=>{switch(e*=this._Frequency,t*=this._Frequency,i*=this._Frequency,this._TransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let s=e+t,a=-.211324865405187*s;e+=a-(i*=.577350269189626),t+=a-i,i+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let s=e+i,a=-.211324865405187*s;e+=a-(t*=.577350269189626),i+=a-t,t+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let s=(e+t+i)*(2/3);e=s-e,t=s-t,i=s-i}switch(this._FractalType){default:return this._GenNoiseSingleR3(this._Seed,e,t,i);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR3(e,t,i);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR3(e,t,i);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR3(e,t,i)}};return 2===arguments.length?s(e,t):3===arguments.length?a(e,t,i):void 0}DomainWrap(e){switch(this._FractalType){default:this._DomainWarpSingle(e);break;case FastNoiseLite.FractalType.DomainWarpProgressive:this._DomainWarpFractalProgressive(e);break;case FastNoiseLite.FractalType.DomainWarpIndependent:this._DomainWarpFractalIndependent(e)}}_Gradients2D=[.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.38268343236509,.923879532511287,.923879532511287,.38268343236509,.923879532511287,-.38268343236509,.38268343236509,-.923879532511287,-.38268343236509,-.923879532511287,-.923879532511287,-.38268343236509,-.923879532511287,.38268343236509,-.38268343236509,.923879532511287];_RandVecs2D=[-.2700222198,-.9628540911,.3863092627,-.9223693152,.04444859006,-.999011673,-.5992523158,-.8005602176,-.7819280288,.6233687174,.9464672271,.3227999196,-.6514146797,-.7587218957,.9378472289,.347048376,-.8497875957,-.5271252623,-.879042592,.4767432447,-.892300288,-.4514423508,-.379844434,-.9250503802,-.9951650832,.0982163789,.7724397808,-.6350880136,.7573283322,-.6530343002,-.9928004525,-.119780055,-.0532665713,.9985803285,.9754253726,-.2203300762,-.7665018163,.6422421394,.991636706,.1290606184,-.994696838,.1028503788,-.5379205513,-.84299554,.5022815471,-.8647041387,.4559821461,-.8899889226,-.8659131224,-.5001944266,.0879458407,-.9961252577,-.5051684983,.8630207346,.7753185226,-.6315704146,-.6921944612,.7217110418,-.5191659449,-.8546734591,.8978622882,-.4402764035,-.1706774107,.9853269617,-.9353430106,-.3537420705,-.9992404798,.03896746794,-.2882064021,-.9575683108,-.9663811329,.2571137995,-.8759714238,-.4823630009,-.8303123018,-.5572983775,.05110133755,-.9986934731,-.8558373281,-.5172450752,.09887025282,.9951003332,.9189016087,.3944867976,-.2439375892,-.9697909324,-.8121409387,-.5834613061,-.9910431363,.1335421355,.8492423985,-.5280031709,-.9717838994,-.2358729591,.9949457207,.1004142068,.6241065508,-.7813392434,.662910307,.7486988212,-.7197418176,.6942418282,-.8143370775,-.5803922158,.104521054,-.9945226741,-.1065926113,-.9943027784,.445799684,-.8951327509,.105547406,.9944142724,-.992790267,.1198644477,-.8334366408,.552615025,.9115561563,-.4111755999,.8285544909,-.5599084351,.7217097654,-.6921957921,.4940492677,-.8694339084,-.3652321272,-.9309164803,-.9696606758,.2444548501,.08925509731,-.996008799,.5354071276,-.8445941083,-.1053576186,.9944343981,-.9890284586,.1477251101,.004856104961,.9999882091,.9885598478,.1508291331,.9286129562,-.3710498316,-.5832393863,-.8123003252,.3015207509,.9534596146,-.9575110528,.2883965738,.9715802154,-.2367105511,.229981792,.9731949318,.955763816,-.2941352207,.740956116,.6715534485,-.9971513787,-.07542630764,.6905710663,-.7232645452,-.290713703,-.9568100872,.5912777791,-.8064679708,-.9454592212,-.325740481,.6664455681,.74555369,.6236134912,.7817328275,.9126993851,-.4086316587,-.8191762011,.5735419353,-.8812745759,-.4726046147,.9953313627,.09651672651,.9855650846,-.1692969699,-.8495980887,.5274306472,.6174853946,-.7865823463,.8508156371,.52546432,.9985032451,-.05469249926,.1971371563,-.9803759185,.6607855748,-.7505747292,-.03097494063,.9995201614,-.6731660801,.739491331,-.7195018362,-.6944905383,.9727511689,.2318515979,.9997059088,-.0242506907,.4421787429,-.8969269532,.9981350961,-.061043673,-.9173660799,-.3980445648,-.8150056635,-.5794529907,-.8789331304,.4769450202,.0158605829,.999874213,-.8095464474,.5870558317,-.9165898907,-.3998286786,-.8023542565,.5968480938,-.5176737917,.8555780767,-.8154407307,-.5788405779,.4022010347,-.9155513791,-.9052556868,-.4248672045,.7317445619,.6815789728,-.5647632201,-.8252529947,-.8403276335,-.5420788397,-.9314281527,.363925262,.5238198472,.8518290719,.7432803869,-.6689800195,-.985371561,-.1704197369,.4601468731,.88784281,.825855404,.5638819483,.6182366099,.7859920446,.8331502863,-.553046653,.1500307506,.9886813308,-.662330369,-.7492119075,-.668598664,.743623444,.7025606278,.7116238924,-.5419389763,-.8404178401,-.3388616456,.9408362159,.8331530315,.5530425174,-.2989720662,-.9542618632,.2638522993,.9645630949,.124108739,-.9922686234,-.7282649308,-.6852956957,.6962500149,.7177993569,-.9183535368,.3957610156,-.6326102274,-.7744703352,-.9331891859,-.359385508,-.1153779357,-.9933216659,.9514974788,-.3076565421,-.08987977445,-.9959526224,.6678496916,.7442961705,.7952400393,-.6062947138,-.6462007402,-.7631674805,-.2733598753,.9619118351,.9669590226,-.254931851,-.9792894595,.2024651934,-.5369502995,-.8436138784,-.270036471,-.9628500944,-.6400277131,.7683518247,-.7854537493,-.6189203566,.06005905383,-.9981948257,-.02455770378,.9996984141,-.65983623,.751409442,-.6253894466,-.7803127835,-.6210408851,-.7837781695,.8348888491,.5504185768,-.1592275245,.9872419133,.8367622488,.5475663786,-.8675753916,-.4973056806,-.2022662628,-.9793305667,.9399189937,.3413975472,.9877404807,-.1561049093,-.9034455656,.4287028224,.1269804218,-.9919052235,-.3819600854,.924178821,.9754625894,.2201652486,-.3204015856,-.9472818081,-.9874760884,.1577687387,.02535348474,-.9996785487,.4835130794,-.8753371362,-.2850799925,-.9585037287,-.06805516006,-.99768156,-.7885244045,-.6150034663,.3185392127,-.9479096845,.8880043089,.4598351306,.6476921488,-.7619021462,.9820241299,.1887554194,.9357275128,-.3527237187,-.8894895414,.4569555293,.7922791302,.6101588153,.7483818261,.6632681526,-.7288929755,-.6846276581,.8729032783,-.4878932944,.8288345784,.5594937369,.08074567077,.9967347374,.9799148216,-.1994165048,-.580730673,-.8140957471,-.4700049791,-.8826637636,.2409492979,.9705377045,.9437816757,-.3305694308,-.8927998638,-.4504535528,-.8069622304,.5906030467,.06258973166,.9980393407,-.9312597469,.3643559849,.5777449785,.8162173362,-.3360095855,-.941858566,.697932075,-.7161639607,-.002008157227,-.9999979837,-.1827294312,-.9831632392,-.6523911722,.7578824173,-.4302626911,-.9027037258,-.9985126289,-.05452091251,-.01028102172,-.9999471489,-.4946071129,.8691166802,-.2999350194,.9539596344,.8165471961,.5772786819,.2697460475,.962931498,-.7306287391,-.6827749597,-.7590952064,-.6509796216,-.907053853,.4210146171,-.5104861064,-.8598860013,.8613350597,.5080373165,.5007881595,-.8655698812,-.654158152,.7563577938,-.8382755311,-.545246856,.6940070834,.7199681717,.06950936031,.9975812994,.1702942185,-.9853932612,.2695973274,.9629731466,.5519612192,-.8338697815,.225657487,-.9742067022,.4215262855,-.9068161835,.4881873305,-.8727388672,-.3683854996,-.9296731273,-.9825390578,.1860564427,.81256471,.5828709909,.3196460933,-.9475370046,.9570913859,.2897862643,-.6876655497,-.7260276109,-.9988770922,-.047376731,-.1250179027,.992154486,-.8280133617,.560708367,.9324863769,-.3612051451,.6394653183,.7688199442,-.01623847064,-.9998681473,-.9955014666,-.09474613458,-.81453315,.580117012,.4037327978,-.9148769469,.9944263371,.1054336766,-.1624711654,.9867132919,-.9949487814,-.100383875,-.6995302564,.7146029809,.5263414922,-.85027327,-.5395221479,.841971408,.6579370318,.7530729462,.01426758847,-.9998982128,-.6734383991,.7392433447,.639412098,-.7688642071,.9211571421,.3891908523,-.146637214,-.9891903394,-.782318098,.6228791163,-.5039610839,-.8637263605,-.7743120191,-.6328039957];_Gradients3D=[0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,1,1,0,0,0,-1,1,0,-1,1,0,0,0,-1,-1,0];_RandVecs3D=[-.7292736885,-.6618439697,.1735581948,0,.790292081,-.5480887466,-.2739291014,0,.7217578935,.6226212466,-.3023380997,0,.565683137,-.8208298145,-.0790000257,0,.760049034,-.5555979497,-.3370999617,0,.3713945616,.5011264475,.7816254623,0,-.1277062463,-.4254438999,-.8959289049,0,-.2881560924,-.5815838982,.7607405838,0,.5849561111,-.662820239,-.4674352136,0,.3307171178,.0391653737,.94291689,0,.8712121778,-.4113374369,-.2679381538,0,.580981015,.7021915846,.4115677815,0,.503756873,.6330056931,-.5878203852,0,.4493712205,.601390195,.6606022552,0,-.6878403724,.09018890807,-.7202371714,0,-.5958956522,-.6469350577,.475797649,0,-.5127052122,.1946921978,-.8361987284,0,-.9911507142,-.05410276466,-.1212153153,0,-.2149721042,.9720882117,-.09397607749,0,-.7518650936,-.5428057603,.3742469607,0,.5237068895,.8516377189,-.02107817834,0,.6333504779,.1926167129,-.7495104896,0,-.06788241606,.3998305789,.9140719259,0,-.5538628599,-.4729896695,-.6852128902,0,-.7261455366,-.5911990757,.3509933228,0,-.9229274737,-.1782808786,.3412049336,0,-.6968815002,.6511274338,.3006480328,0,.9608044783,-.2098363234,-.1811724921,0,.06817146062,-.9743405129,.2145069156,0,-.3577285196,-.6697087264,-.6507845481,0,-.1868621131,.7648617052,-.6164974636,0,-.6541697588,.3967914832,.6439087246,0,.6993340405,-.6164538506,.3618239211,0,-.1546665739,.6291283928,.7617583057,0,-.6841612949,-.2580482182,-.6821542638,0,.5383980957,.4258654885,.7271630328,0,-.5026987823,-.7939832935,-.3418836993,0,.3202971715,.2834415347,.9039195862,0,.8683227101,-.0003762656404,-.4959995258,0,.791120031,-.08511045745,.6057105799,0,-.04011016052,-.4397248749,.8972364289,0,.9145119872,.3579346169,-.1885487608,0,-.9612039066,-.2756484276,.01024666929,0,.6510361721,-.2877799159,-.7023778346,0,-.2041786351,.7365237271,.644859585,0,-.7718263711,.3790626912,.5104855816,0,-.3060082741,-.7692987727,.5608371729,0,.454007341,-.5024843065,.7357899537,0,.4816795475,.6021208291,-.6367380315,0,.6961980369,-.3222197429,.641469197,0,-.6532160499,-.6781148932,.3368515753,0,.5089301236,-.6154662304,-.6018234363,0,-.1635919754,-.9133604627,-.372840892,0,.52408019,-.8437664109,.1157505864,0,.5902587356,.4983817807,-.6349883666,0,.5863227872,.494764745,.6414307729,0,.6779335087,.2341345225,.6968408593,0,.7177054546,-.6858979348,.120178631,0,-.5328819713,-.5205125012,.6671608058,0,-.8654874251,-.0700727088,-.4960053754,0,-.2861810166,.7952089234,.5345495242,0,-.04849529634,.9810836427,-.1874115585,0,-.6358521667,.6058348682,.4781800233,0,.6254794696,-.2861619734,.7258696564,0,-.2585259868,.5061949264,-.8227581726,0,.02136306781,.5064016808,-.8620330371,0,.200111773,.8599263484,.4695550591,0,.4743561372,.6014985084,-.6427953014,0,.6622993731,-.5202474575,-.5391679918,0,.08084972818,-.6532720452,.7527940996,0,-.6893687501,.0592860349,.7219805347,0,-.1121887082,-.9673185067,.2273952515,0,.7344116094,.5979668656,-.3210532909,0,.5789393465,-.2488849713,.7764570201,0,.6988182827,.3557169806,-.6205791146,0,-.8636845529,-.2748771249,-.4224826141,0,-.4247027957,-.4640880967,.777335046,0,.5257722489,-.8427017621,.1158329937,0,.9343830603,.316302472,-.1639543925,0,-.1016836419,-.8057303073,-.5834887393,0,-.6529238969,.50602126,-.5635892736,0,-.2465286165,-.9668205684,-.06694497494,0,-.9776897119,-.2099250524,-.007368825344,0,.7736893337,.5734244712,.2694238123,0,-.6095087895,.4995678998,.6155736747,0,.5794535482,.7434546771,.3339292269,0,-.8226211154,.08142581855,.5627293636,0,-.510385483,.4703667658,.7199039967,0,-.5764971849,-.07231656274,-.8138926898,0,.7250628871,.3949971505,-.5641463116,0,-.1525424005,.4860840828,-.8604958341,0,-.5550976208,-.4957820792,.667882296,0,-.1883614327,.9145869398,.357841725,0,.7625556724,-.5414408243,-.3540489801,0,-.5870231946,-.3226498013,-.7424963803,0,.3051124198,.2262544068,-.9250488391,0,.6379576059,.577242424,-.5097070502,0,-.5966775796,.1454852398,-.7891830656,0,-.658330573,.6555487542,-.3699414651,0,.7434892426,.2351084581,.6260573129,0,.5562114096,.8264360377,-.0873632843,0,-.3028940016,-.8251527185,.4768419182,0,.1129343818,-.985888439,-.1235710781,0,.5937652891,-.5896813806,.5474656618,0,.6757964092,-.5835758614,-.4502648413,0,.7242302609,-.1152719764,.6798550586,0,-.9511914166,.0753623979,-.2992580792,0,.2539470961,-.1886339355,.9486454084,0,.571433621,-.1679450851,-.8032795685,0,-.06778234979,.3978269256,.9149531629,0,.6074972649,.733060024,-.3058922593,0,-.5435478392,.1675822484,.8224791405,0,-.5876678086,-.3380045064,-.7351186982,0,-.7967562402,.04097822706,-.6029098428,0,-.1996350917,.8706294745,.4496111079,0,-.02787660336,-.9106232682,-.4122962022,0,-.7797625996,-.6257634692,.01975775581,0,-.5211232846,.7401644346,-.4249554471,0,.8575424857,.4053272873,-.3167501783,0,.1045223322,.8390195772,-.5339674439,0,.3501822831,.9242524096,-.1520850155,0,.1987849858,.07647613266,.9770547224,0,.7845996363,.6066256811,-.1280964233,0,.09006737436,-.9750989929,-.2026569073,0,-.8274343547,-.542299559,.1458203587,0,-.3485797732,-.415802277,.840000362,0,-.2471778936,-.7304819962,-.6366310879,0,-.3700154943,.8577948156,.3567584454,0,.5913394901,-.548311967,-.5913303597,0,.1204873514,-.7626472379,-.6354935001,0,.616959265,.03079647928,.7863922953,0,.1258156836,-.6640829889,-.7369967419,0,-.6477565124,-.1740147258,-.7417077429,0,.6217889313,-.7804430448,-.06547655076,0,.6589943422,-.6096987708,.4404473475,0,-.2689837504,-.6732403169,-.6887635427,0,-.3849775103,.5676542638,.7277093879,0,.5754444408,.8110471154,-.1051963504,0,.9141593684,.3832947817,.131900567,0,-.107925319,.9245493968,.3654593525,0,.377977089,.3043148782,.8743716458,0,-.2142885215,-.8259286236,.5214617324,0,.5802544474,.4148098596,-.7008834116,0,-.1982660881,.8567161266,-.4761596756,0,-.03381553704,.3773180787,-.9254661404,0,-.6867922841,-.6656597827,.2919133642,0,.7731742607,-.2875793547,-.5652430251,0,-.09655941928,.9193708367,-.3813575004,0,.2715702457,-.9577909544,-.09426605581,0,.2451015704,-.6917998565,-.6792188003,0,.977700782,-.1753855374,.1155036542,0,-.5224739938,.8521606816,.02903615945,0,-.7734880599,-.5261292347,.3534179531,0,-.7134492443,-.269547243,.6467878011,0,.1644037271,.5105846203,-.8439637196,0,.6494635788,.05585611296,.7583384168,0,-.4711970882,.5017280509,-.7254255765,0,-.6335764307,-.2381686273,-.7361091029,0,-.9021533097,-.270947803,-.3357181763,0,-.3793711033,.872258117,.3086152025,0,-.6855598966,-.3250143309,.6514394162,0,.2900942212,-.7799057743,-.5546100667,0,-.2098319339,.85037073,.4825351604,0,-.4592603758,.6598504336,-.5947077538,0,.8715945488,.09616365406,-.4807031248,0,-.6776666319,.7118504878,-.1844907016,0,.7044377633,.312427597,.637304036,0,-.7052318886,-.2401093292,-.6670798253,0,.081921007,-.7207336136,-.6883545647,0,-.6993680906,-.5875763221,-.4069869034,0,-.1281454481,.6419895885,.7559286424,0,-.6337388239,-.6785471501,-.3714146849,0,.5565051903,-.2168887573,-.8020356851,0,-.5791554484,.7244372011,-.3738578718,0,.1175779076,-.7096451073,.6946792478,0,-.6134619607,.1323631078,.7785527795,0,.6984635305,-.02980516237,-.715024719,0,.8318082963,-.3930171956,.3919597455,0,.1469576422,.05541651717,-.9875892167,0,.708868575,-.2690503865,.6520101478,0,.2726053183,.67369766,-.68688995,0,-.6591295371,.3035458599,-.6880466294,0,.4815131379,-.7528270071,.4487723203,0,.9430009463,.1675647412,-.2875261255,0,.434802957,.7695304522,-.4677277752,0,.3931996188,.594473625,.7014236729,0,.7254336655,-.603925654,.3301814672,0,.7590235227,-.6506083235,.02433313207,0,-.8552768592,-.3430042733,.3883935666,0,-.6139746835,.6981725247,.3682257648,0,-.7465905486,-.5752009504,.3342849376,0,.5730065677,.810555537,-.1210916791,0,-.9225877367,-.3475211012,-.167514036,0,-.7105816789,-.4719692027,-.5218416899,0,-.08564609717,.3583001386,.929669703,0,-.8279697606,-.2043157126,.5222271202,0,.427944023,.278165994,.8599346446,0,.5399079671,-.7857120652,-.3019204161,0,.5678404253,-.5495413974,-.6128307303,0,-.9896071041,.1365639107,-.04503418428,0,-.6154342638,-.6440875597,.4543037336,0,.1074204368,-.7946340692,.5975094525,0,-.3595449969,-.8885529948,.28495784,0,-.2180405296,.1529888965,.9638738118,0,-.7277432317,-.6164050508,-.3007234646,0,.7249729114,-.00669719484,.6887448187,0,-.5553659455,-.5336586252,.6377908264,0,.5137558015,.7976208196,-.3160000073,0,-.3794024848,.9245608561,-.03522751494,0,.8229248658,.2745365933,-.4974176556,0,-.5404114394,.6091141441,.5804613989,0,.8036581901,-.2703029469,.5301601931,0,.6044318879,.6832968393,.4095943388,0,.06389988817,.9658208605,-.2512108074,0,.1087113286,.7402471173,-.6634877936,0,-.713427712,-.6926784018,.1059128479,0,.6458897819,-.5724548511,-.5050958653,0,-.6553931414,.7381471625,.159995615,0,.3910961323,.9188871375,-.05186755998,0,-.4879022471,-.5904376907,.6429111375,0,.6014790094,.7707441366,-.2101820095,0,-.5677173047,.7511360995,.3368851762,0,.7858573506,.226674665,.5753666838,0,-.4520345543,-.604222686,-.6561857263,0,.002272116345,.4132844051,-.9105991643,0,-.5815751419,-.5162925989,.6286591339,0,-.03703704785,.8273785755,.5604221175,0,-.5119692504,.7953543429,-.3244980058,0,-.2682417366,-.9572290247,-.1084387619,0,-.2322482736,-.9679131102,-.09594243324,0,.3554328906,-.8881505545,.2913006227,0,.7346520519,-.4371373164,.5188422971,0,.9985120116,.04659011161,-.02833944577,0,-.3727687496,-.9082481361,.1900757285,0,.91737377,-.3483642108,.1925298489,0,.2714911074,.4147529736,-.8684886582,0,.5131763485,-.7116334161,.4798207128,0,-.8737353606,.18886992,-.4482350644,0,.8460043821,-.3725217914,.3814499973,0,.8978727456,-.1780209141,-.4026575304,0,.2178065647,-.9698322841,-.1094789531,0,-.1518031304,-.7788918132,-.6085091231,0,-.2600384876,-.4755398075,-.8403819825,0,.572313509,-.7474340931,-.3373418503,0,-.7174141009,.1699017182,-.6756111411,0,-.684180784,.02145707593,-.7289967412,0,-.2007447902,.06555605789,-.9774476623,0,-.1148803697,-.8044887315,.5827524187,0,-.7870349638,.03447489231,.6159443543,0,-.2015596421,.6859872284,.6991389226,0,-.08581082512,-.10920836,-.9903080513,0,.5532693395,.7325250401,-.396610771,0,-.1842489331,-.9777375055,-.1004076743,0,.0775473789,-.9111505856,.4047110257,0,.1399838409,.7601631212,-.6344734459,0,.4484419361,-.845289248,.2904925424,0];_PrimeX=501125321;_PrimeY=1136930381;_PrimeZ=1720413743;static _Lerp(e,t,i){return e+i*(t-e)}static _InterpHermite(e){return e*e*(3-2*e)}static _InterpQuintic(e){return e*e*e*(e*(6*e-15)+10)}static _CubicLerp(e,t,i,s,a){let r=s-i-(e-t);return a*a*a*r+a*a*(e-t-r)+a*(i-e)+t}static _PingPong(e){return(e-=2*Math.trunc(.5*e))<1?e:2-e}_CalculateFractalBounding(){let e=Math.abs(this._Gain),t=e,i=1;for(let s=1;s>15,r&=254,s*this._Gradients2D[r]+a*this._Gradients2D[1|r]}_GradCoordR3(e,t,i,s,a,r,o){let l=this._HashR3(e,t,i,s);return l^=l>>15,l&=252,a*this._Gradients3D[l]+r*this._Gradients3D[1|l]+o*this._Gradients3D[2|l]}_GenNoiseSingleR2(e,t,i){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R2(e,t,i);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR2(e,t,i);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR2(e,t,i);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR2(e,t,i);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR2(e,t,i);case FastNoiseLite.NoiseType.Value:return this._SingleValueR2(e,t,i);default:return 0}}_GenNoiseSingleR3(e,t,i,s){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R3(e,t,i,s);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR3(e,t,i,s);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR3(e,t,i,s);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR3(e,t,i,s);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR3(e,t,i,s);case FastNoiseLite.NoiseType.Value:return this._SingleValueR3(e,t,i,s);default:return 0}}_UpdateTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:this._TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._TransformType3D=FastNoiseLite.TransformType3D.None}}}_UpdateWarpTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._WarpTransformType3D=FastNoiseLite.TransformType3D.None}}}_GenFractalFBmR2(e,t){let i=this._Seed,s=0,a=this._FractalBounding;for(let r=0;rp){let t=p+s,i=d+(s-1),a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l,h+this._PrimeY,t,i)}else{let t=p+(s-1),i=d+s,a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l+this._PrimeX,h,t,i)}return 99.83685446303647*(a+r+o)}_SingleOpenSimplex2R3(e,t,i,s){let a=Math.round(t),r=Math.round(i),o=Math.round(s),l=t-a,h=i-r,n=s-o,_=Math.trunc(-1-h|1),c=Math.trunc(-1-l|1),p=Math.trunc(-1-n|1),d=c*-l,m=_*-h,u=p*-n;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let R=0,L=.6-l*l-(h*h+n*n);for(let t=0;;t++){if(L>0&&(R+=L*L*(L*L)*this._GradCoordR3(e,a,r,o,l,h,n)),d>=m&&d>=u){let t=L+d+d;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a-c*this._PrimeX,r,o,l+c,h,n))}else if(m>d&&m>=u){let t=L+m+m;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r-_*this._PrimeY,o,l,h+_,n))}else{let t=L+u+u;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r,o-p*this._PrimeZ,l,h,n+p))}if(1===t)break;d=.5-d,m=.5-m,u=.5-u,l=c*d,h=_*m,n=p*u,L+=.75-d-(m+u),a+=c>>1&this._PrimeX,r+=_>>1&this._PrimeY,o+=p>>1&this._PrimeZ,c=-c,_=-_,p=-p,e=~e}return 32.69428253173828*R}_SingleOpenSimplex2SR2(e,t,i){const s=.21132486540518713;let a=Math.floor(t),r=Math.floor(i),o=t-a,l=i-r;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY);let h=a+this._PrimeX,n=r+this._PrimeY,_=(o+l)*s,c=o-_,p=l-_,d=2/3-c*c-p*p,m=d*d*(d*d)*this._GradCoordR2(e,a,r,c,p),u=3.1547005383792506*_+(-.6666666666666666+d),R=c-(1-2*s),L=p-(1-2*s);m+=u*u*(u*u)*this._GradCoordR2(e,h,n,R,L);let F=o-l;if(_>s){if(o+F>1){let t=c+(3*s-2),i=p+(3*s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+(this._PrimeX<<1),r+this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}if(l-F>1){let t=c+(3*s-1),i=p+(3*s-2),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r+(this._PrimeY<<1),t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}}else{if(o+F<0){let t=c+(1-s),i=p-s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a-this._PrimeX,r,t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}if(l0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r-this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}}return 18.24196194486065*m}_SingleOpenSimplex2SR3(e,t,i,s){let a=Math.floor(t),r=Math.floor(i),o=Math.floor(s),l=t-a,h=i-r,n=s-o;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let _=e+1293373,c=Math.trunc(-.5-l),p=Math.trunc(-.5-h),d=Math.trunc(-.5-n),m=l+c,u=h+p,R=n+d,L=.75-m*m-u*u-R*R,F=L*L*(L*L)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),m,u,R),D=l-.5,C=h-.5,N=n-.5,P=.75-D*D-C*C-N*N;F+=P*P*(P*P)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+this._PrimeZ,D,C,N);let V=((1|c)<<1)*D,y=((1|p)<<1)*C,T=((1|d)<<1)*N,f=(-2-(c<<2))*D-1,S=(-2-(p<<2))*C-1,g=(-2-(d<<2))*N-1,M=!1,G=V+L;if(G>0){let t=m-(1|c);F+=G*G*(G*G)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),t,u,R)}else{let t=y+T+L;if(t>0){let i=m,s=u-(1|p),l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=f+P;if(i>0){let e=(1|c)+D;F+=i*i*(i*i)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+this._PrimeZ,e,C,N),M=!0}}let b=!1,X=y+L;if(X>0){let t=m,i=u-(1|p);F+=X*X*(X*X)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),t,i,R)}else{let t=V+T+L;if(t>0){let i=m-(1|c),s=u,l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=S+P;if(i>0){let e=D,t=(1|p)+C;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+this._PrimeZ,e,t,N),b=!0}}let W=!1,Y=T+L;if(Y>0){let t=m,i=u,s=R-(1|d);F+=Y*Y*(Y*Y)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),t,i,s)}else{let t=V+y+L;if(t>0){let i=m-(1|c),s=u-(1|p);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),i,s,R)}let i=g+P;if(i>0){let e=D,t=C,s=(1|d)+N;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+(d&this._PrimeZ<<1),e,t,s),W=!0}}if(!M){let e=S+g+P;if(e>0){let t=D,i=(1|p)+C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+(d&this._PrimeZ<<1),t,i,s)}}if(!b){let e=f+g+P;if(e>0){let t=(1|c)+D,i=C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+(d&this._PrimeZ<<1),t,i,s)}}if(!W){let e=f+S+P;if(e>0){let t=(1|c)+D,i=(1|p)+C;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&this._PrimeX<<1),r+(p&this._PrimeY<<1),o+this._PrimeZ,t,i,N)}}return 9.046026385208288*F}_SingleCellularR2(e,t,i){let s=Math.round(t),a=Math.round(i),r=Number.MAX_VALUE,o=Number.MAX_VALUE,l=0,h=.43701595*this._CellularJitterModifier,n=(s-1)*this._PrimeX,_=(a-1)*this._PrimeY;switch(this._CellularDistanceFunction){default:case FastNoiseLite.CellularDistanceFunction.Euclidean:case FastNoiseLite.CellularDistanceFunction.EuclideanSq:for(let c=s-1;c<=s+1;c++){let s=_;for(let _=a-1;_<=a+1;_++){let a=this._HashR2(e,n,s),p=510&a,d=c-t+this._RandVecs2D[p]*h,m=_-i+this._RandVecs2D[1|p]*h,u=d*d+m*m;o=Math.max(Math.min(o,u),r),u{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,32.69428253173828*t,i,s,!1,a,r,o);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,7.71604938271605*t,i,s,!0,a,r,o);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r,o)}};return 6===arguments.length&&arguments[3]instanceof Vector2?((e,t,i,s,a,r)=>{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,38.283687591552734*t,i,s,!1,a,r);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,16*t,i,s,!0,a,r);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r)}})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]):7===arguments.length&&arguments[3]instanceof Vector3?e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]):void 0}_DomainWarpSingle(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y,o=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=a+r,t=-.211324865405187*e;o*=.577350269189626,a+=t-o,r=r+t-o,o+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=a+o,t=-.211324865405187*e;r*=.577350269189626,a+=t-r,o+=t-r,r+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let e=(a+r+o)*(2/3);a=e-a,r=e-r,o=e-o}this._DoSingleDomainWarp(t,i,s,e,a,r,o)};return 1===arguments.length&&arguments[0]instanceof Vector2?(e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(a+r)*(.5*(1.7320508075688772-1));a+=e,r+=e}this._DoSingleDomainWarp(t,i,s,e,a,r)})(arguments[0]):1===arguments.length&&arguments[0]instanceof Vector3?e(arguments[0]):void 0}_DomainWarpFractalProgressive(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=e.x,i=e.y,s=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=t+i,a=-.211324865405187*e;s*=.577350269189626,t+=a-s,i=i+a-s,s+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=t+s,a=-.211324865405187*e;i*=.577350269189626,t+=a-i,s+=a-i,i+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:{let e=(t+i+s)*(2/3);t=e-t,i=e-i,s=e-s}}let a=this._Seed,r=this._DomainWarpAmp*this._FractalBounding,o=this._Frequency;for(let l=0;l{let t=e.x,i=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(t+i)*(.5*(1.7320508075688772-1));t+=e,i+=e}let s=this._Seed,a=this._DomainWarpAmp*this._FractalBounding,r=this._Frequency;for(let o=0;o{let l=a*i,h=r*i,n=o*i,_=Math.floor(l),c=Math.floor(h),p=Math.floor(n),d=FastNoiseLite._InterpHermite(l-_),m=FastNoiseLite._InterpHermite(h-c),u=FastNoiseLite._InterpHermite(n-p);_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),p=Math.imul(p,this._PrimeZ);let R=_+this._PrimeX,L=c+this._PrimeY,F=p+this._PrimeZ,D=1020&this._HashR3(e,_,c,p),C=1020&this._HashR3(e,R,c,p),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d);D=1020&this._HashR3(e,_,L,p),C=1020&this._HashR3(e,R,L,p);let y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),S=FastNoiseLite._Lerp(N,y,m),g=FastNoiseLite._Lerp(P,T,m),M=FastNoiseLite._Lerp(V,f,m);D=1020&this._HashR3(e,_,c,F),C=1020&this._HashR3(e,R,c,F),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),D=1020&this._HashR3(e,_,L,F),C=1020&this._HashR3(e,R,L,F),y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),s.x+=FastNoiseLite._Lerp(S,FastNoiseLite._Lerp(N,y,m),u)*t,s.y+=FastNoiseLite._Lerp(g,FastNoiseLite._Lerp(P,T,m),u)*t,s.z+=FastNoiseLite._Lerp(M,FastNoiseLite._Lerp(V,f,m),u)*t};6===arguments.length&&arguments[3]instanceof Vector2&&((e,t,i,s,a,r)=>{let o=a*i,l=r*i,h=Math.floor(o),n=Math.floor(l),_=FastNoiseLite._InterpHermite(o-h),c=FastNoiseLite._InterpHermite(l-n);h=Math.imul(h,this._PrimeX),n=Math.imul(n,this._PrimeY);let p=h+this._PrimeX,d=n+this._PrimeY,m=510&this._HashR2(e,h,n),u=510&this._HashR2(e,p,n),R=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),L=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);m=510&this._HashR2(e,h,d),u=510&this._HashR2(e,p,d);let F=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),D=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);s.x+=FastNoiseLite._Lerp(R,F,c)*t,s.y+=FastNoiseLite._Lerp(L,D,c)*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]),7===arguments.length&&arguments[3]instanceof Vector3&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6])}_SingleDomainWarpOpenSimplex2Gradient(){let e=(e,t,i,s,a,r,o,l)=>{r*=i,o*=i,l*=i;let h,n,_,c=Math.round(r),p=Math.round(o),d=Math.round(l),m=r-c,u=o-p,R=l-d,L=-m-1|1,F=-u-1|1,D=-R-1|1,C=L*-m,N=F*-u,P=D*-R;c=Math.imul(c,this._PrimeX),p=Math.imul(p,this._PrimeY),d=Math.imul(d,this._PrimeZ),h=n=_=0;let V=.6-m*m-(u*u+R*R);for(let t=0;;t++){if(V>0){let t,i,s,r=V*V*(V*V);if(a){let a=1020&this._HashR3(e,c,p,d);t=this._RandVecs3D[a],i=this._RandVecs3D[1|a],s=this._RandVecs3D[2|a]}else{let a=this._HashR3(e,c,p,d),r=252&a,o=a>>6&1020,l=m*this._Gradients3D[r]+u*this._Gradients3D[1|r]+R*this._Gradients3D[2|r];t=l*this._RandVecs3D[o],i=l*this._RandVecs3D[1|o],s=l*this._RandVecs3D[2|o]}h+=r*t,n+=r*i,_+=r*s}let i=V,s=c,r=p,o=d,l=m,y=u,T=R;if(C>=N&&C>=P?(l+=L,i=i+C+C,s-=L*this._PrimeX):N>C&&N>=P?(y+=F,i=i+N+N,r-=F*this._PrimeY):(T+=D,i=i+P+P,o-=D*this._PrimeZ),i>1){i-=1;let t,c,p,d=i*i*(i*i);if(a){let i=1020&this._HashR3(e,s,r,o);t=this._RandVecs3D[i],c=this._RandVecs3D[1|i],p=this._RandVecs3D[2|i]}else{let i=this._HashR3(e,s,r,o),a=252&i,h=i>>6&1020,n=l*this._Gradients3D[a]+y*this._Gradients3D[1|a]+T*this._Gradients3D[2|a];t=n*this._RandVecs3D[h],c=n*this._RandVecs3D[1|h],p=n*this._RandVecs3D[2|h]}h+=d*t,n+=d*c,_+=d*p}if(1===t)break;C=.5-C,N=.5-N,P=.5-P,m=L*C,u=F*N,R=D*P,V+=.75-C-(N+P),c+=L>>1&this._PrimeX,p+=F>>1&this._PrimeY,d+=D>>1&this._PrimeZ,L=-L,F=-F,D=-D,e+=1293373}s.x+=h*t,s.y+=n*t,s.z+=_*t};7===arguments.length&&((e,t,i,s,a,r,o)=>{const l=.21132486540518713;r*=i,o*=i;let h,n,_=Math.floor(r),c=Math.floor(o),p=r-_,d=o-c,m=(p+d)*l,u=p-m,R=d-m;_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),h=n=0;let L=.5-u*u-R*R;if(L>0){let t,i,s=L*L*(L*L);if(a){let s=510&this._HashR2(e,_,c);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let s=this._HashR2(e,_,c),a=254&s,r=s>>7&510,o=u*this._Gradients2D[a]+R*this._Gradients2D[1|a];t=o*this._RandVecs2D[r],i=o*this._RandVecs2D[1|r]}h+=s*t,n+=s*i}let F=3.1547005383792506*m+(-.6666666666666666+L);if(F>0){let t,i,s=u+(2*l-1),r=R+(2*l-1),o=F*F*(F*F);if(a){let s=510&this._HashR2(e,_+this._PrimeX,c+this._PrimeY);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let a=this._HashR2(e,_+this._PrimeX,c+this._PrimeY),o=254&a,l=a>>7&510,h=s*this._Gradients2D[o]+r*this._Gradients2D[1|o];t=h*this._RandVecs2D[l],i=h*this._RandVecs2D[1|l]}h+=o*t,n+=o*i}if(R>u){let t=u+l,i=R+(l-1),s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_,c+this._PrimeY);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_,c+this._PrimeY),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}else{let t=u+(l-1),i=R+l,s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_+this._PrimeX,c);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_+this._PrimeX,c),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}s.x+=h*t,s.y+=n*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]),8===arguments.length&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7])}}class Vector2{constructor(e,t){this.x=e,this.y=t}}class Vector3{constructor(e,t,i){this.x=e,this.y=t,this.z=i}} + /* eslint-enable */ Scratch.extensions.register(new Noise()); })(Scratch); From 4a5e36295a7c6f7dd3afd9b26090a2a6b84e5fe1 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Wed, 25 Dec 2024 20:39:48 -0700 Subject: [PATCH 30/36] maybe? --- extensions/Corbnorb/noise.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 4fa5fabf5e..3f7dfa8ea7 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -236,9 +236,11 @@ // https://raw.githubusercontent.com/Auburn/FastNoiseLite/refs/heads/master/JavaScript/FastNoiseLite.js /* eslint-disable */ + /* prettier-disable */ // prettier-ignore class FastNoiseLite{static NoiseType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2S:"OpenSimplex2S",Cellular:"Cellular",Perlin:"Perlin",ValueCubic:"ValueCubic",Value:"Value"});static RotationType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes"});static FractalType=Object.freeze({None:"None",FBm:"FBm",Ridged:"Ridged",PingPong:"PingPong",DomainWarpProgressive:"DomainWarpProgressive",DomainWarpIndependent:"DomainWarpIndependent"});static CellularDistanceFunction=Object.freeze({Euclidean:"Euclidean",EuclideanSq:"EuclideanSq",Manhattan:"Manhattan",Hybrid:"Hybrid"});static CellularReturnType=Object.freeze({CellValue:"CellValue",Distance:"Distance",Distance2:"Distance2",Distance2Add:"Distance2Add",Distance2Sub:"Distance2Sub",Distance2Mul:"Distance2Mul",Distance2Div:"Distance2Div"});static DomainWarpType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2Reduced:"OpenSimplex2Reduced",BasicGrid:"BasicGrid"});static TransformType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes",DefaultOpenSimplex2:"DefaultOpenSimplex2"});_Seed=1337;_Frequency=.01;_NoiseType=FastNoiseLite.NoiseType.OpenSimplex2;_RotationType3D=FastNoiseLite.RotationType3D.None;_TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;_DomainWarpAmp=1;_FractalType=FastNoiseLite.FractalType.None;_Octaves=3;_Lacunarity=2;_Gain=.5;_WeightedStrength=0;_PingPongStrength=2;_FractalBounding=1/1.75;_CellularDistanceFunction=FastNoiseLite.CellularDistanceFunction.EuclideanSq;_CellularReturnType=FastNoiseLite.CellularReturnType.Distance;_CellularJitterModifier=1;_DomainWarpType=FastNoiseLite.DomainWarpType.OpenSimplex2;_WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;constructor(e){void 0!==e&&(this._Seed=e)}SetSeed(e){this._Seed=e}SetFrequency(e){this._Frequency=e}SetNoiseType(e){this._NoiseType=e,this._UpdateTransformType3D()}SetRotationType3D(e){this._RotationType3D=e,this._UpdateTransformType3D(),this._UpdateWarpTransformType3D()}SetFractalType(e){this._FractalType=e}SetFractalOctaves(e){this._Octaves=e,this._CalculateFractalBounding()}SetFractalLacunarity(e){this._Lacunarity=e}SetFractalGain(e){this._Gain=e,this._CalculateFractalBounding()}SetFractalWeightedStrength(e){this._WeightedStrength=e}SetFractalPingPongStrength(e){this._PingPongStrength=e}SetCellularDistanceFunction(e){this._CellularDistanceFunction=e}SetCellularReturnType(e){this._CellularReturnType=e}SetCellularJitter(e){this._CellularJitterModifier=e}SetDomainWarpType(e){this._DomainWarpType=e,this._UpdateWarpTransformType3D()}SetDomainWarpAmp(e){this._DomainWarpAmp=e}GetNoise(e,t,i){let s=(e,t)=>{switch(e*=this._Frequency,t*=this._Frequency,this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:let i=(e+t)*(.5*(1.7320508075688772-1));e+=i,t+=i}switch(this._FractalType){default:return this._GenNoiseSingleR2(this._Seed,e,t);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR2(e,t);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR2(e,t);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR2(e,t)}},a=(e,t,i)=>{switch(e*=this._Frequency,t*=this._Frequency,i*=this._Frequency,this._TransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let s=e+t,a=-.211324865405187*s;e+=a-(i*=.577350269189626),t+=a-i,i+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let s=e+i,a=-.211324865405187*s;e+=a-(t*=.577350269189626),i+=a-t,t+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let s=(e+t+i)*(2/3);e=s-e,t=s-t,i=s-i}switch(this._FractalType){default:return this._GenNoiseSingleR3(this._Seed,e,t,i);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR3(e,t,i);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR3(e,t,i);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR3(e,t,i)}};return 2===arguments.length?s(e,t):3===arguments.length?a(e,t,i):void 0}DomainWrap(e){switch(this._FractalType){default:this._DomainWarpSingle(e);break;case FastNoiseLite.FractalType.DomainWarpProgressive:this._DomainWarpFractalProgressive(e);break;case FastNoiseLite.FractalType.DomainWarpIndependent:this._DomainWarpFractalIndependent(e)}}_Gradients2D=[.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.38268343236509,.923879532511287,.923879532511287,.38268343236509,.923879532511287,-.38268343236509,.38268343236509,-.923879532511287,-.38268343236509,-.923879532511287,-.923879532511287,-.38268343236509,-.923879532511287,.38268343236509,-.38268343236509,.923879532511287];_RandVecs2D=[-.2700222198,-.9628540911,.3863092627,-.9223693152,.04444859006,-.999011673,-.5992523158,-.8005602176,-.7819280288,.6233687174,.9464672271,.3227999196,-.6514146797,-.7587218957,.9378472289,.347048376,-.8497875957,-.5271252623,-.879042592,.4767432447,-.892300288,-.4514423508,-.379844434,-.9250503802,-.9951650832,.0982163789,.7724397808,-.6350880136,.7573283322,-.6530343002,-.9928004525,-.119780055,-.0532665713,.9985803285,.9754253726,-.2203300762,-.7665018163,.6422421394,.991636706,.1290606184,-.994696838,.1028503788,-.5379205513,-.84299554,.5022815471,-.8647041387,.4559821461,-.8899889226,-.8659131224,-.5001944266,.0879458407,-.9961252577,-.5051684983,.8630207346,.7753185226,-.6315704146,-.6921944612,.7217110418,-.5191659449,-.8546734591,.8978622882,-.4402764035,-.1706774107,.9853269617,-.9353430106,-.3537420705,-.9992404798,.03896746794,-.2882064021,-.9575683108,-.9663811329,.2571137995,-.8759714238,-.4823630009,-.8303123018,-.5572983775,.05110133755,-.9986934731,-.8558373281,-.5172450752,.09887025282,.9951003332,.9189016087,.3944867976,-.2439375892,-.9697909324,-.8121409387,-.5834613061,-.9910431363,.1335421355,.8492423985,-.5280031709,-.9717838994,-.2358729591,.9949457207,.1004142068,.6241065508,-.7813392434,.662910307,.7486988212,-.7197418176,.6942418282,-.8143370775,-.5803922158,.104521054,-.9945226741,-.1065926113,-.9943027784,.445799684,-.8951327509,.105547406,.9944142724,-.992790267,.1198644477,-.8334366408,.552615025,.9115561563,-.4111755999,.8285544909,-.5599084351,.7217097654,-.6921957921,.4940492677,-.8694339084,-.3652321272,-.9309164803,-.9696606758,.2444548501,.08925509731,-.996008799,.5354071276,-.8445941083,-.1053576186,.9944343981,-.9890284586,.1477251101,.004856104961,.9999882091,.9885598478,.1508291331,.9286129562,-.3710498316,-.5832393863,-.8123003252,.3015207509,.9534596146,-.9575110528,.2883965738,.9715802154,-.2367105511,.229981792,.9731949318,.955763816,-.2941352207,.740956116,.6715534485,-.9971513787,-.07542630764,.6905710663,-.7232645452,-.290713703,-.9568100872,.5912777791,-.8064679708,-.9454592212,-.325740481,.6664455681,.74555369,.6236134912,.7817328275,.9126993851,-.4086316587,-.8191762011,.5735419353,-.8812745759,-.4726046147,.9953313627,.09651672651,.9855650846,-.1692969699,-.8495980887,.5274306472,.6174853946,-.7865823463,.8508156371,.52546432,.9985032451,-.05469249926,.1971371563,-.9803759185,.6607855748,-.7505747292,-.03097494063,.9995201614,-.6731660801,.739491331,-.7195018362,-.6944905383,.9727511689,.2318515979,.9997059088,-.0242506907,.4421787429,-.8969269532,.9981350961,-.061043673,-.9173660799,-.3980445648,-.8150056635,-.5794529907,-.8789331304,.4769450202,.0158605829,.999874213,-.8095464474,.5870558317,-.9165898907,-.3998286786,-.8023542565,.5968480938,-.5176737917,.8555780767,-.8154407307,-.5788405779,.4022010347,-.9155513791,-.9052556868,-.4248672045,.7317445619,.6815789728,-.5647632201,-.8252529947,-.8403276335,-.5420788397,-.9314281527,.363925262,.5238198472,.8518290719,.7432803869,-.6689800195,-.985371561,-.1704197369,.4601468731,.88784281,.825855404,.5638819483,.6182366099,.7859920446,.8331502863,-.553046653,.1500307506,.9886813308,-.662330369,-.7492119075,-.668598664,.743623444,.7025606278,.7116238924,-.5419389763,-.8404178401,-.3388616456,.9408362159,.8331530315,.5530425174,-.2989720662,-.9542618632,.2638522993,.9645630949,.124108739,-.9922686234,-.7282649308,-.6852956957,.6962500149,.7177993569,-.9183535368,.3957610156,-.6326102274,-.7744703352,-.9331891859,-.359385508,-.1153779357,-.9933216659,.9514974788,-.3076565421,-.08987977445,-.9959526224,.6678496916,.7442961705,.7952400393,-.6062947138,-.6462007402,-.7631674805,-.2733598753,.9619118351,.9669590226,-.254931851,-.9792894595,.2024651934,-.5369502995,-.8436138784,-.270036471,-.9628500944,-.6400277131,.7683518247,-.7854537493,-.6189203566,.06005905383,-.9981948257,-.02455770378,.9996984141,-.65983623,.751409442,-.6253894466,-.7803127835,-.6210408851,-.7837781695,.8348888491,.5504185768,-.1592275245,.9872419133,.8367622488,.5475663786,-.8675753916,-.4973056806,-.2022662628,-.9793305667,.9399189937,.3413975472,.9877404807,-.1561049093,-.9034455656,.4287028224,.1269804218,-.9919052235,-.3819600854,.924178821,.9754625894,.2201652486,-.3204015856,-.9472818081,-.9874760884,.1577687387,.02535348474,-.9996785487,.4835130794,-.8753371362,-.2850799925,-.9585037287,-.06805516006,-.99768156,-.7885244045,-.6150034663,.3185392127,-.9479096845,.8880043089,.4598351306,.6476921488,-.7619021462,.9820241299,.1887554194,.9357275128,-.3527237187,-.8894895414,.4569555293,.7922791302,.6101588153,.7483818261,.6632681526,-.7288929755,-.6846276581,.8729032783,-.4878932944,.8288345784,.5594937369,.08074567077,.9967347374,.9799148216,-.1994165048,-.580730673,-.8140957471,-.4700049791,-.8826637636,.2409492979,.9705377045,.9437816757,-.3305694308,-.8927998638,-.4504535528,-.8069622304,.5906030467,.06258973166,.9980393407,-.9312597469,.3643559849,.5777449785,.8162173362,-.3360095855,-.941858566,.697932075,-.7161639607,-.002008157227,-.9999979837,-.1827294312,-.9831632392,-.6523911722,.7578824173,-.4302626911,-.9027037258,-.9985126289,-.05452091251,-.01028102172,-.9999471489,-.4946071129,.8691166802,-.2999350194,.9539596344,.8165471961,.5772786819,.2697460475,.962931498,-.7306287391,-.6827749597,-.7590952064,-.6509796216,-.907053853,.4210146171,-.5104861064,-.8598860013,.8613350597,.5080373165,.5007881595,-.8655698812,-.654158152,.7563577938,-.8382755311,-.545246856,.6940070834,.7199681717,.06950936031,.9975812994,.1702942185,-.9853932612,.2695973274,.9629731466,.5519612192,-.8338697815,.225657487,-.9742067022,.4215262855,-.9068161835,.4881873305,-.8727388672,-.3683854996,-.9296731273,-.9825390578,.1860564427,.81256471,.5828709909,.3196460933,-.9475370046,.9570913859,.2897862643,-.6876655497,-.7260276109,-.9988770922,-.047376731,-.1250179027,.992154486,-.8280133617,.560708367,.9324863769,-.3612051451,.6394653183,.7688199442,-.01623847064,-.9998681473,-.9955014666,-.09474613458,-.81453315,.580117012,.4037327978,-.9148769469,.9944263371,.1054336766,-.1624711654,.9867132919,-.9949487814,-.100383875,-.6995302564,.7146029809,.5263414922,-.85027327,-.5395221479,.841971408,.6579370318,.7530729462,.01426758847,-.9998982128,-.6734383991,.7392433447,.639412098,-.7688642071,.9211571421,.3891908523,-.146637214,-.9891903394,-.782318098,.6228791163,-.5039610839,-.8637263605,-.7743120191,-.6328039957];_Gradients3D=[0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,1,1,0,0,0,-1,1,0,-1,1,0,0,0,-1,-1,0];_RandVecs3D=[-.7292736885,-.6618439697,.1735581948,0,.790292081,-.5480887466,-.2739291014,0,.7217578935,.6226212466,-.3023380997,0,.565683137,-.8208298145,-.0790000257,0,.760049034,-.5555979497,-.3370999617,0,.3713945616,.5011264475,.7816254623,0,-.1277062463,-.4254438999,-.8959289049,0,-.2881560924,-.5815838982,.7607405838,0,.5849561111,-.662820239,-.4674352136,0,.3307171178,.0391653737,.94291689,0,.8712121778,-.4113374369,-.2679381538,0,.580981015,.7021915846,.4115677815,0,.503756873,.6330056931,-.5878203852,0,.4493712205,.601390195,.6606022552,0,-.6878403724,.09018890807,-.7202371714,0,-.5958956522,-.6469350577,.475797649,0,-.5127052122,.1946921978,-.8361987284,0,-.9911507142,-.05410276466,-.1212153153,0,-.2149721042,.9720882117,-.09397607749,0,-.7518650936,-.5428057603,.3742469607,0,.5237068895,.8516377189,-.02107817834,0,.6333504779,.1926167129,-.7495104896,0,-.06788241606,.3998305789,.9140719259,0,-.5538628599,-.4729896695,-.6852128902,0,-.7261455366,-.5911990757,.3509933228,0,-.9229274737,-.1782808786,.3412049336,0,-.6968815002,.6511274338,.3006480328,0,.9608044783,-.2098363234,-.1811724921,0,.06817146062,-.9743405129,.2145069156,0,-.3577285196,-.6697087264,-.6507845481,0,-.1868621131,.7648617052,-.6164974636,0,-.6541697588,.3967914832,.6439087246,0,.6993340405,-.6164538506,.3618239211,0,-.1546665739,.6291283928,.7617583057,0,-.6841612949,-.2580482182,-.6821542638,0,.5383980957,.4258654885,.7271630328,0,-.5026987823,-.7939832935,-.3418836993,0,.3202971715,.2834415347,.9039195862,0,.8683227101,-.0003762656404,-.4959995258,0,.791120031,-.08511045745,.6057105799,0,-.04011016052,-.4397248749,.8972364289,0,.9145119872,.3579346169,-.1885487608,0,-.9612039066,-.2756484276,.01024666929,0,.6510361721,-.2877799159,-.7023778346,0,-.2041786351,.7365237271,.644859585,0,-.7718263711,.3790626912,.5104855816,0,-.3060082741,-.7692987727,.5608371729,0,.454007341,-.5024843065,.7357899537,0,.4816795475,.6021208291,-.6367380315,0,.6961980369,-.3222197429,.641469197,0,-.6532160499,-.6781148932,.3368515753,0,.5089301236,-.6154662304,-.6018234363,0,-.1635919754,-.9133604627,-.372840892,0,.52408019,-.8437664109,.1157505864,0,.5902587356,.4983817807,-.6349883666,0,.5863227872,.494764745,.6414307729,0,.6779335087,.2341345225,.6968408593,0,.7177054546,-.6858979348,.120178631,0,-.5328819713,-.5205125012,.6671608058,0,-.8654874251,-.0700727088,-.4960053754,0,-.2861810166,.7952089234,.5345495242,0,-.04849529634,.9810836427,-.1874115585,0,-.6358521667,.6058348682,.4781800233,0,.6254794696,-.2861619734,.7258696564,0,-.2585259868,.5061949264,-.8227581726,0,.02136306781,.5064016808,-.8620330371,0,.200111773,.8599263484,.4695550591,0,.4743561372,.6014985084,-.6427953014,0,.6622993731,-.5202474575,-.5391679918,0,.08084972818,-.6532720452,.7527940996,0,-.6893687501,.0592860349,.7219805347,0,-.1121887082,-.9673185067,.2273952515,0,.7344116094,.5979668656,-.3210532909,0,.5789393465,-.2488849713,.7764570201,0,.6988182827,.3557169806,-.6205791146,0,-.8636845529,-.2748771249,-.4224826141,0,-.4247027957,-.4640880967,.777335046,0,.5257722489,-.8427017621,.1158329937,0,.9343830603,.316302472,-.1639543925,0,-.1016836419,-.8057303073,-.5834887393,0,-.6529238969,.50602126,-.5635892736,0,-.2465286165,-.9668205684,-.06694497494,0,-.9776897119,-.2099250524,-.007368825344,0,.7736893337,.5734244712,.2694238123,0,-.6095087895,.4995678998,.6155736747,0,.5794535482,.7434546771,.3339292269,0,-.8226211154,.08142581855,.5627293636,0,-.510385483,.4703667658,.7199039967,0,-.5764971849,-.07231656274,-.8138926898,0,.7250628871,.3949971505,-.5641463116,0,-.1525424005,.4860840828,-.8604958341,0,-.5550976208,-.4957820792,.667882296,0,-.1883614327,.9145869398,.357841725,0,.7625556724,-.5414408243,-.3540489801,0,-.5870231946,-.3226498013,-.7424963803,0,.3051124198,.2262544068,-.9250488391,0,.6379576059,.577242424,-.5097070502,0,-.5966775796,.1454852398,-.7891830656,0,-.658330573,.6555487542,-.3699414651,0,.7434892426,.2351084581,.6260573129,0,.5562114096,.8264360377,-.0873632843,0,-.3028940016,-.8251527185,.4768419182,0,.1129343818,-.985888439,-.1235710781,0,.5937652891,-.5896813806,.5474656618,0,.6757964092,-.5835758614,-.4502648413,0,.7242302609,-.1152719764,.6798550586,0,-.9511914166,.0753623979,-.2992580792,0,.2539470961,-.1886339355,.9486454084,0,.571433621,-.1679450851,-.8032795685,0,-.06778234979,.3978269256,.9149531629,0,.6074972649,.733060024,-.3058922593,0,-.5435478392,.1675822484,.8224791405,0,-.5876678086,-.3380045064,-.7351186982,0,-.7967562402,.04097822706,-.6029098428,0,-.1996350917,.8706294745,.4496111079,0,-.02787660336,-.9106232682,-.4122962022,0,-.7797625996,-.6257634692,.01975775581,0,-.5211232846,.7401644346,-.4249554471,0,.8575424857,.4053272873,-.3167501783,0,.1045223322,.8390195772,-.5339674439,0,.3501822831,.9242524096,-.1520850155,0,.1987849858,.07647613266,.9770547224,0,.7845996363,.6066256811,-.1280964233,0,.09006737436,-.9750989929,-.2026569073,0,-.8274343547,-.542299559,.1458203587,0,-.3485797732,-.415802277,.840000362,0,-.2471778936,-.7304819962,-.6366310879,0,-.3700154943,.8577948156,.3567584454,0,.5913394901,-.548311967,-.5913303597,0,.1204873514,-.7626472379,-.6354935001,0,.616959265,.03079647928,.7863922953,0,.1258156836,-.6640829889,-.7369967419,0,-.6477565124,-.1740147258,-.7417077429,0,.6217889313,-.7804430448,-.06547655076,0,.6589943422,-.6096987708,.4404473475,0,-.2689837504,-.6732403169,-.6887635427,0,-.3849775103,.5676542638,.7277093879,0,.5754444408,.8110471154,-.1051963504,0,.9141593684,.3832947817,.131900567,0,-.107925319,.9245493968,.3654593525,0,.377977089,.3043148782,.8743716458,0,-.2142885215,-.8259286236,.5214617324,0,.5802544474,.4148098596,-.7008834116,0,-.1982660881,.8567161266,-.4761596756,0,-.03381553704,.3773180787,-.9254661404,0,-.6867922841,-.6656597827,.2919133642,0,.7731742607,-.2875793547,-.5652430251,0,-.09655941928,.9193708367,-.3813575004,0,.2715702457,-.9577909544,-.09426605581,0,.2451015704,-.6917998565,-.6792188003,0,.977700782,-.1753855374,.1155036542,0,-.5224739938,.8521606816,.02903615945,0,-.7734880599,-.5261292347,.3534179531,0,-.7134492443,-.269547243,.6467878011,0,.1644037271,.5105846203,-.8439637196,0,.6494635788,.05585611296,.7583384168,0,-.4711970882,.5017280509,-.7254255765,0,-.6335764307,-.2381686273,-.7361091029,0,-.9021533097,-.270947803,-.3357181763,0,-.3793711033,.872258117,.3086152025,0,-.6855598966,-.3250143309,.6514394162,0,.2900942212,-.7799057743,-.5546100667,0,-.2098319339,.85037073,.4825351604,0,-.4592603758,.6598504336,-.5947077538,0,.8715945488,.09616365406,-.4807031248,0,-.6776666319,.7118504878,-.1844907016,0,.7044377633,.312427597,.637304036,0,-.7052318886,-.2401093292,-.6670798253,0,.081921007,-.7207336136,-.6883545647,0,-.6993680906,-.5875763221,-.4069869034,0,-.1281454481,.6419895885,.7559286424,0,-.6337388239,-.6785471501,-.3714146849,0,.5565051903,-.2168887573,-.8020356851,0,-.5791554484,.7244372011,-.3738578718,0,.1175779076,-.7096451073,.6946792478,0,-.6134619607,.1323631078,.7785527795,0,.6984635305,-.02980516237,-.715024719,0,.8318082963,-.3930171956,.3919597455,0,.1469576422,.05541651717,-.9875892167,0,.708868575,-.2690503865,.6520101478,0,.2726053183,.67369766,-.68688995,0,-.6591295371,.3035458599,-.6880466294,0,.4815131379,-.7528270071,.4487723203,0,.9430009463,.1675647412,-.2875261255,0,.434802957,.7695304522,-.4677277752,0,.3931996188,.594473625,.7014236729,0,.7254336655,-.603925654,.3301814672,0,.7590235227,-.6506083235,.02433313207,0,-.8552768592,-.3430042733,.3883935666,0,-.6139746835,.6981725247,.3682257648,0,-.7465905486,-.5752009504,.3342849376,0,.5730065677,.810555537,-.1210916791,0,-.9225877367,-.3475211012,-.167514036,0,-.7105816789,-.4719692027,-.5218416899,0,-.08564609717,.3583001386,.929669703,0,-.8279697606,-.2043157126,.5222271202,0,.427944023,.278165994,.8599346446,0,.5399079671,-.7857120652,-.3019204161,0,.5678404253,-.5495413974,-.6128307303,0,-.9896071041,.1365639107,-.04503418428,0,-.6154342638,-.6440875597,.4543037336,0,.1074204368,-.7946340692,.5975094525,0,-.3595449969,-.8885529948,.28495784,0,-.2180405296,.1529888965,.9638738118,0,-.7277432317,-.6164050508,-.3007234646,0,.7249729114,-.00669719484,.6887448187,0,-.5553659455,-.5336586252,.6377908264,0,.5137558015,.7976208196,-.3160000073,0,-.3794024848,.9245608561,-.03522751494,0,.8229248658,.2745365933,-.4974176556,0,-.5404114394,.6091141441,.5804613989,0,.8036581901,-.2703029469,.5301601931,0,.6044318879,.6832968393,.4095943388,0,.06389988817,.9658208605,-.2512108074,0,.1087113286,.7402471173,-.6634877936,0,-.713427712,-.6926784018,.1059128479,0,.6458897819,-.5724548511,-.5050958653,0,-.6553931414,.7381471625,.159995615,0,.3910961323,.9188871375,-.05186755998,0,-.4879022471,-.5904376907,.6429111375,0,.6014790094,.7707441366,-.2101820095,0,-.5677173047,.7511360995,.3368851762,0,.7858573506,.226674665,.5753666838,0,-.4520345543,-.604222686,-.6561857263,0,.002272116345,.4132844051,-.9105991643,0,-.5815751419,-.5162925989,.6286591339,0,-.03703704785,.8273785755,.5604221175,0,-.5119692504,.7953543429,-.3244980058,0,-.2682417366,-.9572290247,-.1084387619,0,-.2322482736,-.9679131102,-.09594243324,0,.3554328906,-.8881505545,.2913006227,0,.7346520519,-.4371373164,.5188422971,0,.9985120116,.04659011161,-.02833944577,0,-.3727687496,-.9082481361,.1900757285,0,.91737377,-.3483642108,.1925298489,0,.2714911074,.4147529736,-.8684886582,0,.5131763485,-.7116334161,.4798207128,0,-.8737353606,.18886992,-.4482350644,0,.8460043821,-.3725217914,.3814499973,0,.8978727456,-.1780209141,-.4026575304,0,.2178065647,-.9698322841,-.1094789531,0,-.1518031304,-.7788918132,-.6085091231,0,-.2600384876,-.4755398075,-.8403819825,0,.572313509,-.7474340931,-.3373418503,0,-.7174141009,.1699017182,-.6756111411,0,-.684180784,.02145707593,-.7289967412,0,-.2007447902,.06555605789,-.9774476623,0,-.1148803697,-.8044887315,.5827524187,0,-.7870349638,.03447489231,.6159443543,0,-.2015596421,.6859872284,.6991389226,0,-.08581082512,-.10920836,-.9903080513,0,.5532693395,.7325250401,-.396610771,0,-.1842489331,-.9777375055,-.1004076743,0,.0775473789,-.9111505856,.4047110257,0,.1399838409,.7601631212,-.6344734459,0,.4484419361,-.845289248,.2904925424,0];_PrimeX=501125321;_PrimeY=1136930381;_PrimeZ=1720413743;static _Lerp(e,t,i){return e+i*(t-e)}static _InterpHermite(e){return e*e*(3-2*e)}static _InterpQuintic(e){return e*e*e*(e*(6*e-15)+10)}static _CubicLerp(e,t,i,s,a){let r=s-i-(e-t);return a*a*a*r+a*a*(e-t-r)+a*(i-e)+t}static _PingPong(e){return(e-=2*Math.trunc(.5*e))<1?e:2-e}_CalculateFractalBounding(){let e=Math.abs(this._Gain),t=e,i=1;for(let s=1;s>15,r&=254,s*this._Gradients2D[r]+a*this._Gradients2D[1|r]}_GradCoordR3(e,t,i,s,a,r,o){let l=this._HashR3(e,t,i,s);return l^=l>>15,l&=252,a*this._Gradients3D[l]+r*this._Gradients3D[1|l]+o*this._Gradients3D[2|l]}_GenNoiseSingleR2(e,t,i){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R2(e,t,i);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR2(e,t,i);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR2(e,t,i);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR2(e,t,i);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR2(e,t,i);case FastNoiseLite.NoiseType.Value:return this._SingleValueR2(e,t,i);default:return 0}}_GenNoiseSingleR3(e,t,i,s){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R3(e,t,i,s);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR3(e,t,i,s);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR3(e,t,i,s);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR3(e,t,i,s);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR3(e,t,i,s);case FastNoiseLite.NoiseType.Value:return this._SingleValueR3(e,t,i,s);default:return 0}}_UpdateTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:this._TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._TransformType3D=FastNoiseLite.TransformType3D.None}}}_UpdateWarpTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._WarpTransformType3D=FastNoiseLite.TransformType3D.None}}}_GenFractalFBmR2(e,t){let i=this._Seed,s=0,a=this._FractalBounding;for(let r=0;rp){let t=p+s,i=d+(s-1),a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l,h+this._PrimeY,t,i)}else{let t=p+(s-1),i=d+s,a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l+this._PrimeX,h,t,i)}return 99.83685446303647*(a+r+o)}_SingleOpenSimplex2R3(e,t,i,s){let a=Math.round(t),r=Math.round(i),o=Math.round(s),l=t-a,h=i-r,n=s-o,_=Math.trunc(-1-h|1),c=Math.trunc(-1-l|1),p=Math.trunc(-1-n|1),d=c*-l,m=_*-h,u=p*-n;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let R=0,L=.6-l*l-(h*h+n*n);for(let t=0;;t++){if(L>0&&(R+=L*L*(L*L)*this._GradCoordR3(e,a,r,o,l,h,n)),d>=m&&d>=u){let t=L+d+d;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a-c*this._PrimeX,r,o,l+c,h,n))}else if(m>d&&m>=u){let t=L+m+m;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r-_*this._PrimeY,o,l,h+_,n))}else{let t=L+u+u;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r,o-p*this._PrimeZ,l,h,n+p))}if(1===t)break;d=.5-d,m=.5-m,u=.5-u,l=c*d,h=_*m,n=p*u,L+=.75-d-(m+u),a+=c>>1&this._PrimeX,r+=_>>1&this._PrimeY,o+=p>>1&this._PrimeZ,c=-c,_=-_,p=-p,e=~e}return 32.69428253173828*R}_SingleOpenSimplex2SR2(e,t,i){const s=.21132486540518713;let a=Math.floor(t),r=Math.floor(i),o=t-a,l=i-r;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY);let h=a+this._PrimeX,n=r+this._PrimeY,_=(o+l)*s,c=o-_,p=l-_,d=2/3-c*c-p*p,m=d*d*(d*d)*this._GradCoordR2(e,a,r,c,p),u=3.1547005383792506*_+(-.6666666666666666+d),R=c-(1-2*s),L=p-(1-2*s);m+=u*u*(u*u)*this._GradCoordR2(e,h,n,R,L);let F=o-l;if(_>s){if(o+F>1){let t=c+(3*s-2),i=p+(3*s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+(this._PrimeX<<1),r+this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}if(l-F>1){let t=c+(3*s-1),i=p+(3*s-2),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r+(this._PrimeY<<1),t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}}else{if(o+F<0){let t=c+(1-s),i=p-s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a-this._PrimeX,r,t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}if(l0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r-this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}}return 18.24196194486065*m}_SingleOpenSimplex2SR3(e,t,i,s){let a=Math.floor(t),r=Math.floor(i),o=Math.floor(s),l=t-a,h=i-r,n=s-o;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let _=e+1293373,c=Math.trunc(-.5-l),p=Math.trunc(-.5-h),d=Math.trunc(-.5-n),m=l+c,u=h+p,R=n+d,L=.75-m*m-u*u-R*R,F=L*L*(L*L)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),m,u,R),D=l-.5,C=h-.5,N=n-.5,P=.75-D*D-C*C-N*N;F+=P*P*(P*P)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+this._PrimeZ,D,C,N);let V=((1|c)<<1)*D,y=((1|p)<<1)*C,T=((1|d)<<1)*N,f=(-2-(c<<2))*D-1,S=(-2-(p<<2))*C-1,g=(-2-(d<<2))*N-1,M=!1,G=V+L;if(G>0){let t=m-(1|c);F+=G*G*(G*G)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),t,u,R)}else{let t=y+T+L;if(t>0){let i=m,s=u-(1|p),l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=f+P;if(i>0){let e=(1|c)+D;F+=i*i*(i*i)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+this._PrimeZ,e,C,N),M=!0}}let b=!1,X=y+L;if(X>0){let t=m,i=u-(1|p);F+=X*X*(X*X)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),t,i,R)}else{let t=V+T+L;if(t>0){let i=m-(1|c),s=u,l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=S+P;if(i>0){let e=D,t=(1|p)+C;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+this._PrimeZ,e,t,N),b=!0}}let W=!1,Y=T+L;if(Y>0){let t=m,i=u,s=R-(1|d);F+=Y*Y*(Y*Y)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),t,i,s)}else{let t=V+y+L;if(t>0){let i=m-(1|c),s=u-(1|p);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),i,s,R)}let i=g+P;if(i>0){let e=D,t=C,s=(1|d)+N;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+(d&this._PrimeZ<<1),e,t,s),W=!0}}if(!M){let e=S+g+P;if(e>0){let t=D,i=(1|p)+C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+(d&this._PrimeZ<<1),t,i,s)}}if(!b){let e=f+g+P;if(e>0){let t=(1|c)+D,i=C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+(d&this._PrimeZ<<1),t,i,s)}}if(!W){let e=f+S+P;if(e>0){let t=(1|c)+D,i=(1|p)+C;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&this._PrimeX<<1),r+(p&this._PrimeY<<1),o+this._PrimeZ,t,i,N)}}return 9.046026385208288*F}_SingleCellularR2(e,t,i){let s=Math.round(t),a=Math.round(i),r=Number.MAX_VALUE,o=Number.MAX_VALUE,l=0,h=.43701595*this._CellularJitterModifier,n=(s-1)*this._PrimeX,_=(a-1)*this._PrimeY;switch(this._CellularDistanceFunction){default:case FastNoiseLite.CellularDistanceFunction.Euclidean:case FastNoiseLite.CellularDistanceFunction.EuclideanSq:for(let c=s-1;c<=s+1;c++){let s=_;for(let _=a-1;_<=a+1;_++){let a=this._HashR2(e,n,s),p=510&a,d=c-t+this._RandVecs2D[p]*h,m=_-i+this._RandVecs2D[1|p]*h,u=d*d+m*m;o=Math.max(Math.min(o,u),r),u{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,32.69428253173828*t,i,s,!1,a,r,o);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,7.71604938271605*t,i,s,!0,a,r,o);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r,o)}};return 6===arguments.length&&arguments[3]instanceof Vector2?((e,t,i,s,a,r)=>{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,38.283687591552734*t,i,s,!1,a,r);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,16*t,i,s,!0,a,r);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r)}})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]):7===arguments.length&&arguments[3]instanceof Vector3?e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]):void 0}_DomainWarpSingle(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y,o=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=a+r,t=-.211324865405187*e;o*=.577350269189626,a+=t-o,r=r+t-o,o+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=a+o,t=-.211324865405187*e;r*=.577350269189626,a+=t-r,o+=t-r,r+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let e=(a+r+o)*(2/3);a=e-a,r=e-r,o=e-o}this._DoSingleDomainWarp(t,i,s,e,a,r,o)};return 1===arguments.length&&arguments[0]instanceof Vector2?(e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(a+r)*(.5*(1.7320508075688772-1));a+=e,r+=e}this._DoSingleDomainWarp(t,i,s,e,a,r)})(arguments[0]):1===arguments.length&&arguments[0]instanceof Vector3?e(arguments[0]):void 0}_DomainWarpFractalProgressive(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=e.x,i=e.y,s=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=t+i,a=-.211324865405187*e;s*=.577350269189626,t+=a-s,i=i+a-s,s+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=t+s,a=-.211324865405187*e;i*=.577350269189626,t+=a-i,s+=a-i,i+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:{let e=(t+i+s)*(2/3);t=e-t,i=e-i,s=e-s}}let a=this._Seed,r=this._DomainWarpAmp*this._FractalBounding,o=this._Frequency;for(let l=0;l{let t=e.x,i=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(t+i)*(.5*(1.7320508075688772-1));t+=e,i+=e}let s=this._Seed,a=this._DomainWarpAmp*this._FractalBounding,r=this._Frequency;for(let o=0;o{let l=a*i,h=r*i,n=o*i,_=Math.floor(l),c=Math.floor(h),p=Math.floor(n),d=FastNoiseLite._InterpHermite(l-_),m=FastNoiseLite._InterpHermite(h-c),u=FastNoiseLite._InterpHermite(n-p);_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),p=Math.imul(p,this._PrimeZ);let R=_+this._PrimeX,L=c+this._PrimeY,F=p+this._PrimeZ,D=1020&this._HashR3(e,_,c,p),C=1020&this._HashR3(e,R,c,p),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d);D=1020&this._HashR3(e,_,L,p),C=1020&this._HashR3(e,R,L,p);let y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),S=FastNoiseLite._Lerp(N,y,m),g=FastNoiseLite._Lerp(P,T,m),M=FastNoiseLite._Lerp(V,f,m);D=1020&this._HashR3(e,_,c,F),C=1020&this._HashR3(e,R,c,F),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),D=1020&this._HashR3(e,_,L,F),C=1020&this._HashR3(e,R,L,F),y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),s.x+=FastNoiseLite._Lerp(S,FastNoiseLite._Lerp(N,y,m),u)*t,s.y+=FastNoiseLite._Lerp(g,FastNoiseLite._Lerp(P,T,m),u)*t,s.z+=FastNoiseLite._Lerp(M,FastNoiseLite._Lerp(V,f,m),u)*t};6===arguments.length&&arguments[3]instanceof Vector2&&((e,t,i,s,a,r)=>{let o=a*i,l=r*i,h=Math.floor(o),n=Math.floor(l),_=FastNoiseLite._InterpHermite(o-h),c=FastNoiseLite._InterpHermite(l-n);h=Math.imul(h,this._PrimeX),n=Math.imul(n,this._PrimeY);let p=h+this._PrimeX,d=n+this._PrimeY,m=510&this._HashR2(e,h,n),u=510&this._HashR2(e,p,n),R=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),L=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);m=510&this._HashR2(e,h,d),u=510&this._HashR2(e,p,d);let F=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),D=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);s.x+=FastNoiseLite._Lerp(R,F,c)*t,s.y+=FastNoiseLite._Lerp(L,D,c)*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]),7===arguments.length&&arguments[3]instanceof Vector3&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6])}_SingleDomainWarpOpenSimplex2Gradient(){let e=(e,t,i,s,a,r,o,l)=>{r*=i,o*=i,l*=i;let h,n,_,c=Math.round(r),p=Math.round(o),d=Math.round(l),m=r-c,u=o-p,R=l-d,L=-m-1|1,F=-u-1|1,D=-R-1|1,C=L*-m,N=F*-u,P=D*-R;c=Math.imul(c,this._PrimeX),p=Math.imul(p,this._PrimeY),d=Math.imul(d,this._PrimeZ),h=n=_=0;let V=.6-m*m-(u*u+R*R);for(let t=0;;t++){if(V>0){let t,i,s,r=V*V*(V*V);if(a){let a=1020&this._HashR3(e,c,p,d);t=this._RandVecs3D[a],i=this._RandVecs3D[1|a],s=this._RandVecs3D[2|a]}else{let a=this._HashR3(e,c,p,d),r=252&a,o=a>>6&1020,l=m*this._Gradients3D[r]+u*this._Gradients3D[1|r]+R*this._Gradients3D[2|r];t=l*this._RandVecs3D[o],i=l*this._RandVecs3D[1|o],s=l*this._RandVecs3D[2|o]}h+=r*t,n+=r*i,_+=r*s}let i=V,s=c,r=p,o=d,l=m,y=u,T=R;if(C>=N&&C>=P?(l+=L,i=i+C+C,s-=L*this._PrimeX):N>C&&N>=P?(y+=F,i=i+N+N,r-=F*this._PrimeY):(T+=D,i=i+P+P,o-=D*this._PrimeZ),i>1){i-=1;let t,c,p,d=i*i*(i*i);if(a){let i=1020&this._HashR3(e,s,r,o);t=this._RandVecs3D[i],c=this._RandVecs3D[1|i],p=this._RandVecs3D[2|i]}else{let i=this._HashR3(e,s,r,o),a=252&i,h=i>>6&1020,n=l*this._Gradients3D[a]+y*this._Gradients3D[1|a]+T*this._Gradients3D[2|a];t=n*this._RandVecs3D[h],c=n*this._RandVecs3D[1|h],p=n*this._RandVecs3D[2|h]}h+=d*t,n+=d*c,_+=d*p}if(1===t)break;C=.5-C,N=.5-N,P=.5-P,m=L*C,u=F*N,R=D*P,V+=.75-C-(N+P),c+=L>>1&this._PrimeX,p+=F>>1&this._PrimeY,d+=D>>1&this._PrimeZ,L=-L,F=-F,D=-D,e+=1293373}s.x+=h*t,s.y+=n*t,s.z+=_*t};7===arguments.length&&((e,t,i,s,a,r,o)=>{const l=.21132486540518713;r*=i,o*=i;let h,n,_=Math.floor(r),c=Math.floor(o),p=r-_,d=o-c,m=(p+d)*l,u=p-m,R=d-m;_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),h=n=0;let L=.5-u*u-R*R;if(L>0){let t,i,s=L*L*(L*L);if(a){let s=510&this._HashR2(e,_,c);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let s=this._HashR2(e,_,c),a=254&s,r=s>>7&510,o=u*this._Gradients2D[a]+R*this._Gradients2D[1|a];t=o*this._RandVecs2D[r],i=o*this._RandVecs2D[1|r]}h+=s*t,n+=s*i}let F=3.1547005383792506*m+(-.6666666666666666+L);if(F>0){let t,i,s=u+(2*l-1),r=R+(2*l-1),o=F*F*(F*F);if(a){let s=510&this._HashR2(e,_+this._PrimeX,c+this._PrimeY);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let a=this._HashR2(e,_+this._PrimeX,c+this._PrimeY),o=254&a,l=a>>7&510,h=s*this._Gradients2D[o]+r*this._Gradients2D[1|o];t=h*this._RandVecs2D[l],i=h*this._RandVecs2D[1|l]}h+=o*t,n+=o*i}if(R>u){let t=u+l,i=R+(l-1),s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_,c+this._PrimeY);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_,c+this._PrimeY),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}else{let t=u+(l-1),i=R+l,s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_+this._PrimeX,c);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_+this._PrimeX,c),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}s.x+=h*t,s.y+=n*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]),8===arguments.length&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7])}}class Vector2{constructor(e,t){this.x=e,this.y=t}}class Vector3{constructor(e,t,i){this.x=e,this.y=t,this.z=i}} /* eslint-enable */ + /* prettier-enable */ Scratch.extensions.register(new Noise()); })(Scratch); From 6c906199f3940054839e9154a867a0bca51c4367 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Thu, 26 Dec 2024 14:00:17 -0700 Subject: [PATCH 31/36] unminified --- extensions/Corbnorb/noise.js | 3271 ++++++++++++++++++++++++++++++++++ 1 file changed, 3271 insertions(+) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 3f7dfa8ea7..257e0e17c6 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -232,6 +232,7 @@ // SOFTWARE. // +<<<<<<< HEAD //minified code. find original here: // https://raw.githubusercontent.com/Auburn/FastNoiseLite/refs/heads/master/JavaScript/FastNoiseLite.js @@ -241,6 +242,3276 @@ class FastNoiseLite{static NoiseType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2S:"OpenSimplex2S",Cellular:"Cellular",Perlin:"Perlin",ValueCubic:"ValueCubic",Value:"Value"});static RotationType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes"});static FractalType=Object.freeze({None:"None",FBm:"FBm",Ridged:"Ridged",PingPong:"PingPong",DomainWarpProgressive:"DomainWarpProgressive",DomainWarpIndependent:"DomainWarpIndependent"});static CellularDistanceFunction=Object.freeze({Euclidean:"Euclidean",EuclideanSq:"EuclideanSq",Manhattan:"Manhattan",Hybrid:"Hybrid"});static CellularReturnType=Object.freeze({CellValue:"CellValue",Distance:"Distance",Distance2:"Distance2",Distance2Add:"Distance2Add",Distance2Sub:"Distance2Sub",Distance2Mul:"Distance2Mul",Distance2Div:"Distance2Div"});static DomainWarpType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2Reduced:"OpenSimplex2Reduced",BasicGrid:"BasicGrid"});static TransformType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes",DefaultOpenSimplex2:"DefaultOpenSimplex2"});_Seed=1337;_Frequency=.01;_NoiseType=FastNoiseLite.NoiseType.OpenSimplex2;_RotationType3D=FastNoiseLite.RotationType3D.None;_TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;_DomainWarpAmp=1;_FractalType=FastNoiseLite.FractalType.None;_Octaves=3;_Lacunarity=2;_Gain=.5;_WeightedStrength=0;_PingPongStrength=2;_FractalBounding=1/1.75;_CellularDistanceFunction=FastNoiseLite.CellularDistanceFunction.EuclideanSq;_CellularReturnType=FastNoiseLite.CellularReturnType.Distance;_CellularJitterModifier=1;_DomainWarpType=FastNoiseLite.DomainWarpType.OpenSimplex2;_WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;constructor(e){void 0!==e&&(this._Seed=e)}SetSeed(e){this._Seed=e}SetFrequency(e){this._Frequency=e}SetNoiseType(e){this._NoiseType=e,this._UpdateTransformType3D()}SetRotationType3D(e){this._RotationType3D=e,this._UpdateTransformType3D(),this._UpdateWarpTransformType3D()}SetFractalType(e){this._FractalType=e}SetFractalOctaves(e){this._Octaves=e,this._CalculateFractalBounding()}SetFractalLacunarity(e){this._Lacunarity=e}SetFractalGain(e){this._Gain=e,this._CalculateFractalBounding()}SetFractalWeightedStrength(e){this._WeightedStrength=e}SetFractalPingPongStrength(e){this._PingPongStrength=e}SetCellularDistanceFunction(e){this._CellularDistanceFunction=e}SetCellularReturnType(e){this._CellularReturnType=e}SetCellularJitter(e){this._CellularJitterModifier=e}SetDomainWarpType(e){this._DomainWarpType=e,this._UpdateWarpTransformType3D()}SetDomainWarpAmp(e){this._DomainWarpAmp=e}GetNoise(e,t,i){let s=(e,t)=>{switch(e*=this._Frequency,t*=this._Frequency,this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:let i=(e+t)*(.5*(1.7320508075688772-1));e+=i,t+=i}switch(this._FractalType){default:return this._GenNoiseSingleR2(this._Seed,e,t);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR2(e,t);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR2(e,t);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR2(e,t)}},a=(e,t,i)=>{switch(e*=this._Frequency,t*=this._Frequency,i*=this._Frequency,this._TransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let s=e+t,a=-.211324865405187*s;e+=a-(i*=.577350269189626),t+=a-i,i+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let s=e+i,a=-.211324865405187*s;e+=a-(t*=.577350269189626),i+=a-t,t+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let s=(e+t+i)*(2/3);e=s-e,t=s-t,i=s-i}switch(this._FractalType){default:return this._GenNoiseSingleR3(this._Seed,e,t,i);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR3(e,t,i);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR3(e,t,i);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR3(e,t,i)}};return 2===arguments.length?s(e,t):3===arguments.length?a(e,t,i):void 0}DomainWrap(e){switch(this._FractalType){default:this._DomainWarpSingle(e);break;case FastNoiseLite.FractalType.DomainWarpProgressive:this._DomainWarpFractalProgressive(e);break;case FastNoiseLite.FractalType.DomainWarpIndependent:this._DomainWarpFractalIndependent(e)}}_Gradients2D=[.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.38268343236509,.923879532511287,.923879532511287,.38268343236509,.923879532511287,-.38268343236509,.38268343236509,-.923879532511287,-.38268343236509,-.923879532511287,-.923879532511287,-.38268343236509,-.923879532511287,.38268343236509,-.38268343236509,.923879532511287];_RandVecs2D=[-.2700222198,-.9628540911,.3863092627,-.9223693152,.04444859006,-.999011673,-.5992523158,-.8005602176,-.7819280288,.6233687174,.9464672271,.3227999196,-.6514146797,-.7587218957,.9378472289,.347048376,-.8497875957,-.5271252623,-.879042592,.4767432447,-.892300288,-.4514423508,-.379844434,-.9250503802,-.9951650832,.0982163789,.7724397808,-.6350880136,.7573283322,-.6530343002,-.9928004525,-.119780055,-.0532665713,.9985803285,.9754253726,-.2203300762,-.7665018163,.6422421394,.991636706,.1290606184,-.994696838,.1028503788,-.5379205513,-.84299554,.5022815471,-.8647041387,.4559821461,-.8899889226,-.8659131224,-.5001944266,.0879458407,-.9961252577,-.5051684983,.8630207346,.7753185226,-.6315704146,-.6921944612,.7217110418,-.5191659449,-.8546734591,.8978622882,-.4402764035,-.1706774107,.9853269617,-.9353430106,-.3537420705,-.9992404798,.03896746794,-.2882064021,-.9575683108,-.9663811329,.2571137995,-.8759714238,-.4823630009,-.8303123018,-.5572983775,.05110133755,-.9986934731,-.8558373281,-.5172450752,.09887025282,.9951003332,.9189016087,.3944867976,-.2439375892,-.9697909324,-.8121409387,-.5834613061,-.9910431363,.1335421355,.8492423985,-.5280031709,-.9717838994,-.2358729591,.9949457207,.1004142068,.6241065508,-.7813392434,.662910307,.7486988212,-.7197418176,.6942418282,-.8143370775,-.5803922158,.104521054,-.9945226741,-.1065926113,-.9943027784,.445799684,-.8951327509,.105547406,.9944142724,-.992790267,.1198644477,-.8334366408,.552615025,.9115561563,-.4111755999,.8285544909,-.5599084351,.7217097654,-.6921957921,.4940492677,-.8694339084,-.3652321272,-.9309164803,-.9696606758,.2444548501,.08925509731,-.996008799,.5354071276,-.8445941083,-.1053576186,.9944343981,-.9890284586,.1477251101,.004856104961,.9999882091,.9885598478,.1508291331,.9286129562,-.3710498316,-.5832393863,-.8123003252,.3015207509,.9534596146,-.9575110528,.2883965738,.9715802154,-.2367105511,.229981792,.9731949318,.955763816,-.2941352207,.740956116,.6715534485,-.9971513787,-.07542630764,.6905710663,-.7232645452,-.290713703,-.9568100872,.5912777791,-.8064679708,-.9454592212,-.325740481,.6664455681,.74555369,.6236134912,.7817328275,.9126993851,-.4086316587,-.8191762011,.5735419353,-.8812745759,-.4726046147,.9953313627,.09651672651,.9855650846,-.1692969699,-.8495980887,.5274306472,.6174853946,-.7865823463,.8508156371,.52546432,.9985032451,-.05469249926,.1971371563,-.9803759185,.6607855748,-.7505747292,-.03097494063,.9995201614,-.6731660801,.739491331,-.7195018362,-.6944905383,.9727511689,.2318515979,.9997059088,-.0242506907,.4421787429,-.8969269532,.9981350961,-.061043673,-.9173660799,-.3980445648,-.8150056635,-.5794529907,-.8789331304,.4769450202,.0158605829,.999874213,-.8095464474,.5870558317,-.9165898907,-.3998286786,-.8023542565,.5968480938,-.5176737917,.8555780767,-.8154407307,-.5788405779,.4022010347,-.9155513791,-.9052556868,-.4248672045,.7317445619,.6815789728,-.5647632201,-.8252529947,-.8403276335,-.5420788397,-.9314281527,.363925262,.5238198472,.8518290719,.7432803869,-.6689800195,-.985371561,-.1704197369,.4601468731,.88784281,.825855404,.5638819483,.6182366099,.7859920446,.8331502863,-.553046653,.1500307506,.9886813308,-.662330369,-.7492119075,-.668598664,.743623444,.7025606278,.7116238924,-.5419389763,-.8404178401,-.3388616456,.9408362159,.8331530315,.5530425174,-.2989720662,-.9542618632,.2638522993,.9645630949,.124108739,-.9922686234,-.7282649308,-.6852956957,.6962500149,.7177993569,-.9183535368,.3957610156,-.6326102274,-.7744703352,-.9331891859,-.359385508,-.1153779357,-.9933216659,.9514974788,-.3076565421,-.08987977445,-.9959526224,.6678496916,.7442961705,.7952400393,-.6062947138,-.6462007402,-.7631674805,-.2733598753,.9619118351,.9669590226,-.254931851,-.9792894595,.2024651934,-.5369502995,-.8436138784,-.270036471,-.9628500944,-.6400277131,.7683518247,-.7854537493,-.6189203566,.06005905383,-.9981948257,-.02455770378,.9996984141,-.65983623,.751409442,-.6253894466,-.7803127835,-.6210408851,-.7837781695,.8348888491,.5504185768,-.1592275245,.9872419133,.8367622488,.5475663786,-.8675753916,-.4973056806,-.2022662628,-.9793305667,.9399189937,.3413975472,.9877404807,-.1561049093,-.9034455656,.4287028224,.1269804218,-.9919052235,-.3819600854,.924178821,.9754625894,.2201652486,-.3204015856,-.9472818081,-.9874760884,.1577687387,.02535348474,-.9996785487,.4835130794,-.8753371362,-.2850799925,-.9585037287,-.06805516006,-.99768156,-.7885244045,-.6150034663,.3185392127,-.9479096845,.8880043089,.4598351306,.6476921488,-.7619021462,.9820241299,.1887554194,.9357275128,-.3527237187,-.8894895414,.4569555293,.7922791302,.6101588153,.7483818261,.6632681526,-.7288929755,-.6846276581,.8729032783,-.4878932944,.8288345784,.5594937369,.08074567077,.9967347374,.9799148216,-.1994165048,-.580730673,-.8140957471,-.4700049791,-.8826637636,.2409492979,.9705377045,.9437816757,-.3305694308,-.8927998638,-.4504535528,-.8069622304,.5906030467,.06258973166,.9980393407,-.9312597469,.3643559849,.5777449785,.8162173362,-.3360095855,-.941858566,.697932075,-.7161639607,-.002008157227,-.9999979837,-.1827294312,-.9831632392,-.6523911722,.7578824173,-.4302626911,-.9027037258,-.9985126289,-.05452091251,-.01028102172,-.9999471489,-.4946071129,.8691166802,-.2999350194,.9539596344,.8165471961,.5772786819,.2697460475,.962931498,-.7306287391,-.6827749597,-.7590952064,-.6509796216,-.907053853,.4210146171,-.5104861064,-.8598860013,.8613350597,.5080373165,.5007881595,-.8655698812,-.654158152,.7563577938,-.8382755311,-.545246856,.6940070834,.7199681717,.06950936031,.9975812994,.1702942185,-.9853932612,.2695973274,.9629731466,.5519612192,-.8338697815,.225657487,-.9742067022,.4215262855,-.9068161835,.4881873305,-.8727388672,-.3683854996,-.9296731273,-.9825390578,.1860564427,.81256471,.5828709909,.3196460933,-.9475370046,.9570913859,.2897862643,-.6876655497,-.7260276109,-.9988770922,-.047376731,-.1250179027,.992154486,-.8280133617,.560708367,.9324863769,-.3612051451,.6394653183,.7688199442,-.01623847064,-.9998681473,-.9955014666,-.09474613458,-.81453315,.580117012,.4037327978,-.9148769469,.9944263371,.1054336766,-.1624711654,.9867132919,-.9949487814,-.100383875,-.6995302564,.7146029809,.5263414922,-.85027327,-.5395221479,.841971408,.6579370318,.7530729462,.01426758847,-.9998982128,-.6734383991,.7392433447,.639412098,-.7688642071,.9211571421,.3891908523,-.146637214,-.9891903394,-.782318098,.6228791163,-.5039610839,-.8637263605,-.7743120191,-.6328039957];_Gradients3D=[0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,1,1,0,0,0,-1,1,0,-1,1,0,0,0,-1,-1,0];_RandVecs3D=[-.7292736885,-.6618439697,.1735581948,0,.790292081,-.5480887466,-.2739291014,0,.7217578935,.6226212466,-.3023380997,0,.565683137,-.8208298145,-.0790000257,0,.760049034,-.5555979497,-.3370999617,0,.3713945616,.5011264475,.7816254623,0,-.1277062463,-.4254438999,-.8959289049,0,-.2881560924,-.5815838982,.7607405838,0,.5849561111,-.662820239,-.4674352136,0,.3307171178,.0391653737,.94291689,0,.8712121778,-.4113374369,-.2679381538,0,.580981015,.7021915846,.4115677815,0,.503756873,.6330056931,-.5878203852,0,.4493712205,.601390195,.6606022552,0,-.6878403724,.09018890807,-.7202371714,0,-.5958956522,-.6469350577,.475797649,0,-.5127052122,.1946921978,-.8361987284,0,-.9911507142,-.05410276466,-.1212153153,0,-.2149721042,.9720882117,-.09397607749,0,-.7518650936,-.5428057603,.3742469607,0,.5237068895,.8516377189,-.02107817834,0,.6333504779,.1926167129,-.7495104896,0,-.06788241606,.3998305789,.9140719259,0,-.5538628599,-.4729896695,-.6852128902,0,-.7261455366,-.5911990757,.3509933228,0,-.9229274737,-.1782808786,.3412049336,0,-.6968815002,.6511274338,.3006480328,0,.9608044783,-.2098363234,-.1811724921,0,.06817146062,-.9743405129,.2145069156,0,-.3577285196,-.6697087264,-.6507845481,0,-.1868621131,.7648617052,-.6164974636,0,-.6541697588,.3967914832,.6439087246,0,.6993340405,-.6164538506,.3618239211,0,-.1546665739,.6291283928,.7617583057,0,-.6841612949,-.2580482182,-.6821542638,0,.5383980957,.4258654885,.7271630328,0,-.5026987823,-.7939832935,-.3418836993,0,.3202971715,.2834415347,.9039195862,0,.8683227101,-.0003762656404,-.4959995258,0,.791120031,-.08511045745,.6057105799,0,-.04011016052,-.4397248749,.8972364289,0,.9145119872,.3579346169,-.1885487608,0,-.9612039066,-.2756484276,.01024666929,0,.6510361721,-.2877799159,-.7023778346,0,-.2041786351,.7365237271,.644859585,0,-.7718263711,.3790626912,.5104855816,0,-.3060082741,-.7692987727,.5608371729,0,.454007341,-.5024843065,.7357899537,0,.4816795475,.6021208291,-.6367380315,0,.6961980369,-.3222197429,.641469197,0,-.6532160499,-.6781148932,.3368515753,0,.5089301236,-.6154662304,-.6018234363,0,-.1635919754,-.9133604627,-.372840892,0,.52408019,-.8437664109,.1157505864,0,.5902587356,.4983817807,-.6349883666,0,.5863227872,.494764745,.6414307729,0,.6779335087,.2341345225,.6968408593,0,.7177054546,-.6858979348,.120178631,0,-.5328819713,-.5205125012,.6671608058,0,-.8654874251,-.0700727088,-.4960053754,0,-.2861810166,.7952089234,.5345495242,0,-.04849529634,.9810836427,-.1874115585,0,-.6358521667,.6058348682,.4781800233,0,.6254794696,-.2861619734,.7258696564,0,-.2585259868,.5061949264,-.8227581726,0,.02136306781,.5064016808,-.8620330371,0,.200111773,.8599263484,.4695550591,0,.4743561372,.6014985084,-.6427953014,0,.6622993731,-.5202474575,-.5391679918,0,.08084972818,-.6532720452,.7527940996,0,-.6893687501,.0592860349,.7219805347,0,-.1121887082,-.9673185067,.2273952515,0,.7344116094,.5979668656,-.3210532909,0,.5789393465,-.2488849713,.7764570201,0,.6988182827,.3557169806,-.6205791146,0,-.8636845529,-.2748771249,-.4224826141,0,-.4247027957,-.4640880967,.777335046,0,.5257722489,-.8427017621,.1158329937,0,.9343830603,.316302472,-.1639543925,0,-.1016836419,-.8057303073,-.5834887393,0,-.6529238969,.50602126,-.5635892736,0,-.2465286165,-.9668205684,-.06694497494,0,-.9776897119,-.2099250524,-.007368825344,0,.7736893337,.5734244712,.2694238123,0,-.6095087895,.4995678998,.6155736747,0,.5794535482,.7434546771,.3339292269,0,-.8226211154,.08142581855,.5627293636,0,-.510385483,.4703667658,.7199039967,0,-.5764971849,-.07231656274,-.8138926898,0,.7250628871,.3949971505,-.5641463116,0,-.1525424005,.4860840828,-.8604958341,0,-.5550976208,-.4957820792,.667882296,0,-.1883614327,.9145869398,.357841725,0,.7625556724,-.5414408243,-.3540489801,0,-.5870231946,-.3226498013,-.7424963803,0,.3051124198,.2262544068,-.9250488391,0,.6379576059,.577242424,-.5097070502,0,-.5966775796,.1454852398,-.7891830656,0,-.658330573,.6555487542,-.3699414651,0,.7434892426,.2351084581,.6260573129,0,.5562114096,.8264360377,-.0873632843,0,-.3028940016,-.8251527185,.4768419182,0,.1129343818,-.985888439,-.1235710781,0,.5937652891,-.5896813806,.5474656618,0,.6757964092,-.5835758614,-.4502648413,0,.7242302609,-.1152719764,.6798550586,0,-.9511914166,.0753623979,-.2992580792,0,.2539470961,-.1886339355,.9486454084,0,.571433621,-.1679450851,-.8032795685,0,-.06778234979,.3978269256,.9149531629,0,.6074972649,.733060024,-.3058922593,0,-.5435478392,.1675822484,.8224791405,0,-.5876678086,-.3380045064,-.7351186982,0,-.7967562402,.04097822706,-.6029098428,0,-.1996350917,.8706294745,.4496111079,0,-.02787660336,-.9106232682,-.4122962022,0,-.7797625996,-.6257634692,.01975775581,0,-.5211232846,.7401644346,-.4249554471,0,.8575424857,.4053272873,-.3167501783,0,.1045223322,.8390195772,-.5339674439,0,.3501822831,.9242524096,-.1520850155,0,.1987849858,.07647613266,.9770547224,0,.7845996363,.6066256811,-.1280964233,0,.09006737436,-.9750989929,-.2026569073,0,-.8274343547,-.542299559,.1458203587,0,-.3485797732,-.415802277,.840000362,0,-.2471778936,-.7304819962,-.6366310879,0,-.3700154943,.8577948156,.3567584454,0,.5913394901,-.548311967,-.5913303597,0,.1204873514,-.7626472379,-.6354935001,0,.616959265,.03079647928,.7863922953,0,.1258156836,-.6640829889,-.7369967419,0,-.6477565124,-.1740147258,-.7417077429,0,.6217889313,-.7804430448,-.06547655076,0,.6589943422,-.6096987708,.4404473475,0,-.2689837504,-.6732403169,-.6887635427,0,-.3849775103,.5676542638,.7277093879,0,.5754444408,.8110471154,-.1051963504,0,.9141593684,.3832947817,.131900567,0,-.107925319,.9245493968,.3654593525,0,.377977089,.3043148782,.8743716458,0,-.2142885215,-.8259286236,.5214617324,0,.5802544474,.4148098596,-.7008834116,0,-.1982660881,.8567161266,-.4761596756,0,-.03381553704,.3773180787,-.9254661404,0,-.6867922841,-.6656597827,.2919133642,0,.7731742607,-.2875793547,-.5652430251,0,-.09655941928,.9193708367,-.3813575004,0,.2715702457,-.9577909544,-.09426605581,0,.2451015704,-.6917998565,-.6792188003,0,.977700782,-.1753855374,.1155036542,0,-.5224739938,.8521606816,.02903615945,0,-.7734880599,-.5261292347,.3534179531,0,-.7134492443,-.269547243,.6467878011,0,.1644037271,.5105846203,-.8439637196,0,.6494635788,.05585611296,.7583384168,0,-.4711970882,.5017280509,-.7254255765,0,-.6335764307,-.2381686273,-.7361091029,0,-.9021533097,-.270947803,-.3357181763,0,-.3793711033,.872258117,.3086152025,0,-.6855598966,-.3250143309,.6514394162,0,.2900942212,-.7799057743,-.5546100667,0,-.2098319339,.85037073,.4825351604,0,-.4592603758,.6598504336,-.5947077538,0,.8715945488,.09616365406,-.4807031248,0,-.6776666319,.7118504878,-.1844907016,0,.7044377633,.312427597,.637304036,0,-.7052318886,-.2401093292,-.6670798253,0,.081921007,-.7207336136,-.6883545647,0,-.6993680906,-.5875763221,-.4069869034,0,-.1281454481,.6419895885,.7559286424,0,-.6337388239,-.6785471501,-.3714146849,0,.5565051903,-.2168887573,-.8020356851,0,-.5791554484,.7244372011,-.3738578718,0,.1175779076,-.7096451073,.6946792478,0,-.6134619607,.1323631078,.7785527795,0,.6984635305,-.02980516237,-.715024719,0,.8318082963,-.3930171956,.3919597455,0,.1469576422,.05541651717,-.9875892167,0,.708868575,-.2690503865,.6520101478,0,.2726053183,.67369766,-.68688995,0,-.6591295371,.3035458599,-.6880466294,0,.4815131379,-.7528270071,.4487723203,0,.9430009463,.1675647412,-.2875261255,0,.434802957,.7695304522,-.4677277752,0,.3931996188,.594473625,.7014236729,0,.7254336655,-.603925654,.3301814672,0,.7590235227,-.6506083235,.02433313207,0,-.8552768592,-.3430042733,.3883935666,0,-.6139746835,.6981725247,.3682257648,0,-.7465905486,-.5752009504,.3342849376,0,.5730065677,.810555537,-.1210916791,0,-.9225877367,-.3475211012,-.167514036,0,-.7105816789,-.4719692027,-.5218416899,0,-.08564609717,.3583001386,.929669703,0,-.8279697606,-.2043157126,.5222271202,0,.427944023,.278165994,.8599346446,0,.5399079671,-.7857120652,-.3019204161,0,.5678404253,-.5495413974,-.6128307303,0,-.9896071041,.1365639107,-.04503418428,0,-.6154342638,-.6440875597,.4543037336,0,.1074204368,-.7946340692,.5975094525,0,-.3595449969,-.8885529948,.28495784,0,-.2180405296,.1529888965,.9638738118,0,-.7277432317,-.6164050508,-.3007234646,0,.7249729114,-.00669719484,.6887448187,0,-.5553659455,-.5336586252,.6377908264,0,.5137558015,.7976208196,-.3160000073,0,-.3794024848,.9245608561,-.03522751494,0,.8229248658,.2745365933,-.4974176556,0,-.5404114394,.6091141441,.5804613989,0,.8036581901,-.2703029469,.5301601931,0,.6044318879,.6832968393,.4095943388,0,.06389988817,.9658208605,-.2512108074,0,.1087113286,.7402471173,-.6634877936,0,-.713427712,-.6926784018,.1059128479,0,.6458897819,-.5724548511,-.5050958653,0,-.6553931414,.7381471625,.159995615,0,.3910961323,.9188871375,-.05186755998,0,-.4879022471,-.5904376907,.6429111375,0,.6014790094,.7707441366,-.2101820095,0,-.5677173047,.7511360995,.3368851762,0,.7858573506,.226674665,.5753666838,0,-.4520345543,-.604222686,-.6561857263,0,.002272116345,.4132844051,-.9105991643,0,-.5815751419,-.5162925989,.6286591339,0,-.03703704785,.8273785755,.5604221175,0,-.5119692504,.7953543429,-.3244980058,0,-.2682417366,-.9572290247,-.1084387619,0,-.2322482736,-.9679131102,-.09594243324,0,.3554328906,-.8881505545,.2913006227,0,.7346520519,-.4371373164,.5188422971,0,.9985120116,.04659011161,-.02833944577,0,-.3727687496,-.9082481361,.1900757285,0,.91737377,-.3483642108,.1925298489,0,.2714911074,.4147529736,-.8684886582,0,.5131763485,-.7116334161,.4798207128,0,-.8737353606,.18886992,-.4482350644,0,.8460043821,-.3725217914,.3814499973,0,.8978727456,-.1780209141,-.4026575304,0,.2178065647,-.9698322841,-.1094789531,0,-.1518031304,-.7788918132,-.6085091231,0,-.2600384876,-.4755398075,-.8403819825,0,.572313509,-.7474340931,-.3373418503,0,-.7174141009,.1699017182,-.6756111411,0,-.684180784,.02145707593,-.7289967412,0,-.2007447902,.06555605789,-.9774476623,0,-.1148803697,-.8044887315,.5827524187,0,-.7870349638,.03447489231,.6159443543,0,-.2015596421,.6859872284,.6991389226,0,-.08581082512,-.10920836,-.9903080513,0,.5532693395,.7325250401,-.396610771,0,-.1842489331,-.9777375055,-.1004076743,0,.0775473789,-.9111505856,.4047110257,0,.1399838409,.7601631212,-.6344734459,0,.4484419361,-.845289248,.2904925424,0];_PrimeX=501125321;_PrimeY=1136930381;_PrimeZ=1720413743;static _Lerp(e,t,i){return e+i*(t-e)}static _InterpHermite(e){return e*e*(3-2*e)}static _InterpQuintic(e){return e*e*e*(e*(6*e-15)+10)}static _CubicLerp(e,t,i,s,a){let r=s-i-(e-t);return a*a*a*r+a*a*(e-t-r)+a*(i-e)+t}static _PingPong(e){return(e-=2*Math.trunc(.5*e))<1?e:2-e}_CalculateFractalBounding(){let e=Math.abs(this._Gain),t=e,i=1;for(let s=1;s>15,r&=254,s*this._Gradients2D[r]+a*this._Gradients2D[1|r]}_GradCoordR3(e,t,i,s,a,r,o){let l=this._HashR3(e,t,i,s);return l^=l>>15,l&=252,a*this._Gradients3D[l]+r*this._Gradients3D[1|l]+o*this._Gradients3D[2|l]}_GenNoiseSingleR2(e,t,i){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R2(e,t,i);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR2(e,t,i);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR2(e,t,i);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR2(e,t,i);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR2(e,t,i);case FastNoiseLite.NoiseType.Value:return this._SingleValueR2(e,t,i);default:return 0}}_GenNoiseSingleR3(e,t,i,s){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R3(e,t,i,s);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR3(e,t,i,s);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR3(e,t,i,s);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR3(e,t,i,s);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR3(e,t,i,s);case FastNoiseLite.NoiseType.Value:return this._SingleValueR3(e,t,i,s);default:return 0}}_UpdateTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:this._TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._TransformType3D=FastNoiseLite.TransformType3D.None}}}_UpdateWarpTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._WarpTransformType3D=FastNoiseLite.TransformType3D.None}}}_GenFractalFBmR2(e,t){let i=this._Seed,s=0,a=this._FractalBounding;for(let r=0;rp){let t=p+s,i=d+(s-1),a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l,h+this._PrimeY,t,i)}else{let t=p+(s-1),i=d+s,a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l+this._PrimeX,h,t,i)}return 99.83685446303647*(a+r+o)}_SingleOpenSimplex2R3(e,t,i,s){let a=Math.round(t),r=Math.round(i),o=Math.round(s),l=t-a,h=i-r,n=s-o,_=Math.trunc(-1-h|1),c=Math.trunc(-1-l|1),p=Math.trunc(-1-n|1),d=c*-l,m=_*-h,u=p*-n;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let R=0,L=.6-l*l-(h*h+n*n);for(let t=0;;t++){if(L>0&&(R+=L*L*(L*L)*this._GradCoordR3(e,a,r,o,l,h,n)),d>=m&&d>=u){let t=L+d+d;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a-c*this._PrimeX,r,o,l+c,h,n))}else if(m>d&&m>=u){let t=L+m+m;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r-_*this._PrimeY,o,l,h+_,n))}else{let t=L+u+u;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r,o-p*this._PrimeZ,l,h,n+p))}if(1===t)break;d=.5-d,m=.5-m,u=.5-u,l=c*d,h=_*m,n=p*u,L+=.75-d-(m+u),a+=c>>1&this._PrimeX,r+=_>>1&this._PrimeY,o+=p>>1&this._PrimeZ,c=-c,_=-_,p=-p,e=~e}return 32.69428253173828*R}_SingleOpenSimplex2SR2(e,t,i){const s=.21132486540518713;let a=Math.floor(t),r=Math.floor(i),o=t-a,l=i-r;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY);let h=a+this._PrimeX,n=r+this._PrimeY,_=(o+l)*s,c=o-_,p=l-_,d=2/3-c*c-p*p,m=d*d*(d*d)*this._GradCoordR2(e,a,r,c,p),u=3.1547005383792506*_+(-.6666666666666666+d),R=c-(1-2*s),L=p-(1-2*s);m+=u*u*(u*u)*this._GradCoordR2(e,h,n,R,L);let F=o-l;if(_>s){if(o+F>1){let t=c+(3*s-2),i=p+(3*s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+(this._PrimeX<<1),r+this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}if(l-F>1){let t=c+(3*s-1),i=p+(3*s-2),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r+(this._PrimeY<<1),t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}}else{if(o+F<0){let t=c+(1-s),i=p-s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a-this._PrimeX,r,t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}if(l0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r-this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}}return 18.24196194486065*m}_SingleOpenSimplex2SR3(e,t,i,s){let a=Math.floor(t),r=Math.floor(i),o=Math.floor(s),l=t-a,h=i-r,n=s-o;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let _=e+1293373,c=Math.trunc(-.5-l),p=Math.trunc(-.5-h),d=Math.trunc(-.5-n),m=l+c,u=h+p,R=n+d,L=.75-m*m-u*u-R*R,F=L*L*(L*L)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),m,u,R),D=l-.5,C=h-.5,N=n-.5,P=.75-D*D-C*C-N*N;F+=P*P*(P*P)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+this._PrimeZ,D,C,N);let V=((1|c)<<1)*D,y=((1|p)<<1)*C,T=((1|d)<<1)*N,f=(-2-(c<<2))*D-1,S=(-2-(p<<2))*C-1,g=(-2-(d<<2))*N-1,M=!1,G=V+L;if(G>0){let t=m-(1|c);F+=G*G*(G*G)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),t,u,R)}else{let t=y+T+L;if(t>0){let i=m,s=u-(1|p),l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=f+P;if(i>0){let e=(1|c)+D;F+=i*i*(i*i)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+this._PrimeZ,e,C,N),M=!0}}let b=!1,X=y+L;if(X>0){let t=m,i=u-(1|p);F+=X*X*(X*X)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),t,i,R)}else{let t=V+T+L;if(t>0){let i=m-(1|c),s=u,l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=S+P;if(i>0){let e=D,t=(1|p)+C;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+this._PrimeZ,e,t,N),b=!0}}let W=!1,Y=T+L;if(Y>0){let t=m,i=u,s=R-(1|d);F+=Y*Y*(Y*Y)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),t,i,s)}else{let t=V+y+L;if(t>0){let i=m-(1|c),s=u-(1|p);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),i,s,R)}let i=g+P;if(i>0){let e=D,t=C,s=(1|d)+N;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+(d&this._PrimeZ<<1),e,t,s),W=!0}}if(!M){let e=S+g+P;if(e>0){let t=D,i=(1|p)+C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+(d&this._PrimeZ<<1),t,i,s)}}if(!b){let e=f+g+P;if(e>0){let t=(1|c)+D,i=C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+(d&this._PrimeZ<<1),t,i,s)}}if(!W){let e=f+S+P;if(e>0){let t=(1|c)+D,i=(1|p)+C;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&this._PrimeX<<1),r+(p&this._PrimeY<<1),o+this._PrimeZ,t,i,N)}}return 9.046026385208288*F}_SingleCellularR2(e,t,i){let s=Math.round(t),a=Math.round(i),r=Number.MAX_VALUE,o=Number.MAX_VALUE,l=0,h=.43701595*this._CellularJitterModifier,n=(s-1)*this._PrimeX,_=(a-1)*this._PrimeY;switch(this._CellularDistanceFunction){default:case FastNoiseLite.CellularDistanceFunction.Euclidean:case FastNoiseLite.CellularDistanceFunction.EuclideanSq:for(let c=s-1;c<=s+1;c++){let s=_;for(let _=a-1;_<=a+1;_++){let a=this._HashR2(e,n,s),p=510&a,d=c-t+this._RandVecs2D[p]*h,m=_-i+this._RandVecs2D[1|p]*h,u=d*d+m*m;o=Math.max(Math.min(o,u),r),u{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,32.69428253173828*t,i,s,!1,a,r,o);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,7.71604938271605*t,i,s,!0,a,r,o);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r,o)}};return 6===arguments.length&&arguments[3]instanceof Vector2?((e,t,i,s,a,r)=>{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,38.283687591552734*t,i,s,!1,a,r);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,16*t,i,s,!0,a,r);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r)}})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]):7===arguments.length&&arguments[3]instanceof Vector3?e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]):void 0}_DomainWarpSingle(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y,o=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=a+r,t=-.211324865405187*e;o*=.577350269189626,a+=t-o,r=r+t-o,o+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=a+o,t=-.211324865405187*e;r*=.577350269189626,a+=t-r,o+=t-r,r+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let e=(a+r+o)*(2/3);a=e-a,r=e-r,o=e-o}this._DoSingleDomainWarp(t,i,s,e,a,r,o)};return 1===arguments.length&&arguments[0]instanceof Vector2?(e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(a+r)*(.5*(1.7320508075688772-1));a+=e,r+=e}this._DoSingleDomainWarp(t,i,s,e,a,r)})(arguments[0]):1===arguments.length&&arguments[0]instanceof Vector3?e(arguments[0]):void 0}_DomainWarpFractalProgressive(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=e.x,i=e.y,s=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=t+i,a=-.211324865405187*e;s*=.577350269189626,t+=a-s,i=i+a-s,s+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=t+s,a=-.211324865405187*e;i*=.577350269189626,t+=a-i,s+=a-i,i+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:{let e=(t+i+s)*(2/3);t=e-t,i=e-i,s=e-s}}let a=this._Seed,r=this._DomainWarpAmp*this._FractalBounding,o=this._Frequency;for(let l=0;l{let t=e.x,i=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(t+i)*(.5*(1.7320508075688772-1));t+=e,i+=e}let s=this._Seed,a=this._DomainWarpAmp*this._FractalBounding,r=this._Frequency;for(let o=0;o{let l=a*i,h=r*i,n=o*i,_=Math.floor(l),c=Math.floor(h),p=Math.floor(n),d=FastNoiseLite._InterpHermite(l-_),m=FastNoiseLite._InterpHermite(h-c),u=FastNoiseLite._InterpHermite(n-p);_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),p=Math.imul(p,this._PrimeZ);let R=_+this._PrimeX,L=c+this._PrimeY,F=p+this._PrimeZ,D=1020&this._HashR3(e,_,c,p),C=1020&this._HashR3(e,R,c,p),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d);D=1020&this._HashR3(e,_,L,p),C=1020&this._HashR3(e,R,L,p);let y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),S=FastNoiseLite._Lerp(N,y,m),g=FastNoiseLite._Lerp(P,T,m),M=FastNoiseLite._Lerp(V,f,m);D=1020&this._HashR3(e,_,c,F),C=1020&this._HashR3(e,R,c,F),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),D=1020&this._HashR3(e,_,L,F),C=1020&this._HashR3(e,R,L,F),y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),s.x+=FastNoiseLite._Lerp(S,FastNoiseLite._Lerp(N,y,m),u)*t,s.y+=FastNoiseLite._Lerp(g,FastNoiseLite._Lerp(P,T,m),u)*t,s.z+=FastNoiseLite._Lerp(M,FastNoiseLite._Lerp(V,f,m),u)*t};6===arguments.length&&arguments[3]instanceof Vector2&&((e,t,i,s,a,r)=>{let o=a*i,l=r*i,h=Math.floor(o),n=Math.floor(l),_=FastNoiseLite._InterpHermite(o-h),c=FastNoiseLite._InterpHermite(l-n);h=Math.imul(h,this._PrimeX),n=Math.imul(n,this._PrimeY);let p=h+this._PrimeX,d=n+this._PrimeY,m=510&this._HashR2(e,h,n),u=510&this._HashR2(e,p,n),R=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),L=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);m=510&this._HashR2(e,h,d),u=510&this._HashR2(e,p,d);let F=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),D=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);s.x+=FastNoiseLite._Lerp(R,F,c)*t,s.y+=FastNoiseLite._Lerp(L,D,c)*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]),7===arguments.length&&arguments[3]instanceof Vector3&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6])}_SingleDomainWarpOpenSimplex2Gradient(){let e=(e,t,i,s,a,r,o,l)=>{r*=i,o*=i,l*=i;let h,n,_,c=Math.round(r),p=Math.round(o),d=Math.round(l),m=r-c,u=o-p,R=l-d,L=-m-1|1,F=-u-1|1,D=-R-1|1,C=L*-m,N=F*-u,P=D*-R;c=Math.imul(c,this._PrimeX),p=Math.imul(p,this._PrimeY),d=Math.imul(d,this._PrimeZ),h=n=_=0;let V=.6-m*m-(u*u+R*R);for(let t=0;;t++){if(V>0){let t,i,s,r=V*V*(V*V);if(a){let a=1020&this._HashR3(e,c,p,d);t=this._RandVecs3D[a],i=this._RandVecs3D[1|a],s=this._RandVecs3D[2|a]}else{let a=this._HashR3(e,c,p,d),r=252&a,o=a>>6&1020,l=m*this._Gradients3D[r]+u*this._Gradients3D[1|r]+R*this._Gradients3D[2|r];t=l*this._RandVecs3D[o],i=l*this._RandVecs3D[1|o],s=l*this._RandVecs3D[2|o]}h+=r*t,n+=r*i,_+=r*s}let i=V,s=c,r=p,o=d,l=m,y=u,T=R;if(C>=N&&C>=P?(l+=L,i=i+C+C,s-=L*this._PrimeX):N>C&&N>=P?(y+=F,i=i+N+N,r-=F*this._PrimeY):(T+=D,i=i+P+P,o-=D*this._PrimeZ),i>1){i-=1;let t,c,p,d=i*i*(i*i);if(a){let i=1020&this._HashR3(e,s,r,o);t=this._RandVecs3D[i],c=this._RandVecs3D[1|i],p=this._RandVecs3D[2|i]}else{let i=this._HashR3(e,s,r,o),a=252&i,h=i>>6&1020,n=l*this._Gradients3D[a]+y*this._Gradients3D[1|a]+T*this._Gradients3D[2|a];t=n*this._RandVecs3D[h],c=n*this._RandVecs3D[1|h],p=n*this._RandVecs3D[2|h]}h+=d*t,n+=d*c,_+=d*p}if(1===t)break;C=.5-C,N=.5-N,P=.5-P,m=L*C,u=F*N,R=D*P,V+=.75-C-(N+P),c+=L>>1&this._PrimeX,p+=F>>1&this._PrimeY,d+=D>>1&this._PrimeZ,L=-L,F=-F,D=-D,e+=1293373}s.x+=h*t,s.y+=n*t,s.z+=_*t};7===arguments.length&&((e,t,i,s,a,r,o)=>{const l=.21132486540518713;r*=i,o*=i;let h,n,_=Math.floor(r),c=Math.floor(o),p=r-_,d=o-c,m=(p+d)*l,u=p-m,R=d-m;_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),h=n=0;let L=.5-u*u-R*R;if(L>0){let t,i,s=L*L*(L*L);if(a){let s=510&this._HashR2(e,_,c);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let s=this._HashR2(e,_,c),a=254&s,r=s>>7&510,o=u*this._Gradients2D[a]+R*this._Gradients2D[1|a];t=o*this._RandVecs2D[r],i=o*this._RandVecs2D[1|r]}h+=s*t,n+=s*i}let F=3.1547005383792506*m+(-.6666666666666666+L);if(F>0){let t,i,s=u+(2*l-1),r=R+(2*l-1),o=F*F*(F*F);if(a){let s=510&this._HashR2(e,_+this._PrimeX,c+this._PrimeY);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let a=this._HashR2(e,_+this._PrimeX,c+this._PrimeY),o=254&a,l=a>>7&510,h=s*this._Gradients2D[o]+r*this._Gradients2D[1|o];t=h*this._RandVecs2D[l],i=h*this._RandVecs2D[1|l]}h+=o*t,n+=o*i}if(R>u){let t=u+l,i=R+(l-1),s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_,c+this._PrimeY);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_,c+this._PrimeY),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}else{let t=u+(l-1),i=R+l,s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_+this._PrimeX,c);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_+this._PrimeX,c),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}s.x+=h*t,s.y+=n*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]),8===arguments.length&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7])}}class Vector2{constructor(e,t){this.x=e,this.y=t}}class Vector3{constructor(e,t,i){this.x=e,this.y=t,this.z=i}} /* eslint-enable */ /* prettier-enable */ +======= + class FastNoiseLite { + static NoiseType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2S: "OpenSimplex2S", + Cellular: "Cellular", + Perlin: "Perlin", + ValueCubic: "ValueCubic", + Value: "Value", + }); + static RotationType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + }); + static FractalType = Object.freeze({ + None: "None", + FBm: "FBm", + Ridged: "Ridged", + PingPong: "PingPong", + DomainWarpProgressive: "DomainWarpProgressive", + DomainWarpIndependent: "DomainWarpIndependent", + }); + static CellularDistanceFunction = Object.freeze({ + Euclidean: "Euclidean", + EuclideanSq: "EuclideanSq", + Manhattan: "Manhattan", + Hybrid: "Hybrid", + }); + static CellularReturnType = Object.freeze({ + CellValue: "CellValue", + Distance: "Distance", + Distance2: "Distance2", + Distance2Add: "Distance2Add", + Distance2Sub: "Distance2Sub", + Distance2Mul: "Distance2Mul", + Distance2Div: "Distance2Div", + }); + static DomainWarpType = Object.freeze({ + OpenSimplex2: "OpenSimplex2", + OpenSimplex2Reduced: "OpenSimplex2Reduced", + BasicGrid: "BasicGrid", + }); + static TransformType3D = Object.freeze({ + None: "None", + ImproveXYPlanes: "ImproveXYPlanes", + ImproveXZPlanes: "ImproveXZPlanes", + DefaultOpenSimplex2: "DefaultOpenSimplex2", + }); + + /* Private */ + _Seed = 1337; + _Frequency = 0.01; + _NoiseType = FastNoiseLite.NoiseType.OpenSimplex2; + _RotationType3D = FastNoiseLite.RotationType3D.None; + _TransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + _DomainWarpAmp = 1.0; + + _FractalType = FastNoiseLite.FractalType.None; + _Octaves = 3; + _Lacunarity = 2.0; + _Gain = 0.5; + _WeightedStrength = 0.0; + _PingPongStrength = 2.0; + + _FractalBounding = 1 / 1.75; + + _CellularDistanceFunction = + FastNoiseLite.CellularDistanceFunction.EuclideanSq; + _CellularReturnType = FastNoiseLite.CellularReturnType.Distance; + _CellularJitterModifier = 1.0; + + _DomainWarpType = FastNoiseLite.DomainWarpType.OpenSimplex2; + _WarpTransformType3D = FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + + /** + * @description Create new FastNoiseLite object with optional seed + * @param {number} [seed] + * @constructor + */ + constructor(seed) { + if (seed !== undefined) { + this._Seed = seed; + } + } + + /** + * @description Sets seed used for all noise types + * @remarks Default: 1337 + * @default 1337 + * @param {number} seed + */ + SetSeed(seed) { + this._Seed = seed; + } + + /** + * @description Sets frequency for all noise types + * @remarks Default: 0.01 + * @default 0.01 + * @param {number} frequency + */ + SetFrequency(frequency) { + this._Frequency = frequency; + } + + /** + * @description Sets noise algorithm used for GetNoise(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.NoiseType.OpenSimplex2 + * @param {FastNoiseLite.NoiseType} noiseType + */ + SetNoiseType(noiseType) { + this._NoiseType = noiseType; + this._UpdateTransformType3D(); + } + + /** + * @description Sets domain rotation type for 3D Noise and 3D DomainWarp. + * @description Can aid in reducing directional artifacts when sampling a 2D plane in 3D + * @remarks Default: None + * @default FastNoiseLite.RotationType3D.None + * @param {FastNoiseLite.RotationType3D} rotationType3D + */ + SetRotationType3D(rotationType3D) { + this._RotationType3D = rotationType3D; + this._UpdateTransformType3D(); + this._UpdateWarpTransformType3D(); + } + + /** + * @description Sets method for combining octaves in all fractal noise types + * @remarks Default: None + * @default FastNoiseLite.FractalType.None + * @param {FastNoiseLite.FractalType} fractalType + */ + SetFractalType(fractalType) { + this._FractalType = fractalType; + } + + /** + * @description Sets octave count for all fractal noise types + * @remarks Default: 3 + * @default 3 + * @param {number} octaves + */ + SetFractalOctaves(octaves) { + this._Octaves = octaves; + this._CalculateFractalBounding(); + } + + /** + * @description Sets octave lacunarity for all fractal noise types + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} lacunarity + */ + SetFractalLacunarity(lacunarity) { + this._Lacunarity = lacunarity; + } + + /** + * @description Sets octave gain for all fractal noise types + * @remarks Default: 0.5 + * @default 0.5 + * @param {number} gain + */ + SetFractalGain(gain) { + this._Gain = gain; + this._CalculateFractalBounding(); + } + + /** + * @description Sets octave weighting for all none DomainWarp fratal types + * @remarks Default: 0.0 | Keep between 0...1 to maintain -1...1 output bounding + * @default 0.5 + * @param {number} weightedStrength + */ + SetFractalWeightedStrength(weightedStrength) { + this._WeightedStrength = weightedStrength; + } + + /** + * @description Sets strength of the fractal ping pong effect + * @remarks Default: 2.0 + * @default 2.0 + * @param {number} pingPongStrength + */ + SetFractalPingPongStrength(pingPongStrength) { + this._PingPongStrength = pingPongStrength; + } + + /** + * @description Sets distance function used in cellular noise calculations + * @remarks Default: EuclideanSq + * @default FastNoiseLite.CellularDistanceFunction.EuclideanSq + * @param {FastNoiseLite.CellularDistanceFunction} cellularDistanceFunction + */ + SetCellularDistanceFunction(cellularDistanceFunction) { + this._CellularDistanceFunction = cellularDistanceFunction; + } + + /** + * @description Sets return type from cellular noise calculations + * @remarks Default: Distance + * @default FastNoiseLite.CellularReturnType.Distance + * @param {FastNoiseLite.CellularReturnType} cellularReturnType + */ + SetCellularReturnType(cellularReturnType) { + this._CellularReturnType = cellularReturnType; + } + + /** + * @description Sets the maximum distance a cellular point can move from it's grid position + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} cellularJitter + */ + SetCellularJitter(cellularJitter) { + this._CellularJitterModifier = cellularJitter; + } + + /** + * @description Sets the warp algorithm when using DomainWarp(...) + * @remarks Default: OpenSimplex2 + * @default FastNoiseLite.DomainWarpType.OpenSimplex2 + * @param {FastNoiseLite.DomainWarpType} domainWarpType + */ + SetDomainWarpType(domainWarpType) { + this._DomainWarpType = domainWarpType; + this._UpdateWarpTransformType3D(); + } + + /** + * @description Sets the maximum warp distance from original position when using DomainWarp(...) + * @remarks Default: 1.0 + * @default 1.0 + * @param {number} domainWarpAmp + */ + SetDomainWarpAmp(domainWarpAmp) { + this._DomainWarpAmp = domainWarpAmp; + } + + /** + * @description 2D/3D noise at given position using current settings + * @param {number} x X coordinate + * @param {number} y Y coordinate + * @param {number} [z] Z coordinate + * @return {number} Noise output bounded between -1...1 + */ + GetNoise(x, y, z) { + /** + * @description 2D noise at given position using current settings + * @param {number} x + * @param {number} y + * @return {number} Noise output bounded between -1...1 + */ + let R2 = (x, y) => { + x *= this._Frequency; + y *= this._Frequency; + + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (x + y) * F2; + x += t; + y += t; + break; + } + default: + break; + } + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR2(this._Seed, x, y); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR2(x, y); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR2(x, y); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR2(x, y); + } + }; + + /** + * @description 3D noise at given position using current settings + * @param {number} x + * @param {number} y + * @param {number} z + * @return {number} Noise output bounded between -1...1 + */ + let R3 = (x, y, z) => { + x *= this._Frequency; + y *= this._Frequency; + z *= this._Frequency; + + switch (this._TransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: { + let xy = x + y; + let s2 = xy * -0.211324865405187; + z *= 0.577350269189626; + x += s2 - z; + y += s2 - z; + z += xy * 0.577350269189626; + break; + } + case FastNoiseLite.TransformType3D.ImproveXZPlanes: { + let xz = x + z; + let s2 = xz * -0.211324865405187; + y *= 0.577350269189626; + x += s2 - y; + z += s2 - y; + y += xz * 0.577350269189626; + break; + } + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + const R3 = 2.0 / 3.0; + let r = (x + y + z) * R3; + x = r - x; + y = r - y; + z = r - z; + break; + } + default: + break; + } + + switch (this._FractalType) { + default: + return this._GenNoiseSingleR3(this._Seed, x, y, z); + case FastNoiseLite.FractalType.FBm: + return this._GenFractalFBmR3(x, y, z); + case FastNoiseLite.FractalType.Ridged: + return this._GenFractalRidgedR3(x, y, z); + case FastNoiseLite.FractalType.PingPong: + return this._GenFractalPingPongR3(x, y, z); + } + }; + + if (arguments.length === 2) { + return R2(x, y); + } + + if (arguments.length === 3) { + return R3(x, y, z); + } + } + + /** + * @description 2D/3D warps the input position using current domain warp settings + * @param {Vector2|Vector3} coord + */ + DomainWrap(coord) { + switch (this._FractalType) { + default: + this._DomainWarpSingle(coord); + break; + case FastNoiseLite.FractalType.DomainWarpProgressive: + this._DomainWarpFractalProgressive(coord); + break; + case FastNoiseLite.FractalType.DomainWarpIndependent: + this._DomainWarpFractalIndependent(coord); + break; + } + } + + // prettier-ignore + _Gradients2D = [ + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, + 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, + 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, + -0.130526192220052, -0.99144486137381, -0.38268343236509, -0.923879532511287, -0.608761429008721, -0.793353340291235, -0.793353340291235, -0.608761429008721, + -0.923879532511287, -0.38268343236509, -0.99144486137381, -0.130526192220052, -0.99144486137381, 0.130526192220051, -0.923879532511287, 0.38268343236509, + -0.793353340291235, 0.608761429008721, -0.608761429008721, 0.793353340291235, -0.38268343236509, 0.923879532511287, -0.130526192220052, 0.99144486137381, + 0.38268343236509, 0.923879532511287, 0.923879532511287, 0.38268343236509, 0.923879532511287, -0.38268343236509, 0.38268343236509, -0.923879532511287, + -0.38268343236509, -0.923879532511287, -0.923879532511287, -0.38268343236509, -0.923879532511287, 0.38268343236509, -0.38268343236509, 0.923879532511287, + ]; + + // prettier-ignore + _RandVecs2D = [ + -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, + -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, + -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, + -0.8659131224, -0.5001944266, 0.0879458407, -0.9961252577, -0.5051684983, 0.8630207346, 0.7753185226, -0.6315704146, -0.6921944612, 0.7217110418, -0.5191659449, -0.8546734591, 0.8978622882, -0.4402764035, -0.1706774107, 0.9853269617, + -0.9353430106, -0.3537420705, -0.9992404798, 0.03896746794, -0.2882064021, -0.9575683108, -0.9663811329, 0.2571137995, -0.8759714238, -0.4823630009, -0.8303123018, -0.5572983775, 0.05110133755, -0.9986934731, -0.8558373281, -0.5172450752, + 0.09887025282, 0.9951003332, 0.9189016087, 0.3944867976, -0.2439375892, -0.9697909324, -0.8121409387, -0.5834613061, -0.9910431363, 0.1335421355, 0.8492423985, -0.5280031709, -0.9717838994, -0.2358729591, 0.9949457207, 0.1004142068, + 0.6241065508, -0.7813392434, 0.662910307, 0.7486988212, -0.7197418176, 0.6942418282, -0.8143370775, -0.5803922158, 0.104521054, -0.9945226741, -0.1065926113, -0.9943027784, 0.445799684, -0.8951327509, 0.105547406, 0.9944142724, + -0.992790267, 0.1198644477, -0.8334366408, 0.552615025, 0.9115561563, -0.4111755999, 0.8285544909, -0.5599084351, 0.7217097654, -0.6921957921, 0.4940492677, -0.8694339084, -0.3652321272, -0.9309164803, -0.9696606758, 0.2444548501, + 0.08925509731, -0.996008799, 0.5354071276, -0.8445941083, -0.1053576186, 0.9944343981, -0.9890284586, 0.1477251101, 0.004856104961, 0.9999882091, 0.9885598478, 0.1508291331, 0.9286129562, -0.3710498316, -0.5832393863, -0.8123003252, + 0.3015207509, 0.9534596146, -0.9575110528, 0.2883965738, 0.9715802154, -0.2367105511, 0.229981792, 0.9731949318, 0.955763816, -0.2941352207, 0.740956116, 0.6715534485, -0.9971513787, -0.07542630764, 0.6905710663, -0.7232645452, + -0.290713703, -0.9568100872, 0.5912777791, -0.8064679708, -0.9454592212, -0.325740481, 0.6664455681, 0.74555369, 0.6236134912, 0.7817328275, 0.9126993851, -0.4086316587, -0.8191762011, 0.5735419353, -0.8812745759, -0.4726046147, + 0.9953313627, 0.09651672651, 0.9855650846, -0.1692969699, -0.8495980887, 0.5274306472, 0.6174853946, -0.7865823463, 0.8508156371, 0.52546432, 0.9985032451, -0.05469249926, 0.1971371563, -0.9803759185, 0.6607855748, -0.7505747292, + -0.03097494063, 0.9995201614, -0.6731660801, 0.739491331, -0.7195018362, -0.6944905383, 0.9727511689, 0.2318515979, 0.9997059088, -0.0242506907, 0.4421787429, -0.8969269532, 0.9981350961, -0.061043673, -0.9173660799, -0.3980445648, + -0.8150056635, -0.5794529907, -0.8789331304, 0.4769450202, 0.0158605829, 0.999874213, -0.8095464474, 0.5870558317, -0.9165898907, -0.3998286786, -0.8023542565, 0.5968480938, -0.5176737917, 0.8555780767, -0.8154407307, -0.5788405779, + 0.4022010347, -0.9155513791, -0.9052556868, -0.4248672045, 0.7317445619, 0.6815789728, -0.5647632201, -0.8252529947, -0.8403276335, -0.5420788397, -0.9314281527, 0.363925262, 0.5238198472, 0.8518290719, 0.7432803869, -0.6689800195, + -0.985371561, -0.1704197369, 0.4601468731, 0.88784281, 0.825855404, 0.5638819483, 0.6182366099, 0.7859920446, 0.8331502863, -0.553046653, 0.1500307506, 0.9886813308, -0.662330369, -0.7492119075, -0.668598664, 0.743623444, + 0.7025606278, 0.7116238924, -0.5419389763, -0.8404178401, -0.3388616456, 0.9408362159, 0.8331530315, 0.5530425174, -0.2989720662, -0.9542618632, 0.2638522993, 0.9645630949, 0.124108739, -0.9922686234, -0.7282649308, -0.6852956957, + 0.6962500149, 0.7177993569, -0.9183535368, 0.3957610156, -0.6326102274, -0.7744703352, -0.9331891859, -0.359385508, -0.1153779357, -0.9933216659, 0.9514974788, -0.3076565421, -0.08987977445, -0.9959526224, 0.6678496916, 0.7442961705, + 0.7952400393, -0.6062947138, -0.6462007402, -0.7631674805, -0.2733598753, 0.9619118351, 0.9669590226, -0.254931851, -0.9792894595, 0.2024651934, -0.5369502995, -0.8436138784, -0.270036471, -0.9628500944, -0.6400277131, 0.7683518247, + -0.7854537493, -0.6189203566, 0.06005905383, -0.9981948257, -0.02455770378, 0.9996984141, -0.65983623, 0.751409442, -0.6253894466, -0.7803127835, -0.6210408851, -0.7837781695, 0.8348888491, 0.5504185768, -0.1592275245, 0.9872419133, + 0.8367622488, 0.5475663786, -0.8675753916, -0.4973056806, -0.2022662628, -0.9793305667, 0.9399189937, 0.3413975472, 0.9877404807, -0.1561049093, -0.9034455656, 0.4287028224, 0.1269804218, -0.9919052235, -0.3819600854, 0.924178821, + 0.9754625894, 0.2201652486, -0.3204015856, -0.9472818081, -0.9874760884, 0.1577687387, 0.02535348474, -0.9996785487, 0.4835130794, -0.8753371362, -0.2850799925, -0.9585037287, -0.06805516006, -0.99768156, -0.7885244045, -0.6150034663, + 0.3185392127, -0.9479096845, 0.8880043089, 0.4598351306, 0.6476921488, -0.7619021462, 0.9820241299, 0.1887554194, 0.9357275128, -0.3527237187, -0.8894895414, 0.4569555293, 0.7922791302, 0.6101588153, 0.7483818261, 0.6632681526, + -0.7288929755, -0.6846276581, 0.8729032783, -0.4878932944, 0.8288345784, 0.5594937369, 0.08074567077, 0.9967347374, 0.9799148216, -0.1994165048, -0.580730673, -0.8140957471, -0.4700049791, -0.8826637636, 0.2409492979, 0.9705377045, + 0.9437816757, -0.3305694308, -0.8927998638, -0.4504535528, -0.8069622304, 0.5906030467, 0.06258973166, 0.9980393407, -0.9312597469, 0.3643559849, 0.5777449785, 0.8162173362, -0.3360095855, -0.941858566, 0.697932075, -0.7161639607, + -0.002008157227, -0.9999979837, -0.1827294312, -0.9831632392, -0.6523911722, 0.7578824173, -0.4302626911, -0.9027037258, -0.9985126289, -0.05452091251, -0.01028102172, -0.9999471489, -0.4946071129, 0.8691166802, -0.2999350194, 0.9539596344, + 0.8165471961, 0.5772786819, 0.2697460475, 0.962931498, -0.7306287391, -0.6827749597, -0.7590952064, -0.6509796216, -0.907053853, 0.4210146171, -0.5104861064, -0.8598860013, 0.8613350597, 0.5080373165, 0.5007881595, -0.8655698812, + -0.654158152, 0.7563577938, -0.8382755311, -0.545246856, 0.6940070834, 0.7199681717, 0.06950936031, 0.9975812994, 0.1702942185, -0.9853932612, 0.2695973274, 0.9629731466, 0.5519612192, -0.8338697815, 0.225657487, -0.9742067022, + 0.4215262855, -0.9068161835, 0.4881873305, -0.8727388672, -0.3683854996, -0.9296731273, -0.9825390578, 0.1860564427, 0.81256471, 0.5828709909, 0.3196460933, -0.9475370046, 0.9570913859, 0.2897862643, -0.6876655497, -0.7260276109, + -0.9988770922, -0.047376731, -0.1250179027, 0.992154486, -0.8280133617, 0.560708367, 0.9324863769, -0.3612051451, 0.6394653183, 0.7688199442, -0.01623847064, -0.9998681473, -0.9955014666, -0.09474613458, -0.81453315, 0.580117012, + 0.4037327978, -0.9148769469, 0.9944263371, 0.1054336766, -0.1624711654, 0.9867132919, -0.9949487814, -0.100383875, -0.6995302564, 0.7146029809, 0.5263414922, -0.85027327, -0.5395221479, 0.841971408, 0.6579370318, 0.7530729462, + 0.01426758847, -0.9998982128, -0.6734383991, 0.7392433447, 0.639412098, -0.7688642071, 0.9211571421, 0.3891908523, -0.146637214, -0.9891903394, -0.782318098, 0.6228791163, -0.5039610839, -0.8637263605, -0.7743120191, -0.6328039957, + ]; + + // prettier-ignore + _Gradients3D = [ + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, + 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, + 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, + 1, 1, 0, 0, 0, -1, 1, 0, -1, 1, 0, 0, 0, -1, -1, 0 + ]; + + // prettier-ignore + _RandVecs3D = [ + -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, + 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, + -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, + -0.7261455366, -0.5911990757, 0.3509933228, 0, -0.9229274737, -0.1782808786, 0.3412049336, 0, -0.6968815002, 0.6511274338, 0.3006480328, 0, 0.9608044783, -0.2098363234, -0.1811724921, 0, 0.06817146062, -0.9743405129, 0.2145069156, 0, -0.3577285196, -0.6697087264, -0.6507845481, 0, -0.1868621131, 0.7648617052, -0.6164974636, 0, -0.6541697588, 0.3967914832, 0.6439087246, 0, + 0.6993340405, -0.6164538506, 0.3618239211, 0, -0.1546665739, 0.6291283928, 0.7617583057, 0, -0.6841612949, -0.2580482182, -0.6821542638, 0, 0.5383980957, 0.4258654885, 0.7271630328, 0, -0.5026987823, -0.7939832935, -0.3418836993, 0, 0.3202971715, 0.2834415347, 0.9039195862, 0, 0.8683227101, -0.0003762656404, -0.4959995258, 0, 0.791120031, -0.08511045745, 0.6057105799, 0, + -0.04011016052, -0.4397248749, 0.8972364289, 0, 0.9145119872, 0.3579346169, -0.1885487608, 0, -0.9612039066, -0.2756484276, 0.01024666929, 0, 0.6510361721, -0.2877799159, -0.7023778346, 0, -0.2041786351, 0.7365237271, 0.644859585, 0, -0.7718263711, 0.3790626912, 0.5104855816, 0, -0.3060082741, -0.7692987727, 0.5608371729, 0, 0.454007341, -0.5024843065, 0.7357899537, 0, + 0.4816795475, 0.6021208291, -0.6367380315, 0, 0.6961980369, -0.3222197429, 0.641469197, 0, -0.6532160499, -0.6781148932, 0.3368515753, 0, 0.5089301236, -0.6154662304, -0.6018234363, 0, -0.1635919754, -0.9133604627, -0.372840892, 0, 0.52408019, -0.8437664109, 0.1157505864, 0, 0.5902587356, 0.4983817807, -0.6349883666, 0, 0.5863227872, 0.494764745, 0.6414307729, 0, + 0.6779335087, 0.2341345225, 0.6968408593, 0, 0.7177054546, -0.6858979348, 0.120178631, 0, -0.5328819713, -0.5205125012, 0.6671608058, 0, -0.8654874251, -0.0700727088, -0.4960053754, 0, -0.2861810166, 0.7952089234, 0.5345495242, 0, -0.04849529634, 0.9810836427, -0.1874115585, 0, -0.6358521667, 0.6058348682, 0.4781800233, 0, 0.6254794696, -0.2861619734, 0.7258696564, 0, + -0.2585259868, 0.5061949264, -0.8227581726, 0, 0.02136306781, 0.5064016808, -0.8620330371, 0, 0.200111773, 0.8599263484, 0.4695550591, 0, 0.4743561372, 0.6014985084, -0.6427953014, 0, 0.6622993731, -0.5202474575, -0.5391679918, 0, 0.08084972818, -0.6532720452, 0.7527940996, 0, -0.6893687501, 0.0592860349, 0.7219805347, 0, -0.1121887082, -0.9673185067, 0.2273952515, 0, + 0.7344116094, 0.5979668656, -0.3210532909, 0, 0.5789393465, -0.2488849713, 0.7764570201, 0, 0.6988182827, 0.3557169806, -0.6205791146, 0, -0.8636845529, -0.2748771249, -0.4224826141, 0, -0.4247027957, -0.4640880967, 0.777335046, 0, 0.5257722489, -0.8427017621, 0.1158329937, 0, 0.9343830603, 0.316302472, -0.1639543925, 0, -0.1016836419, -0.8057303073, -0.5834887393, 0, + -0.6529238969, 0.50602126, -0.5635892736, 0, -0.2465286165, -0.9668205684, -0.06694497494, 0, -0.9776897119, -0.2099250524, -0.007368825344, 0, 0.7736893337, 0.5734244712, 0.2694238123, 0, -0.6095087895, 0.4995678998, 0.6155736747, 0, 0.5794535482, 0.7434546771, 0.3339292269, 0, -0.8226211154, 0.08142581855, 0.5627293636, 0, -0.510385483, 0.4703667658, 0.7199039967, 0, + -0.5764971849, -0.07231656274, -0.8138926898, 0, 0.7250628871, 0.3949971505, -0.5641463116, 0, -0.1525424005, 0.4860840828, -0.8604958341, 0, -0.5550976208, -0.4957820792, 0.667882296, 0, -0.1883614327, 0.9145869398, 0.357841725, 0, 0.7625556724, -0.5414408243, -0.3540489801, 0, -0.5870231946, -0.3226498013, -0.7424963803, 0, 0.3051124198, 0.2262544068, -0.9250488391, 0, + 0.6379576059, 0.577242424, -0.5097070502, 0, -0.5966775796, 0.1454852398, -0.7891830656, 0, -0.658330573, 0.6555487542, -0.3699414651, 0, 0.7434892426, 0.2351084581, 0.6260573129, 0, 0.5562114096, 0.8264360377, -0.0873632843, 0, -0.3028940016, -0.8251527185, 0.4768419182, 0, 0.1129343818, -0.985888439, -0.1235710781, 0, 0.5937652891, -0.5896813806, 0.5474656618, 0, + 0.6757964092, -0.5835758614, -0.4502648413, 0, 0.7242302609, -0.1152719764, 0.6798550586, 0, -0.9511914166, 0.0753623979, -0.2992580792, 0, 0.2539470961, -0.1886339355, 0.9486454084, 0, 0.571433621, -0.1679450851, -0.8032795685, 0, -0.06778234979, 0.3978269256, 0.9149531629, 0, 0.6074972649, 0.733060024, -0.3058922593, 0, -0.5435478392, 0.1675822484, 0.8224791405, 0, + -0.5876678086, -0.3380045064, -0.7351186982, 0, -0.7967562402, 0.04097822706, -0.6029098428, 0, -0.1996350917, 0.8706294745, 0.4496111079, 0, -0.02787660336, -0.9106232682, -0.4122962022, 0, -0.7797625996, -0.6257634692, 0.01975775581, 0, -0.5211232846, 0.7401644346, -0.4249554471, 0, 0.8575424857, 0.4053272873, -0.3167501783, 0, 0.1045223322, 0.8390195772, -0.5339674439, 0, + 0.3501822831, 0.9242524096, -0.1520850155, 0, 0.1987849858, 0.07647613266, 0.9770547224, 0, 0.7845996363, 0.6066256811, -0.1280964233, 0, 0.09006737436, -0.9750989929, -0.2026569073, 0, -0.8274343547, -0.542299559, 0.1458203587, 0, -0.3485797732, -0.415802277, 0.840000362, 0, -0.2471778936, -0.7304819962, -0.6366310879, 0, -0.3700154943, 0.8577948156, 0.3567584454, 0, + 0.5913394901, -0.548311967, -0.5913303597, 0, 0.1204873514, -0.7626472379, -0.6354935001, 0, 0.616959265, 0.03079647928, 0.7863922953, 0, 0.1258156836, -0.6640829889, -0.7369967419, 0, -0.6477565124, -0.1740147258, -0.7417077429, 0, 0.6217889313, -0.7804430448, -0.06547655076, 0, 0.6589943422, -0.6096987708, 0.4404473475, 0, -0.2689837504, -0.6732403169, -0.6887635427, 0, + -0.3849775103, 0.5676542638, 0.7277093879, 0, 0.5754444408, 0.8110471154, -0.1051963504, 0, 0.9141593684, 0.3832947817, 0.131900567, 0, -0.107925319, 0.9245493968, 0.3654593525, 0, 0.377977089, 0.3043148782, 0.8743716458, 0, -0.2142885215, -0.8259286236, 0.5214617324, 0, 0.5802544474, 0.4148098596, -0.7008834116, 0, -0.1982660881, 0.8567161266, -0.4761596756, 0, + -0.03381553704, 0.3773180787, -0.9254661404, 0, -0.6867922841, -0.6656597827, 0.2919133642, 0, 0.7731742607, -0.2875793547, -0.5652430251, 0, -0.09655941928, 0.9193708367, -0.3813575004, 0, 0.2715702457, -0.9577909544, -0.09426605581, 0, 0.2451015704, -0.6917998565, -0.6792188003, 0, 0.977700782, -0.1753855374, 0.1155036542, 0, -0.5224739938, 0.8521606816, 0.02903615945, 0, + -0.7734880599, -0.5261292347, 0.3534179531, 0, -0.7134492443, -0.269547243, 0.6467878011, 0, 0.1644037271, 0.5105846203, -0.8439637196, 0, 0.6494635788, 0.05585611296, 0.7583384168, 0, -0.4711970882, 0.5017280509, -0.7254255765, 0, -0.6335764307, -0.2381686273, -0.7361091029, 0, -0.9021533097, -0.270947803, -0.3357181763, 0, -0.3793711033, 0.872258117, 0.3086152025, 0, + -0.6855598966, -0.3250143309, 0.6514394162, 0, 0.2900942212, -0.7799057743, -0.5546100667, 0, -0.2098319339, 0.85037073, 0.4825351604, 0, -0.4592603758, 0.6598504336, -0.5947077538, 0, 0.8715945488, 0.09616365406, -0.4807031248, 0, -0.6776666319, 0.7118504878, -0.1844907016, 0, 0.7044377633, 0.312427597, 0.637304036, 0, -0.7052318886, -0.2401093292, -0.6670798253, 0, + 0.081921007, -0.7207336136, -0.6883545647, 0, -0.6993680906, -0.5875763221, -0.4069869034, 0, -0.1281454481, 0.6419895885, 0.7559286424, 0, -0.6337388239, -0.6785471501, -0.3714146849, 0, 0.5565051903, -0.2168887573, -0.8020356851, 0, -0.5791554484, 0.7244372011, -0.3738578718, 0, 0.1175779076, -0.7096451073, 0.6946792478, 0, -0.6134619607, 0.1323631078, 0.7785527795, 0, + 0.6984635305, -0.02980516237, -0.715024719, 0, 0.8318082963, -0.3930171956, 0.3919597455, 0, 0.1469576422, 0.05541651717, -0.9875892167, 0, 0.708868575, -0.2690503865, 0.6520101478, 0, 0.2726053183, 0.67369766, -0.68688995, 0, -0.6591295371, 0.3035458599, -0.6880466294, 0, 0.4815131379, -0.7528270071, 0.4487723203, 0, 0.9430009463, 0.1675647412, -0.2875261255, 0, + 0.434802957, 0.7695304522, -0.4677277752, 0, 0.3931996188, 0.594473625, 0.7014236729, 0, 0.7254336655, -0.603925654, 0.3301814672, 0, 0.7590235227, -0.6506083235, 0.02433313207, 0, -0.8552768592, -0.3430042733, 0.3883935666, 0, -0.6139746835, 0.6981725247, 0.3682257648, 0, -0.7465905486, -0.5752009504, 0.3342849376, 0, 0.5730065677, 0.810555537, -0.1210916791, 0, + -0.9225877367, -0.3475211012, -0.167514036, 0, -0.7105816789, -0.4719692027, -0.5218416899, 0, -0.08564609717, 0.3583001386, 0.929669703, 0, -0.8279697606, -0.2043157126, 0.5222271202, 0, 0.427944023, 0.278165994, 0.8599346446, 0, 0.5399079671, -0.7857120652, -0.3019204161, 0, 0.5678404253, -0.5495413974, -0.6128307303, 0, -0.9896071041, 0.1365639107, -0.04503418428, 0, + -0.6154342638, -0.6440875597, 0.4543037336, 0, 0.1074204368, -0.7946340692, 0.5975094525, 0, -0.3595449969, -0.8885529948, 0.28495784, 0, -0.2180405296, 0.1529888965, 0.9638738118, 0, -0.7277432317, -0.6164050508, -0.3007234646, 0, 0.7249729114, -0.00669719484, 0.6887448187, 0, -0.5553659455, -0.5336586252, 0.6377908264, 0, 0.5137558015, 0.7976208196, -0.3160000073, 0, + -0.3794024848, 0.9245608561, -0.03522751494, 0, 0.8229248658, 0.2745365933, -0.4974176556, 0, -0.5404114394, 0.6091141441, 0.5804613989, 0, 0.8036581901, -0.2703029469, 0.5301601931, 0, 0.6044318879, 0.6832968393, 0.4095943388, 0, 0.06389988817, 0.9658208605, -0.2512108074, 0, 0.1087113286, 0.7402471173, -0.6634877936, 0, -0.713427712, -0.6926784018, 0.1059128479, 0, + 0.6458897819, -0.5724548511, -0.5050958653, 0, -0.6553931414, 0.7381471625, 0.159995615, 0, 0.3910961323, 0.9188871375, -0.05186755998, 0, -0.4879022471, -0.5904376907, 0.6429111375, 0, 0.6014790094, 0.7707441366, -0.2101820095, 0, -0.5677173047, 0.7511360995, 0.3368851762, 0, 0.7858573506, 0.226674665, 0.5753666838, 0, -0.4520345543, -0.604222686, -0.6561857263, 0, + 0.002272116345, 0.4132844051, -0.9105991643, 0, -0.5815751419, -0.5162925989, 0.6286591339, 0, -0.03703704785, 0.8273785755, 0.5604221175, 0, -0.5119692504, 0.7953543429, -0.3244980058, 0, -0.2682417366, -0.9572290247, -0.1084387619, 0, -0.2322482736, -0.9679131102, -0.09594243324, 0, 0.3554328906, -0.8881505545, 0.2913006227, 0, 0.7346520519, -0.4371373164, 0.5188422971, 0, + 0.9985120116, 0.04659011161, -0.02833944577, 0, -0.3727687496, -0.9082481361, 0.1900757285, 0, 0.91737377, -0.3483642108, 0.1925298489, 0, 0.2714911074, 0.4147529736, -0.8684886582, 0, 0.5131763485, -0.7116334161, 0.4798207128, 0, -0.8737353606, 0.18886992, -0.4482350644, 0, 0.8460043821, -0.3725217914, 0.3814499973, 0, 0.8978727456, -0.1780209141, -0.4026575304, 0, + 0.2178065647, -0.9698322841, -0.1094789531, 0, -0.1518031304, -0.7788918132, -0.6085091231, 0, -0.2600384876, -0.4755398075, -0.8403819825, 0, 0.572313509, -0.7474340931, -0.3373418503, 0, -0.7174141009, 0.1699017182, -0.6756111411, 0, -0.684180784, 0.02145707593, -0.7289967412, 0, -0.2007447902, 0.06555605789, -0.9774476623, 0, -0.1148803697, -0.8044887315, 0.5827524187, 0, + -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 + ]; + + _PrimeX = 501125321; + _PrimeY = 1136930381; + _PrimeZ = 1720413743; + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} t + * @returns {number} + */ + static _Lerp(a, b, t) { + return a + t * (b - a); + } + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _InterpHermite(t) { + return t * t * (3 - 2 * t); + } + + /** + * @private + * @param t + * @returns {number} + */ + static _InterpQuintic(t) { + return t * t * t * (t * (t * 6 - 15) + 10); + } + + /** + * @private + * @param {number} a + * @param {number} b + * @param {number} c + * @param {number} d + * @param {number} t + * @returns {number} + */ + static _CubicLerp(a, b, c, d, t) { + const p = d - c - (a - b); + return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; + } + + /** + * @private + * @param {number} t + * @returns {number} + */ + static _PingPong(t) { + t -= Math.trunc(t * 0.5) * 2; + return t < 1 ? t : 2 - t; + } + + /** + * @private + */ + _CalculateFractalBounding() { + let gain = Math.abs(this._Gain); + let amp = gain; + let ampFractal = 1.0; + for (let i = 1; i < this._Octaves; i++) { + ampFractal += amp; + amp *= gain; + } + this._FractalBounding = 1 / ampFractal; + } + + /** + * @private + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @returns {number} + */ + _HashR2(seed, xPrimed, yPrimed) { + let hash = seed ^ xPrimed ^ yPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _HashR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = seed ^ xPrimed ^ yPrimed ^ zPrimed; + hash = Math.imul(hash, 0x27d4eb2d); + return hash; + } + + /** + * @private + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @returns {number} + */ + _ValCoordR2(seed, xPrimed, yPrimed) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @returns {number} + */ + _ValCoordR3(seed, xPrimed, yPrimed, zPrimed) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + + hash = Math.imul(hash, hash); + hash ^= hash << 19; + return hash * (1 / 2147483648.0); + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} xd + * @param {number} yd + * @returns {number} + */ + _GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + hash ^= hash >> 15; + hash &= 127 << 1; + + let xg = this._Gradients2D[hash]; + let yg = this._Gradients2D[hash | 1]; + + return xd * xg + yd * yg; + } + + /** + * + * @param {number} seed + * @param {number} xPrimed + * @param {number} yPrimed + * @param {number} zPrimed + * @param {number} xd + * @param {number} yd + * @param {number} zd + * @returns {number} + */ + _GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + hash ^= hash >> 15; + hash &= 63 << 2; + + let xg = this._Gradients3D[hash]; + let yg = this._Gradients3D[hash | 1]; + let zg = this._Gradients3D[hash | 2]; + + return xd * xg + yd * yg + zd * zg; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenNoiseSingleR2(seed, x, y) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R2(seed, x, y); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR2(seed, x, y); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR2(seed, x, y); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR2(seed, x, y); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR2(seed, x, y); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR2(seed, x, y); + default: + return 0; + } + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenNoiseSingleR3(seed, x, y, z) { + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + return this._SingleOpenSimplex2R3(seed, x, y, z); + case FastNoiseLite.NoiseType.OpenSimplex2S: + return this._SingleOpenSimplex2SR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Cellular: + return this._SingleCellularR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Perlin: + return this._SinglePerlinR3(seed, x, y, z); + case FastNoiseLite.NoiseType.ValueCubic: + return this._SingleValueCubicR3(seed, x, y, z); + case FastNoiseLite.NoiseType.Value: + return this._SingleValueR3(seed, x, y, z); + default: + return 0; + } + } + + /** + * @private + */ + _UpdateTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._TransformType3D = FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._NoiseType) { + case FastNoiseLite.NoiseType.OpenSimplex2: + case FastNoiseLite.NoiseType.OpenSimplex2S: + this._TransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; + default: + this._TransformType3D = FastNoiseLite.TransformType3D.None; + break; + } + break; + } + } + + /** + * @private + */ + _UpdateWarpTransformType3D() { + switch (this._RotationType3D) { + case FastNoiseLite.RotationType3D.ImproveXYPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXYPlanes; + break; + case FastNoiseLite.RotationType3D.ImproveXZPlanes: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.ImproveXZPlanes; + break; + default: + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._WarpTransformType3D = + FastNoiseLite.TransformType3D.DefaultOpenSimplex2; + break; + default: + this._WarpTransformType3D = FastNoiseLite.TransformType3D.None; + break; + } + break; + } + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalFBmR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR2(seed++, x, y); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + Math.min(noise + 1, 2) * 0.5, + this._WeightedStrength + ); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalFBmR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = this._GenNoiseSingleR3(seed++, x, y, z); + sum += noise * amp; + amp *= FastNoiseLite._Lerp( + 1.0, + (noise + 1) * 0.5, + this._WeightedStrength + ); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalRidgedR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR2(seed++, x, y)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalRidgedR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = Math.abs(this._GenNoiseSingleR3(seed++, x, y, z)); + sum += (noise * -2 + 1) * amp; + amp *= FastNoiseLite._Lerp(1.0, 1 - noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @returns {number} + */ + _GenFractalPingPongR2(x, y) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR2(seed++, x, y) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * @private + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _GenFractalPingPongR3(x, y, z) { + let seed = this._Seed; + let sum = 0; + let amp = this._FractalBounding; + + for (let i = 0; i < this._Octaves; i++) { + let noise = FastNoiseLite._PingPong( + (this._GenNoiseSingleR3(seed++, x, y, z) + 1) * this._PingPongStrength + ); + sum += (noise - 0.5) * 2 * amp; + amp *= FastNoiseLite._Lerp(1.0, noise, this._WeightedStrength); + + x *= this._Lacunarity; + y *= this._Lacunarity; + z *= this._Lacunarity; + amp *= this._Gain; + } + return sum; + } + + /** + * + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleOpenSimplex2R2(seed, x, y) { + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let n0, n1, n2; + + let a = 0.5 - x0 * x0 - y0 * y0; + + if (a <= 0) { + n0 = 0; + } else { + n0 = a * a * (a * a) * this._GradCoordR2(seed, i, j, x0, y0); + } + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + + if (c <= 0) { + n2 = 0; + } else { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + n2 = + c * + c * + (c * c) * + this._GradCoordR2(seed, i + this._PrimeX, j + this._PrimeY, x2, y2); + } + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = + b * + b * + (b * b) * + this._GradCoordR2(seed, i, j + this._PrimeY, x1, y1); + } + } else { + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b <= 0) { + n1 = 0; + } else { + n1 = + b * + b * + (b * b) * + this._GradCoordR2(seed, i + this._PrimeX, j, x1, y1); + } + } + return (n0 + n1 + n2) * 99.83685446303647; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleOpenSimplex2R3(seed, x, y, z) { + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let yNSign = Math.trunc((-1.0 - y0) | 1); + let xNSign = Math.trunc((-1.0 - x0) | 1); + let zNSign = Math.trunc((-1.0 - z0) | 1); + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let value = 0; + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + + for (let l = 0; ; l++) { + if (a > 0) { + value += + a * a * (a * a) * this._GradCoordR3(seed, i, j, k, x0, y0, z0); + } + + if (ax0 >= ay0 && ax0 >= az0) { + let b = a + ax0 + ax0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i - xNSign * this._PrimeX, + j, + k, + x0 + xNSign, + y0, + z0 + ); + } + } else if (ay0 > ax0 && ay0 >= az0) { + let b = a + ay0 + ay0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j - yNSign * this._PrimeY, + k, + x0, + y0 + yNSign, + z0 + ); + } + } else { + let b = a + az0 + az0; + if (b > 1) { + b -= 1; + value += + b * + b * + (b * b) * + this._GradCoordR3( + seed, + i, + j, + k - zNSign * this._PrimeZ, + x0, + y0, + z0 + zNSign + ); + } + } + + if (l === 1) { + break; + } + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed = ~seed; + } + return value * 32.69428253173828125; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleOpenSimplex2SR2(seed, x, y) { + // 2D OpenSimplex2S case is a modified 2D simplex noise. + + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + /* + * --- Skew moved to TransformNoiseCoordinate method --- + * final FNLfloat F2 = 0.5f * (SQRT3 - 1); + * FNLfloat s = (x + y) * F2; + * x += s; y += s; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + let i1 = i + this._PrimeX; + let j1 = j + this._PrimeY; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; + let value = a0 * a0 * (a0 * a0) * this._GradCoordR2(seed, i, j, x0, y0); + let a1 = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); + let x1 = x0 - (1 - 2 * G2); + let y1 = y0 - (1 - 2 * G2); + value += a1 * a1 * (a1 * a1) * this._GradCoordR2(seed, i1, j1, x1, y1); + + // Nested conditionals were faster than compact bit logic/arithmetic. + let xmyi = xi - yi; + if (t > G2) { + if (xi + xmyi > 1) { + let x2 = x0 + (3 * G2 - 2); + let y2 = y0 + (3 * G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2( + seed, + i + (this._PrimeX << 1), + j + this._PrimeY, + x2, + y2 + ); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); + } + } + + if (yi - xmyi > 1) { + let x3 = x0 + (3 * G2 - 1); + let y3 = y0 + (3 * G2 - 2); + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2( + seed, + i + this._PrimeX, + j + (this._PrimeY << 1), + x3, + y3 + ); + } + } else { + let x3 = x0 + (G2 - 1); + let y3 = y0 + G2; + let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; + if (a3 > 0) { + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR2(seed, i + this._PrimeX, j, x3, y3); + } + } + } else { + if (xi + xmyi < 0) { + let x2 = x0 + (1 - G2); + let y2 = y0 - G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i - this._PrimeX, j, x2, y2); + } + } else { + let x2 = x0 + (G2 - 1); + let y2 = y0 + G2; + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i + this._PrimeX, j, x2, y2); + } + } + + if (yi < xmyi) { + let x2 = x0 - G2; + let y2 = y0 - (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j - this._PrimeY, x2, y2); + } + } else { + let x2 = x0 + G2; + let y2 = y0 + (G2 - 1); + let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; + if (a2 > 0) { + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR2(seed, i, j + this._PrimeY, x2, y2); + } + } + } + + return value * 18.24196194486065; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleOpenSimplex2SR3(seed, x, y, z) { + // 3D OpenSimplex2S case uses two offset rotated cube grids. + + /* + * --- Rotation moved to TransformNoiseCoordinate method --- + * final FNLfloat R3 = (FNLfloat)(2.0 / 3.0); + * FNLfloat r = (x + y + z) * R3; // Rotation, not skew + * x = r - x; y = r - y; z = r - z; + */ + + let i = Math.floor(x); + let j = Math.floor(y); + let k = Math.floor(z); + let xi = x - i; + let yi = y - j; + let zi = z - k; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + let seed2 = seed + 1293373; + + let xNMask = Math.trunc(-0.5 - xi); + let yNMask = Math.trunc(-0.5 - yi); + let zNMask = Math.trunc(-0.5 - zi); + + let x0 = xi + xNMask; + let y0 = yi + yNMask; + let z0 = zi + zNMask; + let a0 = 0.75 - x0 * x0 - y0 * y0 - z0 * z0; + let value = + a0 * + a0 * + (a0 * a0) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x0, + y0, + z0 + ); + + let x1 = xi - 0.5; + let y1 = yi - 0.5; + let z1 = zi - 0.5; + let a1 = 0.75 - x1 * x1 - y1 * y1 - z1 * z1; + value += + a1 * + a1 * + (a1 * a1) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + this._PrimeZ, + x1, + y1, + z1 + ); + + let xAFlipMask0 = ((xNMask | 1) << 1) * x1; + let yAFlipMask0 = ((yNMask | 1) << 1) * y1; + let zAFlipMask0 = ((zNMask | 1) << 1) * z1; + let xAFlipMask1 = (-2 - (xNMask << 2)) * x1 - 1.0; + let yAFlipMask1 = (-2 - (yNMask << 2)) * y1 - 1.0; + let zAFlipMask1 = (-2 - (zNMask << 2)) * z1 - 1.0; + + let skip5 = false; + let a2 = xAFlipMask0 + a0; + if (a2 > 0) { + let x2 = x0 - (xNMask | 1); + value += + a2 * + a2 * + (a2 * a2) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x2, + y0, + z0 + ); + } else { + let a3 = yAFlipMask0 + zAFlipMask0 + a0; + + if (a3 > 0) { + let x3 = x0; + let y3 = y0 - (yNMask | 1); + let z3 = z0 - (zNMask | 1); + value += + a3 * + a3 * + (a3 * a3) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x3, + y3, + z3 + ); + } + + let a4 = xAFlipMask1 + a1; + if (a4 > 0) { + let x4 = (xNMask | 1) + x1; + value += + a4 * + a4 * + (a4 * a4) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + this._PrimeZ, + x4, + y1, + z1 + ); + skip5 = true; + } + } + + let skip9 = false; + let a6 = yAFlipMask0 + a0; + if (a6 > 0) { + let x6 = x0; + let y6 = y0 - (yNMask | 1); + value += + a6 * + a6 * + (a6 * a6) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + x6, + y6, + z0 + ); + } else { + let a7 = xAFlipMask0 + zAFlipMask0 + a0; + if (a7 > 0) { + let x7 = x0 - (xNMask | 1); + let y7 = y0; + let z7 = z0 - (zNMask | 1); + value += + a7 * + a7 * + (a7 * a7) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + x7, + y7, + z7 + ); + } + + let a8 = yAFlipMask1 + a1; + if (a8 > 0) { + let x8 = x1; + let y8 = (yNMask | 1) + y1; + value += + a8 * + a8 * + (a8 * a8) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + x8, + y8, + z1 + ); + skip9 = true; + } + } + + let skipD = false; + let aA = zAFlipMask0 + a0; + if (aA > 0) { + let xA = x0; + let yA = y0; + let zA = z0 - (zNMask | 1); + value += + aA * + aA * + (aA * aA) * + this._GradCoordR3( + seed, + i + (xNMask & this._PrimeX), + j + (yNMask & this._PrimeY), + k + (~zNMask & this._PrimeZ), + xA, + yA, + zA + ); + } else { + let aB = xAFlipMask0 + yAFlipMask0 + a0; + if (aB > 0) { + let xB = x0 - (xNMask | 1); + let yB = y0 - (yNMask | 1); + value += + aB * + aB * + (aB * aB) * + this._GradCoordR3( + seed, + i + (~xNMask & this._PrimeX), + j + (~yNMask & this._PrimeY), + k + (zNMask & this._PrimeZ), + xB, + yB, + z0 + ); + } + + let aC = zAFlipMask1 + a1; + if (aC > 0) { + let xC = x1; + let yC = y1; + let zC = (zNMask | 1) + z1; + value += + aC * + aC * + (aC * aC) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + xC, + yC, + zC + ); + skipD = true; + } + } + + if (!skip5) { + let a5 = yAFlipMask1 + zAFlipMask1 + a1; + if (a5 > 0) { + let x5 = x1; + let y5 = (yNMask | 1) + y1; + let z5 = (zNMask | 1) + z1; + value += + a5 * + a5 * + (a5 * a5) * + this._GradCoordR3( + seed2, + i + this._PrimeX, + j + (yNMask & (this._PrimeY << 1)), + k + (zNMask & (this._PrimeZ << 1)), + x5, + y5, + z5 + ); + } + } + + if (!skip9) { + let a9 = xAFlipMask1 + zAFlipMask1 + a1; + if (a9 > 0) { + let x9 = (xNMask | 1) + x1; + let y9 = y1; + let z9 = (zNMask | 1) + z1; + value += + a9 * + a9 * + (a9 * a9) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX * 2)), + j + this._PrimeY, + k + (zNMask & (this._PrimeZ << 1)), + x9, + y9, + z9 + ); + } + } + + if (!skipD) { + let aD = xAFlipMask1 + yAFlipMask1 + a1; + if (aD > 0) { + let xD = (xNMask | 1) + x1; + let yD = (yNMask | 1) + y1; + value += + aD * + aD * + (aD * aD) * + this._GradCoordR3( + seed2, + i + (xNMask & (this._PrimeX << 1)), + j + (yNMask & (this._PrimeY << 1)), + k + this._PrimeZ, + xD, + yD, + z1 + ); + } + } + + return value * 9.046026385208288; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleCellularR2(seed, x, y) { + /** + * + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + let xr = Math.round(x); + let yr = Math.round(y); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + + let closestHash = 0; + + let cellularJitter = 0.43701595 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + + switch (this._CellularDistanceFunction) { + default: + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY; + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = Math.abs(vecX) + Math.abs(vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let hash = this._HashR2(seed, xPrimed, yPrimed); + let idx = hash & (255 << 1); + + let vecX = xi - x + this._RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs2D[idx | 1] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); + + distance1 = Math.max(Math.min(distance1, newDistance), distance0); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + } + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + + if ( + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue + ) { + distance1 = Math.sqrt(distance1); + } + } + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; + } + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleCellularR3(seed, x, y, z) { + let xr = Math.round(x); + let yr = Math.round(y); + let zr = Math.round(z); + + let distance0 = Number.MAX_VALUE; + let distance1 = Number.MAX_VALUE; + let closestHash = 0; + + let cellularJitter = 0.39614353 * this._CellularJitterModifier; + + let xPrimed = (xr - 1) * this._PrimeX; + let yPrimedBase = (yr - 1) * this._PrimeY; + let zPrimedBase = (zr - 1) * this._PrimeZ; + + switch (this._CellularDistanceFunction) { + case FastNoiseLite.CellularDistanceFunction.Euclidean: + case FastNoiseLite.CellularDistanceFunction.EuclideanSq: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Manhattan: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = + Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + case FastNoiseLite.CellularDistanceFunction.Hybrid: + for (let xi = xr - 1; xi <= xr + 1; xi++) { + let yPrimed = yPrimedBase; + + for (let yi = yr - 1; yi <= yr + 1; yi++) { + let zPrimed = zPrimedBase; + + for (let zi = zr - 1; zi <= zr + 1; zi++) { + let hash = this._HashR3(seed, xPrimed, yPrimed, zPrimed); + let idx = hash & (255 << 2); + + let vecX = xi - x + this._RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this._RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this._RandVecs3D[idx | 2] * cellularJitter; + + let newDistance = + Math.abs(vecX) + + Math.abs(vecY) + + Math.abs(vecZ) + + (vecX * vecX + vecY * vecY + vecZ * vecZ); + + distance1 = Math.max( + Math.min(distance1, newDistance), + distance0 + ); + if (newDistance < distance0) { + distance0 = newDistance; + closestHash = hash; + } + zPrimed += this._PrimeZ; + } + yPrimed += this._PrimeY; + } + xPrimed += this._PrimeX; + } + break; + default: + break; + } + + if ( + this._CellularDistanceFunction === + FastNoiseLite.CellularDistanceFunction.Euclidean && + this._CellularReturnType !== FastNoiseLite.CellularReturnType.CellValue + ) { + distance0 = Math.sqrt(distance0); + + if ( + this._CellularReturnType !== + FastNoiseLite.CellularReturnType.CellValue + ) { + distance1 = Math.sqrt(distance1); + } + } + + switch (this._CellularReturnType) { + case FastNoiseLite.CellularReturnType.CellValue: + return closestHash * (1 / 2147483648.0); + case FastNoiseLite.CellularReturnType.Distance: + return distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2: + return distance1 - 1; + case FastNoiseLite.CellularReturnType.Distance2Add: + return (distance1 + distance0) * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Sub: + return distance1 - distance0 - 1; + case FastNoiseLite.CellularReturnType.Distance2Mul: + return distance1 * distance0 * 0.5 - 1; + case FastNoiseLite.CellularReturnType.Distance2Div: + return distance0 / distance1 - 1; + default: + return 0; + } + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SinglePerlinR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xd0 = x - x0; + let yd0 = y - y0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y0, xd0, yd0), + this._GradCoordR2(seed, x1, y0, xd1, yd0), + xs + ); + let xf1 = FastNoiseLite._Lerp( + this._GradCoordR2(seed, x0, y1, xd0, yd1), + this._GradCoordR2(seed, x1, y1, xd1, yd1), + xs + ); + + return FastNoiseLite._Lerp(xf0, xf1, ys) * 1.4247691104677813; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SinglePerlinR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xd0 = x - x0; + let yd0 = y - y0; + let zd0 = z - z0; + let xd1 = xd0 - 1; + let yd1 = yd0 - 1; + let zd1 = zd0 - 1; + + let xs = FastNoiseLite._InterpQuintic(xd0); + let ys = FastNoiseLite._InterpQuintic(yd0); + let zs = FastNoiseLite._InterpQuintic(zd0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), + this._GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), + xs + ); + let xf10 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), + this._GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), + xs + ); + let xf01 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), + this._GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), + xs + ); + let xf11 = FastNoiseLite._Lerp( + this._GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), + this._GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), + xs + ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs) * 0.964921414852142333984375; + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueCubicR2(seed, x, y) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + + let xs = x - x1; + let ys = y - y1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), + this._ValCoordR2(seed, x2, y0), + this._ValCoordR2(seed, x3, y0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), + this._ValCoordR2(seed, x2, y1), + this._ValCoordR2(seed, x3, y1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y2), + this._ValCoordR2(seed, x1, y2), + this._ValCoordR2(seed, x2, y2), + this._ValCoordR2(seed, x3, y2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR2(seed, x0, y3), + this._ValCoordR2(seed, x1, y3), + this._ValCoordR2(seed, x2, y3), + this._ValCoordR2(seed, x3, y3), + xs + ), + ys + ) * + (1 / (1.5 * 1.5)) + ); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueCubicR3(seed, x, y, z) { + let x1 = Math.floor(x); + let y1 = Math.floor(y); + let z1 = Math.floor(z); + + let xs = x - x1; + let ys = y - y1; + let zs = z - z1; + + x1 = Math.imul(x1, this._PrimeX); + y1 = Math.imul(y1, this._PrimeY); + z1 = Math.imul(z1, this._PrimeZ); + + let x0 = x1 - this._PrimeX; + let y0 = y1 - this._PrimeY; + let z0 = z1 - this._PrimeZ; + let x2 = x1 + this._PrimeX; + let y2 = y1 + this._PrimeY; + let z2 = z1 + this._PrimeZ; + let x3 = x1 + (this._PrimeX << 1); + let y3 = y1 + (this._PrimeY << 1); + let z3 = z1 + (this._PrimeZ << 1); + + return ( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + this._ValCoordR3(seed, x2, y0, z0), + this._ValCoordR3(seed, x3, y0, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + this._ValCoordR3(seed, x2, y1, z0), + this._ValCoordR3(seed, x3, y1, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z0), + this._ValCoordR3(seed, x1, y2, z0), + this._ValCoordR3(seed, x2, y2, z0), + this._ValCoordR3(seed, x3, y2, z0), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z0), + this._ValCoordR3(seed, x1, y3, z0), + this._ValCoordR3(seed, x2, y3, z0), + this._ValCoordR3(seed, x3, y3, z0), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + this._ValCoordR3(seed, x2, y0, z1), + this._ValCoordR3(seed, x3, y0, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + this._ValCoordR3(seed, x2, y1, z1), + this._ValCoordR3(seed, x3, y1, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z1), + this._ValCoordR3(seed, x1, y2, z1), + this._ValCoordR3(seed, x2, y2, z1), + this._ValCoordR3(seed, x3, y2, z1), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z1), + this._ValCoordR3(seed, x1, y3, z1), + this._ValCoordR3(seed, x2, y3, z1), + this._ValCoordR3(seed, x3, y3, z1), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z2), + this._ValCoordR3(seed, x1, y0, z2), + this._ValCoordR3(seed, x2, y0, z2), + this._ValCoordR3(seed, x3, y0, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z2), + this._ValCoordR3(seed, x1, y1, z2), + this._ValCoordR3(seed, x2, y1, z2), + this._ValCoordR3(seed, x3, y1, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z2), + this._ValCoordR3(seed, x1, y2, z2), + this._ValCoordR3(seed, x2, y2, z2), + this._ValCoordR3(seed, x3, y2, z2), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z2), + this._ValCoordR3(seed, x1, y3, z2), + this._ValCoordR3(seed, x2, y3, z2), + this._ValCoordR3(seed, x3, y3, z2), + xs + ), + ys + ), + FastNoiseLite._CubicLerp( + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y0, z3), + this._ValCoordR3(seed, x1, y0, z3), + this._ValCoordR3(seed, x2, y0, z3), + this._ValCoordR3(seed, x3, y0, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y1, z3), + this._ValCoordR3(seed, x1, y1, z3), + this._ValCoordR3(seed, x2, y1, z3), + this._ValCoordR3(seed, x3, y1, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y2, z3), + this._ValCoordR3(seed, x1, y2, z3), + this._ValCoordR3(seed, x2, y2, z3), + this._ValCoordR3(seed, x3, y2, z3), + xs + ), + FastNoiseLite._CubicLerp( + this._ValCoordR3(seed, x0, y3, z3), + this._ValCoordR3(seed, x1, y3, z3), + this._ValCoordR3(seed, x2, y3, z3), + this._ValCoordR3(seed, x3, y3, z3), + xs + ), + ys + ), + zs + ) * + (1 / (1.5 * 1.5 * 1.5)) + ); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @returns {number} + */ + _SingleValueR2(seed, x, y) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let xf0 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y0), + this._ValCoordR2(seed, x1, y0), + xs + ); + let xf1 = FastNoiseLite._Lerp( + this._ValCoordR2(seed, x0, y1), + this._ValCoordR2(seed, x1, y1), + xs + ); + + return FastNoiseLite._Lerp(xf0, xf1, ys); + } + + /** + * @private + * @param {number} seed + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {number} + */ + _SingleValueR3(seed, x, y, z) { + let x0 = Math.floor(x); + let y0 = Math.floor(y); + let z0 = Math.floor(z); + + let xs = FastNoiseLite._InterpHermite(x - x0); + let ys = FastNoiseLite._InterpHermite(y - y0); + let zs = FastNoiseLite._InterpHermite(z - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let xf00 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z0), + this._ValCoordR3(seed, x1, y0, z0), + xs + ); + let xf10 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z0), + this._ValCoordR3(seed, x1, y1, z0), + xs + ); + let xf01 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y0, z1), + this._ValCoordR3(seed, x1, y0, z1), + xs + ); + let xf11 = FastNoiseLite._Lerp( + this._ValCoordR3(seed, x0, y1, z1), + this._ValCoordR3(seed, x1, y1, z1), + xs + ); + + let yf0 = FastNoiseLite._Lerp(xf00, xf10, ys); + let yf1 = FastNoiseLite._Lerp(xf01, xf11, ys); + + return FastNoiseLite._Lerp(yf0, yf1, zs); + } + + /** + * @private + */ + _DoSingleDomainWarp() { + /** + * + * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + let R2 = (seed, amp, freq, coord, x, y) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 38.283687591552734375, + freq, + coord, + false, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 16.0, + freq, + coord, + true, + x, + y + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); + break; + } + }; + + /** + * + * @param {number} seed + * @param {number} amp + * @param {number} freq + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, amp, freq, coord, x, y, z) => { + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 32.69428253173828125, + freq, + coord, + false, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: + this._SingleDomainWarpOpenSimplex2Gradient( + seed, + amp * 7.71604938271605, + freq, + coord, + true, + x, + y, + z + ); + break; + case FastNoiseLite.DomainWarpType.BasicGrid: + this._SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); + break; + } + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + return R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] + ); + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + return R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + } + + /** + * @private + */ + _DomainWarpSingle() { + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + } + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + break; + } + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + _DomainWarpFractalProgressive() { + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + } + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + } + break; + default: + break; + } + + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + /** + * @private + */ + _DomainWarpFractalIndependent() { + /** + * + * @param {Vector2} coord + */ + let R2 = (coord) => { + let xs = coord.x; + let ys = coord.y; + switch (this._DomainWarpType) { + case FastNoiseLite.DomainWarpType.OpenSimplex2: + case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced: { + const SQRT3 = 1.7320508075688772; + const F2 = 0.5 * (SQRT3 - 1); + let t = (xs + ys) * F2; + xs += t; + ys += t; + break; + } + default: + break; + } + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + /** + * + * @param {Vector3} coord + */ + let R3 = (coord) => { + let xs = coord.x; + let ys = coord.y; + let zs = coord.z; + switch (this._WarpTransformType3D) { + case FastNoiseLite.TransformType3D.ImproveXYPlanes: + { + let xy = xs + ys; + let s2 = xy * -0.211324865405187; + zs *= 0.577350269189626; + xs += s2 - zs; + ys = ys + s2 - zs; + zs += xy * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.ImproveXZPlanes: + { + let xz = xs + zs; + let s2 = xz * -0.211324865405187; + ys *= 0.577350269189626; + xs += s2 - ys; + zs += s2 - ys; + ys += xz * 0.577350269189626; + } + break; + case FastNoiseLite.TransformType3D.DefaultOpenSimplex2: + { + const R3 = 2.0 / 3.0; + let r = (xs + ys + zs) * R3; // Rotation, not skew + xs = r - xs; + ys = r - ys; + zs = r - zs; + } + break; + default: + break; + } + + let seed = this._Seed; + let amp = this._DomainWarpAmp * this._FractalBounding; + let freq = this._Frequency; + for (let i = 0; i < this._Octaves; i++) { + this._DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + + seed++; + amp *= this._Gain; + freq *= this._Lacunarity; + } + }; + + if (arguments.length === 1 && arguments[0] instanceof Vector2) { + return R2(arguments[0]); + } + + if (arguments.length === 1 && arguments[0] instanceof Vector3) { + return R3(arguments[0]); + } + } + + /** + * @private + */ + _SingleDomainWarpBasicGrid() { + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {number} x + * @param {number} y + */ + + let R2 = (seed, warpAmp, frequency, coord, x, y) => { + let xf = x * frequency; + let yf = y * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + + let hash0 = this._HashR2(seed, x0, y0) & (255 << 1); + let hash1 = this._HashR2(seed, x1, y0) & (255 << 1); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + hash0 = this._HashR2(seed, x0, y1) & (255 << 1); + hash1 = this._HashR2(seed, x1, y1) & (255 << 1); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0], + this._RandVecs2D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs2D[hash0 | 1], + this._RandVecs2D[hash1 | 1], + xs + ); + + coord.x += FastNoiseLite._Lerp(lx0x, lx1x, ys) * warpAmp; + coord.y += FastNoiseLite._Lerp(ly0x, ly1x, ys) * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, x, y, z) => { + let xf = x * frequency; + let yf = y * frequency; + let zf = z * frequency; + + let x0 = Math.floor(xf); + let y0 = Math.floor(yf); + let z0 = Math.floor(zf); + + let xs = FastNoiseLite._InterpHermite(xf - x0); + let ys = FastNoiseLite._InterpHermite(yf - y0); + let zs = FastNoiseLite._InterpHermite(zf - z0); + + x0 = Math.imul(x0, this._PrimeX); + y0 = Math.imul(y0, this._PrimeY); + z0 = Math.imul(z0, this._PrimeZ); + let x1 = x0 + this._PrimeX; + let y1 = y0 + this._PrimeY; + let z1 = z0 + this._PrimeZ; + + let hash0 = this._HashR3(seed, x0, y0, z0) & (255 << 2); + let hash1 = this._HashR3(seed, x1, y0, z0) & (255 << 2); + + let lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z0) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z0) & (255 << 2); + + let lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + let ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + let lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + let lx0y = FastNoiseLite._Lerp(lx0x, lx1x, ys); + let ly0y = FastNoiseLite._Lerp(ly0x, ly1x, ys); + let lz0y = FastNoiseLite._Lerp(lz0x, lz1x, ys); + + hash0 = this._HashR3(seed, x0, y0, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y0, z1) & (255 << 2); + + lx0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz0x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + hash0 = this._HashR3(seed, x0, y1, z1) & (255 << 2); + hash1 = this._HashR3(seed, x1, y1, z1) & (255 << 2); + + lx1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0], + this._RandVecs3D[hash1], + xs + ); + ly1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 1], + this._RandVecs3D[hash1 | 1], + xs + ); + lz1x = FastNoiseLite._Lerp( + this._RandVecs3D[hash0 | 2], + this._RandVecs3D[hash1 | 2], + xs + ); + + coord.x += + FastNoiseLite._Lerp(lx0y, FastNoiseLite._Lerp(lx0x, lx1x, ys), zs) * + warpAmp; + coord.y += + FastNoiseLite._Lerp(ly0y, FastNoiseLite._Lerp(ly0x, ly1x, ys), zs) * + warpAmp; + coord.z += + FastNoiseLite._Lerp(lz0y, FastNoiseLite._Lerp(lz0x, lz1x, ys), zs) * + warpAmp; + }; + + if (arguments.length === 6 && arguments[3] instanceof Vector2) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5] + ); + } + + if (arguments.length === 7 && arguments[3] instanceof Vector3) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + } + + /** + * @private + */ + _SingleDomainWarpOpenSimplex2Gradient() { + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector2} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + */ + let R2 = (seed, warpAmp, frequency, coord, outGradOnly, x, y) => { + const SQRT3 = 1.7320508075688772; + const G2 = (3 - SQRT3) / 6; + + x *= frequency; + y *= frequency; + + let i = Math.floor(x); + let j = Math.floor(y); + let xi = x - i; + let yi = y - j; + + let t = (xi + yi) * G2; + let x0 = xi - t; + let y0 = yi - t; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + + let vx, vy; + vx = vy = 0; + + let a = 0.5 - x0 * x0 - y0 * y0; + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i, j) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i, j); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x0 * xg + y0 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += aaaa * xo; + vy += aaaa * yo; + } + + let c = + 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); + if (c > 0) { + let x2 = x0 + (2 * G2 - 1); + let y2 = y0 + (2 * G2 - 1); + let cccc = c * c * (c * c); + let xo, yo; + if (outGradOnly) { + let hash = + this._HashR2(seed, i + this._PrimeX, j + this._PrimeY) & + (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i + this._PrimeX, j + this._PrimeY); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x2 * xg + y2 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += cccc * xo; + vy += cccc * yo; + } + + if (y0 > x0) { + let x1 = x0 + G2; + let y1 = y0 + (G2 - 1); + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i, j + this._PrimeY) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i, j + this._PrimeY); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x1 * xg + y1 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += bbbb * xo; + vy += bbbb * yo; + } + } else { + let x1 = x0 + (G2 - 1); + let y1 = y0 + G2; + let b = 0.5 - x1 * x1 - y1 * y1; + if (b > 0) { + let bbbb = b * b * (b * b); + let xo, yo; + if (outGradOnly) { + let hash = this._HashR2(seed, i + this._PrimeX, j) & (255 << 1); + xo = this._RandVecs2D[hash]; + yo = this._RandVecs2D[hash | 1]; + } else { + let hash = this._HashR2(seed, i + this._PrimeX, j); + let index1 = hash & (127 << 1); + let index2 = (hash >> 7) & (255 << 1); + let xg = this._Gradients2D[index1]; + let yg = this._Gradients2D[index1 | 1]; + let value = x1 * xg + y1 * yg; + let xgo = this._RandVecs2D[index2]; + let ygo = this._RandVecs2D[index2 | 1]; + xo = value * xgo; + yo = value * ygo; + } + vx += bbbb * xo; + vy += bbbb * yo; + } + } + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + }; + + /** + * + * @param {number} seed + * @param {number} warpAmp + * @param {number} frequency + * @param {Vector3} coord + * @param {boolean} outGradOnly + * @param {number} x + * @param {number} y + * @param {number} z + */ + let R3 = (seed, warpAmp, frequency, coord, outGradOnly, x, y, z) => { + x *= frequency; + y *= frequency; + z *= frequency; + + let i = Math.round(x); + let j = Math.round(y); + let k = Math.round(z); + let x0 = x - i; + let y0 = y - j; + let z0 = z - k; + + let xNSign = (-x0 - 1.0) | 1; + let yNSign = (-y0 - 1.0) | 1; + let zNSign = (-z0 - 1.0) | 1; + + let ax0 = xNSign * -x0; + let ay0 = yNSign * -y0; + let az0 = zNSign * -z0; + + i = Math.imul(i, this._PrimeX); + j = Math.imul(j, this._PrimeY); + k = Math.imul(k, this._PrimeZ); + + let vx, vy, vz; + vx = vy = vz = 0; + + let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); + for (let l = 0; ; l++) { + if (a > 0) { + let aaaa = a * a * (a * a); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i, j, k) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i, j, k); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x0 * xg + y0 * yg + z0 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; + } + vx += aaaa * xo; + vy += aaaa * yo; + vz += aaaa * zo; + } + + let b = a; + let i1 = i; + let j1 = j; + let k1 = k; + let x1 = x0; + let y1 = y0; + let z1 = z0; + + if (ax0 >= ay0 && ax0 >= az0) { + x1 += xNSign; + b = b + ax0 + ax0; + i1 -= xNSign * this._PrimeX; + } else if (ay0 > ax0 && ay0 >= az0) { + y1 += yNSign; + b = b + ay0 + ay0; + j1 -= yNSign * this._PrimeY; + } else { + z1 += zNSign; + b = b + az0 + az0; + k1 -= zNSign * this._PrimeZ; + } + + if (b > 1) { + b -= 1; + let bbbb = b * b * (b * b); + let xo, yo, zo; + if (outGradOnly) { + let hash = this._HashR3(seed, i1, j1, k1) & (255 << 2); + xo = this._RandVecs3D[hash]; + yo = this._RandVecs3D[hash | 1]; + zo = this._RandVecs3D[hash | 2]; + } else { + let hash = this._HashR3(seed, i1, j1, k1); + let index1 = hash & (63 << 2); + let index2 = (hash >> 6) & (255 << 2); + let xg = this._Gradients3D[index1]; + let yg = this._Gradients3D[index1 | 1]; + let zg = this._Gradients3D[index1 | 2]; + let value = x1 * xg + y1 * yg + z1 * zg; + let xgo = this._RandVecs3D[index2]; + let ygo = this._RandVecs3D[index2 | 1]; + let zgo = this._RandVecs3D[index2 | 2]; + xo = value * xgo; + yo = value * ygo; + zo = value * zgo; + } + vx += bbbb * xo; + vy += bbbb * yo; + vz += bbbb * zo; + } + + if (l === 1) break; + + ax0 = 0.5 - ax0; + ay0 = 0.5 - ay0; + az0 = 0.5 - az0; + + x0 = xNSign * ax0; + y0 = yNSign * ay0; + z0 = zNSign * az0; + + a += 0.75 - ax0 - (ay0 + az0); + + i += (xNSign >> 1) & this._PrimeX; + j += (yNSign >> 1) & this._PrimeY; + k += (zNSign >> 1) & this._PrimeZ; + + xNSign = -xNSign; + yNSign = -yNSign; + zNSign = -zNSign; + + seed += 1293373; + } + + coord.x += vx * warpAmp; + coord.y += vy * warpAmp; + coord.z += vz * warpAmp; + }; + + if (arguments.length === 7) { + R2( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6] + ); + } + + if (arguments.length === 8) { + R3( + arguments[0], + arguments[1], + arguments[2], + arguments[3], + arguments[4], + arguments[5], + arguments[6], + arguments[7] + ); + } + } + } + + class Vector2 { + /** + * 2d Vector + * @param {number} x + * @param {number} y + */ + constructor(x, y) { + this.x = x; + this.y = y; + } + } + + class Vector3 { + /** + * 3d Vector + * @param {number} x + * @param {number} y + * @param {number} z + */ + constructor(x, y, z) { + this.x = x; + this.y = y; + this.z = z; + } + } +>>>>>>> parent of 95e6823 (minified) Scratch.extensions.register(new Noise()); })(Scratch); From 99c20d0d515726d9bed208a36a89405c719ec6f4 Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Thu, 26 Dec 2024 14:02:09 -0700 Subject: [PATCH 32/36] unminified --- extensions/Corbnorb/noise.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 257e0e17c6..8b09604a78 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -232,17 +232,6 @@ // SOFTWARE. // -<<<<<<< HEAD - //minified code. find original here: - // https://raw.githubusercontent.com/Auburn/FastNoiseLite/refs/heads/master/JavaScript/FastNoiseLite.js - - /* eslint-disable */ - /* prettier-disable */ - // prettier-ignore - class FastNoiseLite{static NoiseType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2S:"OpenSimplex2S",Cellular:"Cellular",Perlin:"Perlin",ValueCubic:"ValueCubic",Value:"Value"});static RotationType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes"});static FractalType=Object.freeze({None:"None",FBm:"FBm",Ridged:"Ridged",PingPong:"PingPong",DomainWarpProgressive:"DomainWarpProgressive",DomainWarpIndependent:"DomainWarpIndependent"});static CellularDistanceFunction=Object.freeze({Euclidean:"Euclidean",EuclideanSq:"EuclideanSq",Manhattan:"Manhattan",Hybrid:"Hybrid"});static CellularReturnType=Object.freeze({CellValue:"CellValue",Distance:"Distance",Distance2:"Distance2",Distance2Add:"Distance2Add",Distance2Sub:"Distance2Sub",Distance2Mul:"Distance2Mul",Distance2Div:"Distance2Div"});static DomainWarpType=Object.freeze({OpenSimplex2:"OpenSimplex2",OpenSimplex2Reduced:"OpenSimplex2Reduced",BasicGrid:"BasicGrid"});static TransformType3D=Object.freeze({None:"None",ImproveXYPlanes:"ImproveXYPlanes",ImproveXZPlanes:"ImproveXZPlanes",DefaultOpenSimplex2:"DefaultOpenSimplex2"});_Seed=1337;_Frequency=.01;_NoiseType=FastNoiseLite.NoiseType.OpenSimplex2;_RotationType3D=FastNoiseLite.RotationType3D.None;_TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;_DomainWarpAmp=1;_FractalType=FastNoiseLite.FractalType.None;_Octaves=3;_Lacunarity=2;_Gain=.5;_WeightedStrength=0;_PingPongStrength=2;_FractalBounding=1/1.75;_CellularDistanceFunction=FastNoiseLite.CellularDistanceFunction.EuclideanSq;_CellularReturnType=FastNoiseLite.CellularReturnType.Distance;_CellularJitterModifier=1;_DomainWarpType=FastNoiseLite.DomainWarpType.OpenSimplex2;_WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;constructor(e){void 0!==e&&(this._Seed=e)}SetSeed(e){this._Seed=e}SetFrequency(e){this._Frequency=e}SetNoiseType(e){this._NoiseType=e,this._UpdateTransformType3D()}SetRotationType3D(e){this._RotationType3D=e,this._UpdateTransformType3D(),this._UpdateWarpTransformType3D()}SetFractalType(e){this._FractalType=e}SetFractalOctaves(e){this._Octaves=e,this._CalculateFractalBounding()}SetFractalLacunarity(e){this._Lacunarity=e}SetFractalGain(e){this._Gain=e,this._CalculateFractalBounding()}SetFractalWeightedStrength(e){this._WeightedStrength=e}SetFractalPingPongStrength(e){this._PingPongStrength=e}SetCellularDistanceFunction(e){this._CellularDistanceFunction=e}SetCellularReturnType(e){this._CellularReturnType=e}SetCellularJitter(e){this._CellularJitterModifier=e}SetDomainWarpType(e){this._DomainWarpType=e,this._UpdateWarpTransformType3D()}SetDomainWarpAmp(e){this._DomainWarpAmp=e}GetNoise(e,t,i){let s=(e,t)=>{switch(e*=this._Frequency,t*=this._Frequency,this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:let i=(e+t)*(.5*(1.7320508075688772-1));e+=i,t+=i}switch(this._FractalType){default:return this._GenNoiseSingleR2(this._Seed,e,t);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR2(e,t);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR2(e,t);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR2(e,t)}},a=(e,t,i)=>{switch(e*=this._Frequency,t*=this._Frequency,i*=this._Frequency,this._TransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let s=e+t,a=-.211324865405187*s;e+=a-(i*=.577350269189626),t+=a-i,i+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let s=e+i,a=-.211324865405187*s;e+=a-(t*=.577350269189626),i+=a-t,t+=.577350269189626*s;break}case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let s=(e+t+i)*(2/3);e=s-e,t=s-t,i=s-i}switch(this._FractalType){default:return this._GenNoiseSingleR3(this._Seed,e,t,i);case FastNoiseLite.FractalType.FBm:return this._GenFractalFBmR3(e,t,i);case FastNoiseLite.FractalType.Ridged:return this._GenFractalRidgedR3(e,t,i);case FastNoiseLite.FractalType.PingPong:return this._GenFractalPingPongR3(e,t,i)}};return 2===arguments.length?s(e,t):3===arguments.length?a(e,t,i):void 0}DomainWrap(e){switch(this._FractalType){default:this._DomainWarpSingle(e);break;case FastNoiseLite.FractalType.DomainWarpProgressive:this._DomainWarpFractalProgressive(e);break;case FastNoiseLite.FractalType.DomainWarpIndependent:this._DomainWarpFractalIndependent(e)}}_Gradients2D=[.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.130526192220052,.99144486137381,.38268343236509,.923879532511287,.608761429008721,.793353340291235,.793353340291235,.608761429008721,.923879532511287,.38268343236509,.99144486137381,.130526192220051,.99144486137381,-.130526192220051,.923879532511287,-.38268343236509,.793353340291235,-.60876142900872,.608761429008721,-.793353340291235,.38268343236509,-.923879532511287,.130526192220052,-.99144486137381,-.130526192220052,-.99144486137381,-.38268343236509,-.923879532511287,-.608761429008721,-.793353340291235,-.793353340291235,-.608761429008721,-.923879532511287,-.38268343236509,-.99144486137381,-.130526192220052,-.99144486137381,.130526192220051,-.923879532511287,.38268343236509,-.793353340291235,.608761429008721,-.608761429008721,.793353340291235,-.38268343236509,.923879532511287,-.130526192220052,.99144486137381,.38268343236509,.923879532511287,.923879532511287,.38268343236509,.923879532511287,-.38268343236509,.38268343236509,-.923879532511287,-.38268343236509,-.923879532511287,-.923879532511287,-.38268343236509,-.923879532511287,.38268343236509,-.38268343236509,.923879532511287];_RandVecs2D=[-.2700222198,-.9628540911,.3863092627,-.9223693152,.04444859006,-.999011673,-.5992523158,-.8005602176,-.7819280288,.6233687174,.9464672271,.3227999196,-.6514146797,-.7587218957,.9378472289,.347048376,-.8497875957,-.5271252623,-.879042592,.4767432447,-.892300288,-.4514423508,-.379844434,-.9250503802,-.9951650832,.0982163789,.7724397808,-.6350880136,.7573283322,-.6530343002,-.9928004525,-.119780055,-.0532665713,.9985803285,.9754253726,-.2203300762,-.7665018163,.6422421394,.991636706,.1290606184,-.994696838,.1028503788,-.5379205513,-.84299554,.5022815471,-.8647041387,.4559821461,-.8899889226,-.8659131224,-.5001944266,.0879458407,-.9961252577,-.5051684983,.8630207346,.7753185226,-.6315704146,-.6921944612,.7217110418,-.5191659449,-.8546734591,.8978622882,-.4402764035,-.1706774107,.9853269617,-.9353430106,-.3537420705,-.9992404798,.03896746794,-.2882064021,-.9575683108,-.9663811329,.2571137995,-.8759714238,-.4823630009,-.8303123018,-.5572983775,.05110133755,-.9986934731,-.8558373281,-.5172450752,.09887025282,.9951003332,.9189016087,.3944867976,-.2439375892,-.9697909324,-.8121409387,-.5834613061,-.9910431363,.1335421355,.8492423985,-.5280031709,-.9717838994,-.2358729591,.9949457207,.1004142068,.6241065508,-.7813392434,.662910307,.7486988212,-.7197418176,.6942418282,-.8143370775,-.5803922158,.104521054,-.9945226741,-.1065926113,-.9943027784,.445799684,-.8951327509,.105547406,.9944142724,-.992790267,.1198644477,-.8334366408,.552615025,.9115561563,-.4111755999,.8285544909,-.5599084351,.7217097654,-.6921957921,.4940492677,-.8694339084,-.3652321272,-.9309164803,-.9696606758,.2444548501,.08925509731,-.996008799,.5354071276,-.8445941083,-.1053576186,.9944343981,-.9890284586,.1477251101,.004856104961,.9999882091,.9885598478,.1508291331,.9286129562,-.3710498316,-.5832393863,-.8123003252,.3015207509,.9534596146,-.9575110528,.2883965738,.9715802154,-.2367105511,.229981792,.9731949318,.955763816,-.2941352207,.740956116,.6715534485,-.9971513787,-.07542630764,.6905710663,-.7232645452,-.290713703,-.9568100872,.5912777791,-.8064679708,-.9454592212,-.325740481,.6664455681,.74555369,.6236134912,.7817328275,.9126993851,-.4086316587,-.8191762011,.5735419353,-.8812745759,-.4726046147,.9953313627,.09651672651,.9855650846,-.1692969699,-.8495980887,.5274306472,.6174853946,-.7865823463,.8508156371,.52546432,.9985032451,-.05469249926,.1971371563,-.9803759185,.6607855748,-.7505747292,-.03097494063,.9995201614,-.6731660801,.739491331,-.7195018362,-.6944905383,.9727511689,.2318515979,.9997059088,-.0242506907,.4421787429,-.8969269532,.9981350961,-.061043673,-.9173660799,-.3980445648,-.8150056635,-.5794529907,-.8789331304,.4769450202,.0158605829,.999874213,-.8095464474,.5870558317,-.9165898907,-.3998286786,-.8023542565,.5968480938,-.5176737917,.8555780767,-.8154407307,-.5788405779,.4022010347,-.9155513791,-.9052556868,-.4248672045,.7317445619,.6815789728,-.5647632201,-.8252529947,-.8403276335,-.5420788397,-.9314281527,.363925262,.5238198472,.8518290719,.7432803869,-.6689800195,-.985371561,-.1704197369,.4601468731,.88784281,.825855404,.5638819483,.6182366099,.7859920446,.8331502863,-.553046653,.1500307506,.9886813308,-.662330369,-.7492119075,-.668598664,.743623444,.7025606278,.7116238924,-.5419389763,-.8404178401,-.3388616456,.9408362159,.8331530315,.5530425174,-.2989720662,-.9542618632,.2638522993,.9645630949,.124108739,-.9922686234,-.7282649308,-.6852956957,.6962500149,.7177993569,-.9183535368,.3957610156,-.6326102274,-.7744703352,-.9331891859,-.359385508,-.1153779357,-.9933216659,.9514974788,-.3076565421,-.08987977445,-.9959526224,.6678496916,.7442961705,.7952400393,-.6062947138,-.6462007402,-.7631674805,-.2733598753,.9619118351,.9669590226,-.254931851,-.9792894595,.2024651934,-.5369502995,-.8436138784,-.270036471,-.9628500944,-.6400277131,.7683518247,-.7854537493,-.6189203566,.06005905383,-.9981948257,-.02455770378,.9996984141,-.65983623,.751409442,-.6253894466,-.7803127835,-.6210408851,-.7837781695,.8348888491,.5504185768,-.1592275245,.9872419133,.8367622488,.5475663786,-.8675753916,-.4973056806,-.2022662628,-.9793305667,.9399189937,.3413975472,.9877404807,-.1561049093,-.9034455656,.4287028224,.1269804218,-.9919052235,-.3819600854,.924178821,.9754625894,.2201652486,-.3204015856,-.9472818081,-.9874760884,.1577687387,.02535348474,-.9996785487,.4835130794,-.8753371362,-.2850799925,-.9585037287,-.06805516006,-.99768156,-.7885244045,-.6150034663,.3185392127,-.9479096845,.8880043089,.4598351306,.6476921488,-.7619021462,.9820241299,.1887554194,.9357275128,-.3527237187,-.8894895414,.4569555293,.7922791302,.6101588153,.7483818261,.6632681526,-.7288929755,-.6846276581,.8729032783,-.4878932944,.8288345784,.5594937369,.08074567077,.9967347374,.9799148216,-.1994165048,-.580730673,-.8140957471,-.4700049791,-.8826637636,.2409492979,.9705377045,.9437816757,-.3305694308,-.8927998638,-.4504535528,-.8069622304,.5906030467,.06258973166,.9980393407,-.9312597469,.3643559849,.5777449785,.8162173362,-.3360095855,-.941858566,.697932075,-.7161639607,-.002008157227,-.9999979837,-.1827294312,-.9831632392,-.6523911722,.7578824173,-.4302626911,-.9027037258,-.9985126289,-.05452091251,-.01028102172,-.9999471489,-.4946071129,.8691166802,-.2999350194,.9539596344,.8165471961,.5772786819,.2697460475,.962931498,-.7306287391,-.6827749597,-.7590952064,-.6509796216,-.907053853,.4210146171,-.5104861064,-.8598860013,.8613350597,.5080373165,.5007881595,-.8655698812,-.654158152,.7563577938,-.8382755311,-.545246856,.6940070834,.7199681717,.06950936031,.9975812994,.1702942185,-.9853932612,.2695973274,.9629731466,.5519612192,-.8338697815,.225657487,-.9742067022,.4215262855,-.9068161835,.4881873305,-.8727388672,-.3683854996,-.9296731273,-.9825390578,.1860564427,.81256471,.5828709909,.3196460933,-.9475370046,.9570913859,.2897862643,-.6876655497,-.7260276109,-.9988770922,-.047376731,-.1250179027,.992154486,-.8280133617,.560708367,.9324863769,-.3612051451,.6394653183,.7688199442,-.01623847064,-.9998681473,-.9955014666,-.09474613458,-.81453315,.580117012,.4037327978,-.9148769469,.9944263371,.1054336766,-.1624711654,.9867132919,-.9949487814,-.100383875,-.6995302564,.7146029809,.5263414922,-.85027327,-.5395221479,.841971408,.6579370318,.7530729462,.01426758847,-.9998982128,-.6734383991,.7392433447,.639412098,-.7688642071,.9211571421,.3891908523,-.146637214,-.9891903394,-.782318098,.6228791163,-.5039610839,-.8637263605,-.7743120191,-.6328039957];_Gradients3D=[0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,1,0,1,0,-1,0,1,0,1,0,-1,0,-1,0,-1,0,1,1,0,0,-1,1,0,0,1,-1,0,0,-1,-1,0,0,1,1,0,0,0,-1,1,0,-1,1,0,0,0,-1,-1,0];_RandVecs3D=[-.7292736885,-.6618439697,.1735581948,0,.790292081,-.5480887466,-.2739291014,0,.7217578935,.6226212466,-.3023380997,0,.565683137,-.8208298145,-.0790000257,0,.760049034,-.5555979497,-.3370999617,0,.3713945616,.5011264475,.7816254623,0,-.1277062463,-.4254438999,-.8959289049,0,-.2881560924,-.5815838982,.7607405838,0,.5849561111,-.662820239,-.4674352136,0,.3307171178,.0391653737,.94291689,0,.8712121778,-.4113374369,-.2679381538,0,.580981015,.7021915846,.4115677815,0,.503756873,.6330056931,-.5878203852,0,.4493712205,.601390195,.6606022552,0,-.6878403724,.09018890807,-.7202371714,0,-.5958956522,-.6469350577,.475797649,0,-.5127052122,.1946921978,-.8361987284,0,-.9911507142,-.05410276466,-.1212153153,0,-.2149721042,.9720882117,-.09397607749,0,-.7518650936,-.5428057603,.3742469607,0,.5237068895,.8516377189,-.02107817834,0,.6333504779,.1926167129,-.7495104896,0,-.06788241606,.3998305789,.9140719259,0,-.5538628599,-.4729896695,-.6852128902,0,-.7261455366,-.5911990757,.3509933228,0,-.9229274737,-.1782808786,.3412049336,0,-.6968815002,.6511274338,.3006480328,0,.9608044783,-.2098363234,-.1811724921,0,.06817146062,-.9743405129,.2145069156,0,-.3577285196,-.6697087264,-.6507845481,0,-.1868621131,.7648617052,-.6164974636,0,-.6541697588,.3967914832,.6439087246,0,.6993340405,-.6164538506,.3618239211,0,-.1546665739,.6291283928,.7617583057,0,-.6841612949,-.2580482182,-.6821542638,0,.5383980957,.4258654885,.7271630328,0,-.5026987823,-.7939832935,-.3418836993,0,.3202971715,.2834415347,.9039195862,0,.8683227101,-.0003762656404,-.4959995258,0,.791120031,-.08511045745,.6057105799,0,-.04011016052,-.4397248749,.8972364289,0,.9145119872,.3579346169,-.1885487608,0,-.9612039066,-.2756484276,.01024666929,0,.6510361721,-.2877799159,-.7023778346,0,-.2041786351,.7365237271,.644859585,0,-.7718263711,.3790626912,.5104855816,0,-.3060082741,-.7692987727,.5608371729,0,.454007341,-.5024843065,.7357899537,0,.4816795475,.6021208291,-.6367380315,0,.6961980369,-.3222197429,.641469197,0,-.6532160499,-.6781148932,.3368515753,0,.5089301236,-.6154662304,-.6018234363,0,-.1635919754,-.9133604627,-.372840892,0,.52408019,-.8437664109,.1157505864,0,.5902587356,.4983817807,-.6349883666,0,.5863227872,.494764745,.6414307729,0,.6779335087,.2341345225,.6968408593,0,.7177054546,-.6858979348,.120178631,0,-.5328819713,-.5205125012,.6671608058,0,-.8654874251,-.0700727088,-.4960053754,0,-.2861810166,.7952089234,.5345495242,0,-.04849529634,.9810836427,-.1874115585,0,-.6358521667,.6058348682,.4781800233,0,.6254794696,-.2861619734,.7258696564,0,-.2585259868,.5061949264,-.8227581726,0,.02136306781,.5064016808,-.8620330371,0,.200111773,.8599263484,.4695550591,0,.4743561372,.6014985084,-.6427953014,0,.6622993731,-.5202474575,-.5391679918,0,.08084972818,-.6532720452,.7527940996,0,-.6893687501,.0592860349,.7219805347,0,-.1121887082,-.9673185067,.2273952515,0,.7344116094,.5979668656,-.3210532909,0,.5789393465,-.2488849713,.7764570201,0,.6988182827,.3557169806,-.6205791146,0,-.8636845529,-.2748771249,-.4224826141,0,-.4247027957,-.4640880967,.777335046,0,.5257722489,-.8427017621,.1158329937,0,.9343830603,.316302472,-.1639543925,0,-.1016836419,-.8057303073,-.5834887393,0,-.6529238969,.50602126,-.5635892736,0,-.2465286165,-.9668205684,-.06694497494,0,-.9776897119,-.2099250524,-.007368825344,0,.7736893337,.5734244712,.2694238123,0,-.6095087895,.4995678998,.6155736747,0,.5794535482,.7434546771,.3339292269,0,-.8226211154,.08142581855,.5627293636,0,-.510385483,.4703667658,.7199039967,0,-.5764971849,-.07231656274,-.8138926898,0,.7250628871,.3949971505,-.5641463116,0,-.1525424005,.4860840828,-.8604958341,0,-.5550976208,-.4957820792,.667882296,0,-.1883614327,.9145869398,.357841725,0,.7625556724,-.5414408243,-.3540489801,0,-.5870231946,-.3226498013,-.7424963803,0,.3051124198,.2262544068,-.9250488391,0,.6379576059,.577242424,-.5097070502,0,-.5966775796,.1454852398,-.7891830656,0,-.658330573,.6555487542,-.3699414651,0,.7434892426,.2351084581,.6260573129,0,.5562114096,.8264360377,-.0873632843,0,-.3028940016,-.8251527185,.4768419182,0,.1129343818,-.985888439,-.1235710781,0,.5937652891,-.5896813806,.5474656618,0,.6757964092,-.5835758614,-.4502648413,0,.7242302609,-.1152719764,.6798550586,0,-.9511914166,.0753623979,-.2992580792,0,.2539470961,-.1886339355,.9486454084,0,.571433621,-.1679450851,-.8032795685,0,-.06778234979,.3978269256,.9149531629,0,.6074972649,.733060024,-.3058922593,0,-.5435478392,.1675822484,.8224791405,0,-.5876678086,-.3380045064,-.7351186982,0,-.7967562402,.04097822706,-.6029098428,0,-.1996350917,.8706294745,.4496111079,0,-.02787660336,-.9106232682,-.4122962022,0,-.7797625996,-.6257634692,.01975775581,0,-.5211232846,.7401644346,-.4249554471,0,.8575424857,.4053272873,-.3167501783,0,.1045223322,.8390195772,-.5339674439,0,.3501822831,.9242524096,-.1520850155,0,.1987849858,.07647613266,.9770547224,0,.7845996363,.6066256811,-.1280964233,0,.09006737436,-.9750989929,-.2026569073,0,-.8274343547,-.542299559,.1458203587,0,-.3485797732,-.415802277,.840000362,0,-.2471778936,-.7304819962,-.6366310879,0,-.3700154943,.8577948156,.3567584454,0,.5913394901,-.548311967,-.5913303597,0,.1204873514,-.7626472379,-.6354935001,0,.616959265,.03079647928,.7863922953,0,.1258156836,-.6640829889,-.7369967419,0,-.6477565124,-.1740147258,-.7417077429,0,.6217889313,-.7804430448,-.06547655076,0,.6589943422,-.6096987708,.4404473475,0,-.2689837504,-.6732403169,-.6887635427,0,-.3849775103,.5676542638,.7277093879,0,.5754444408,.8110471154,-.1051963504,0,.9141593684,.3832947817,.131900567,0,-.107925319,.9245493968,.3654593525,0,.377977089,.3043148782,.8743716458,0,-.2142885215,-.8259286236,.5214617324,0,.5802544474,.4148098596,-.7008834116,0,-.1982660881,.8567161266,-.4761596756,0,-.03381553704,.3773180787,-.9254661404,0,-.6867922841,-.6656597827,.2919133642,0,.7731742607,-.2875793547,-.5652430251,0,-.09655941928,.9193708367,-.3813575004,0,.2715702457,-.9577909544,-.09426605581,0,.2451015704,-.6917998565,-.6792188003,0,.977700782,-.1753855374,.1155036542,0,-.5224739938,.8521606816,.02903615945,0,-.7734880599,-.5261292347,.3534179531,0,-.7134492443,-.269547243,.6467878011,0,.1644037271,.5105846203,-.8439637196,0,.6494635788,.05585611296,.7583384168,0,-.4711970882,.5017280509,-.7254255765,0,-.6335764307,-.2381686273,-.7361091029,0,-.9021533097,-.270947803,-.3357181763,0,-.3793711033,.872258117,.3086152025,0,-.6855598966,-.3250143309,.6514394162,0,.2900942212,-.7799057743,-.5546100667,0,-.2098319339,.85037073,.4825351604,0,-.4592603758,.6598504336,-.5947077538,0,.8715945488,.09616365406,-.4807031248,0,-.6776666319,.7118504878,-.1844907016,0,.7044377633,.312427597,.637304036,0,-.7052318886,-.2401093292,-.6670798253,0,.081921007,-.7207336136,-.6883545647,0,-.6993680906,-.5875763221,-.4069869034,0,-.1281454481,.6419895885,.7559286424,0,-.6337388239,-.6785471501,-.3714146849,0,.5565051903,-.2168887573,-.8020356851,0,-.5791554484,.7244372011,-.3738578718,0,.1175779076,-.7096451073,.6946792478,0,-.6134619607,.1323631078,.7785527795,0,.6984635305,-.02980516237,-.715024719,0,.8318082963,-.3930171956,.3919597455,0,.1469576422,.05541651717,-.9875892167,0,.708868575,-.2690503865,.6520101478,0,.2726053183,.67369766,-.68688995,0,-.6591295371,.3035458599,-.6880466294,0,.4815131379,-.7528270071,.4487723203,0,.9430009463,.1675647412,-.2875261255,0,.434802957,.7695304522,-.4677277752,0,.3931996188,.594473625,.7014236729,0,.7254336655,-.603925654,.3301814672,0,.7590235227,-.6506083235,.02433313207,0,-.8552768592,-.3430042733,.3883935666,0,-.6139746835,.6981725247,.3682257648,0,-.7465905486,-.5752009504,.3342849376,0,.5730065677,.810555537,-.1210916791,0,-.9225877367,-.3475211012,-.167514036,0,-.7105816789,-.4719692027,-.5218416899,0,-.08564609717,.3583001386,.929669703,0,-.8279697606,-.2043157126,.5222271202,0,.427944023,.278165994,.8599346446,0,.5399079671,-.7857120652,-.3019204161,0,.5678404253,-.5495413974,-.6128307303,0,-.9896071041,.1365639107,-.04503418428,0,-.6154342638,-.6440875597,.4543037336,0,.1074204368,-.7946340692,.5975094525,0,-.3595449969,-.8885529948,.28495784,0,-.2180405296,.1529888965,.9638738118,0,-.7277432317,-.6164050508,-.3007234646,0,.7249729114,-.00669719484,.6887448187,0,-.5553659455,-.5336586252,.6377908264,0,.5137558015,.7976208196,-.3160000073,0,-.3794024848,.9245608561,-.03522751494,0,.8229248658,.2745365933,-.4974176556,0,-.5404114394,.6091141441,.5804613989,0,.8036581901,-.2703029469,.5301601931,0,.6044318879,.6832968393,.4095943388,0,.06389988817,.9658208605,-.2512108074,0,.1087113286,.7402471173,-.6634877936,0,-.713427712,-.6926784018,.1059128479,0,.6458897819,-.5724548511,-.5050958653,0,-.6553931414,.7381471625,.159995615,0,.3910961323,.9188871375,-.05186755998,0,-.4879022471,-.5904376907,.6429111375,0,.6014790094,.7707441366,-.2101820095,0,-.5677173047,.7511360995,.3368851762,0,.7858573506,.226674665,.5753666838,0,-.4520345543,-.604222686,-.6561857263,0,.002272116345,.4132844051,-.9105991643,0,-.5815751419,-.5162925989,.6286591339,0,-.03703704785,.8273785755,.5604221175,0,-.5119692504,.7953543429,-.3244980058,0,-.2682417366,-.9572290247,-.1084387619,0,-.2322482736,-.9679131102,-.09594243324,0,.3554328906,-.8881505545,.2913006227,0,.7346520519,-.4371373164,.5188422971,0,.9985120116,.04659011161,-.02833944577,0,-.3727687496,-.9082481361,.1900757285,0,.91737377,-.3483642108,.1925298489,0,.2714911074,.4147529736,-.8684886582,0,.5131763485,-.7116334161,.4798207128,0,-.8737353606,.18886992,-.4482350644,0,.8460043821,-.3725217914,.3814499973,0,.8978727456,-.1780209141,-.4026575304,0,.2178065647,-.9698322841,-.1094789531,0,-.1518031304,-.7788918132,-.6085091231,0,-.2600384876,-.4755398075,-.8403819825,0,.572313509,-.7474340931,-.3373418503,0,-.7174141009,.1699017182,-.6756111411,0,-.684180784,.02145707593,-.7289967412,0,-.2007447902,.06555605789,-.9774476623,0,-.1148803697,-.8044887315,.5827524187,0,-.7870349638,.03447489231,.6159443543,0,-.2015596421,.6859872284,.6991389226,0,-.08581082512,-.10920836,-.9903080513,0,.5532693395,.7325250401,-.396610771,0,-.1842489331,-.9777375055,-.1004076743,0,.0775473789,-.9111505856,.4047110257,0,.1399838409,.7601631212,-.6344734459,0,.4484419361,-.845289248,.2904925424,0];_PrimeX=501125321;_PrimeY=1136930381;_PrimeZ=1720413743;static _Lerp(e,t,i){return e+i*(t-e)}static _InterpHermite(e){return e*e*(3-2*e)}static _InterpQuintic(e){return e*e*e*(e*(6*e-15)+10)}static _CubicLerp(e,t,i,s,a){let r=s-i-(e-t);return a*a*a*r+a*a*(e-t-r)+a*(i-e)+t}static _PingPong(e){return(e-=2*Math.trunc(.5*e))<1?e:2-e}_CalculateFractalBounding(){let e=Math.abs(this._Gain),t=e,i=1;for(let s=1;s>15,r&=254,s*this._Gradients2D[r]+a*this._Gradients2D[1|r]}_GradCoordR3(e,t,i,s,a,r,o){let l=this._HashR3(e,t,i,s);return l^=l>>15,l&=252,a*this._Gradients3D[l]+r*this._Gradients3D[1|l]+o*this._Gradients3D[2|l]}_GenNoiseSingleR2(e,t,i){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R2(e,t,i);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR2(e,t,i);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR2(e,t,i);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR2(e,t,i);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR2(e,t,i);case FastNoiseLite.NoiseType.Value:return this._SingleValueR2(e,t,i);default:return 0}}_GenNoiseSingleR3(e,t,i,s){switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:return this._SingleOpenSimplex2R3(e,t,i,s);case FastNoiseLite.NoiseType.OpenSimplex2S:return this._SingleOpenSimplex2SR3(e,t,i,s);case FastNoiseLite.NoiseType.Cellular:return this._SingleCellularR3(e,t,i,s);case FastNoiseLite.NoiseType.Perlin:return this._SinglePerlinR3(e,t,i,s);case FastNoiseLite.NoiseType.ValueCubic:return this._SingleValueCubicR3(e,t,i,s);case FastNoiseLite.NoiseType.Value:return this._SingleValueR3(e,t,i,s);default:return 0}}_UpdateTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._TransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._NoiseType){case FastNoiseLite.NoiseType.OpenSimplex2:case FastNoiseLite.NoiseType.OpenSimplex2S:this._TransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._TransformType3D=FastNoiseLite.TransformType3D.None}}}_UpdateWarpTransformType3D(){switch(this._RotationType3D){case FastNoiseLite.RotationType3D.ImproveXYPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXYPlanes;break;case FastNoiseLite.RotationType3D.ImproveXZPlanes:this._WarpTransformType3D=FastNoiseLite.TransformType3D.ImproveXZPlanes;break;default:switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._WarpTransformType3D=FastNoiseLite.TransformType3D.DefaultOpenSimplex2;break;default:this._WarpTransformType3D=FastNoiseLite.TransformType3D.None}}}_GenFractalFBmR2(e,t){let i=this._Seed,s=0,a=this._FractalBounding;for(let r=0;rp){let t=p+s,i=d+(s-1),a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l,h+this._PrimeY,t,i)}else{let t=p+(s-1),i=d+s,a=.5-t*t-i*i;r=a<=0?0:a*a*(a*a)*this._GradCoordR2(e,l+this._PrimeX,h,t,i)}return 99.83685446303647*(a+r+o)}_SingleOpenSimplex2R3(e,t,i,s){let a=Math.round(t),r=Math.round(i),o=Math.round(s),l=t-a,h=i-r,n=s-o,_=Math.trunc(-1-h|1),c=Math.trunc(-1-l|1),p=Math.trunc(-1-n|1),d=c*-l,m=_*-h,u=p*-n;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let R=0,L=.6-l*l-(h*h+n*n);for(let t=0;;t++){if(L>0&&(R+=L*L*(L*L)*this._GradCoordR3(e,a,r,o,l,h,n)),d>=m&&d>=u){let t=L+d+d;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a-c*this._PrimeX,r,o,l+c,h,n))}else if(m>d&&m>=u){let t=L+m+m;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r-_*this._PrimeY,o,l,h+_,n))}else{let t=L+u+u;t>1&&(t-=1,R+=t*t*(t*t)*this._GradCoordR3(e,a,r,o-p*this._PrimeZ,l,h,n+p))}if(1===t)break;d=.5-d,m=.5-m,u=.5-u,l=c*d,h=_*m,n=p*u,L+=.75-d-(m+u),a+=c>>1&this._PrimeX,r+=_>>1&this._PrimeY,o+=p>>1&this._PrimeZ,c=-c,_=-_,p=-p,e=~e}return 32.69428253173828*R}_SingleOpenSimplex2SR2(e,t,i){const s=.21132486540518713;let a=Math.floor(t),r=Math.floor(i),o=t-a,l=i-r;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY);let h=a+this._PrimeX,n=r+this._PrimeY,_=(o+l)*s,c=o-_,p=l-_,d=2/3-c*c-p*p,m=d*d*(d*d)*this._GradCoordR2(e,a,r,c,p),u=3.1547005383792506*_+(-.6666666666666666+d),R=c-(1-2*s),L=p-(1-2*s);m+=u*u*(u*u)*this._GradCoordR2(e,h,n,R,L);let F=o-l;if(_>s){if(o+F>1){let t=c+(3*s-2),i=p+(3*s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+(this._PrimeX<<1),r+this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}if(l-F>1){let t=c+(3*s-1),i=p+(3*s-2),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r+(this._PrimeY<<1),t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}}else{if(o+F<0){let t=c+(1-s),i=p-s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a-this._PrimeX,r,t,i))}else{let t=c+(s-1),i=p+s,o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a+this._PrimeX,r,t,i))}if(l0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r-this._PrimeY,t,i))}else{let t=c+s,i=p+(s-1),o=2/3-t*t-i*i;o>0&&(m+=o*o*(o*o)*this._GradCoordR2(e,a,r+this._PrimeY,t,i))}}return 18.24196194486065*m}_SingleOpenSimplex2SR3(e,t,i,s){let a=Math.floor(t),r=Math.floor(i),o=Math.floor(s),l=t-a,h=i-r,n=s-o;a=Math.imul(a,this._PrimeX),r=Math.imul(r,this._PrimeY),o=Math.imul(o,this._PrimeZ);let _=e+1293373,c=Math.trunc(-.5-l),p=Math.trunc(-.5-h),d=Math.trunc(-.5-n),m=l+c,u=h+p,R=n+d,L=.75-m*m-u*u-R*R,F=L*L*(L*L)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),m,u,R),D=l-.5,C=h-.5,N=n-.5,P=.75-D*D-C*C-N*N;F+=P*P*(P*P)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+this._PrimeZ,D,C,N);let V=((1|c)<<1)*D,y=((1|p)<<1)*C,T=((1|d)<<1)*N,f=(-2-(c<<2))*D-1,S=(-2-(p<<2))*C-1,g=(-2-(d<<2))*N-1,M=!1,G=V+L;if(G>0){let t=m-(1|c);F+=G*G*(G*G)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(d&this._PrimeZ),t,u,R)}else{let t=y+T+L;if(t>0){let i=m,s=u-(1|p),l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=f+P;if(i>0){let e=(1|c)+D;F+=i*i*(i*i)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+this._PrimeZ,e,C,N),M=!0}}let b=!1,X=y+L;if(X>0){let t=m,i=u-(1|p);F+=X*X*(X*X)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),t,i,R)}else{let t=V+T+L;if(t>0){let i=m-(1|c),s=u,l=R-(1|d);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),i,s,l)}let i=S+P;if(i>0){let e=D,t=(1|p)+C;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+this._PrimeZ,e,t,N),b=!0}}let W=!1,Y=T+L;if(Y>0){let t=m,i=u,s=R-(1|d);F+=Y*Y*(Y*Y)*this._GradCoordR3(e,a+(c&this._PrimeX),r+(p&this._PrimeY),o+(~d&this._PrimeZ),t,i,s)}else{let t=V+y+L;if(t>0){let i=m-(1|c),s=u-(1|p);F+=t*t*(t*t)*this._GradCoordR3(e,a+(~c&this._PrimeX),r+(~p&this._PrimeY),o+(d&this._PrimeZ),i,s,R)}let i=g+P;if(i>0){let e=D,t=C,s=(1|d)+N;F+=i*i*(i*i)*this._GradCoordR3(_,a+this._PrimeX,r+this._PrimeY,o+(d&this._PrimeZ<<1),e,t,s),W=!0}}if(!M){let e=S+g+P;if(e>0){let t=D,i=(1|p)+C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+this._PrimeX,r+(p&this._PrimeY<<1),o+(d&this._PrimeZ<<1),t,i,s)}}if(!b){let e=f+g+P;if(e>0){let t=(1|c)+D,i=C,s=(1|d)+N;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&2*this._PrimeX),r+this._PrimeY,o+(d&this._PrimeZ<<1),t,i,s)}}if(!W){let e=f+S+P;if(e>0){let t=(1|c)+D,i=(1|p)+C;F+=e*e*(e*e)*this._GradCoordR3(_,a+(c&this._PrimeX<<1),r+(p&this._PrimeY<<1),o+this._PrimeZ,t,i,N)}}return 9.046026385208288*F}_SingleCellularR2(e,t,i){let s=Math.round(t),a=Math.round(i),r=Number.MAX_VALUE,o=Number.MAX_VALUE,l=0,h=.43701595*this._CellularJitterModifier,n=(s-1)*this._PrimeX,_=(a-1)*this._PrimeY;switch(this._CellularDistanceFunction){default:case FastNoiseLite.CellularDistanceFunction.Euclidean:case FastNoiseLite.CellularDistanceFunction.EuclideanSq:for(let c=s-1;c<=s+1;c++){let s=_;for(let _=a-1;_<=a+1;_++){let a=this._HashR2(e,n,s),p=510&a,d=c-t+this._RandVecs2D[p]*h,m=_-i+this._RandVecs2D[1|p]*h,u=d*d+m*m;o=Math.max(Math.min(o,u),r),u{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,32.69428253173828*t,i,s,!1,a,r,o);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,7.71604938271605*t,i,s,!0,a,r,o);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r,o)}};return 6===arguments.length&&arguments[3]instanceof Vector2?((e,t,i,s,a,r)=>{switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:this._SingleDomainWarpOpenSimplex2Gradient(e,38.283687591552734*t,i,s,!1,a,r);break;case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:this._SingleDomainWarpOpenSimplex2Gradient(e,16*t,i,s,!0,a,r);break;case FastNoiseLite.DomainWarpType.BasicGrid:this._SingleDomainWarpBasicGrid(e,t,i,s,a,r)}})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]):7===arguments.length&&arguments[3]instanceof Vector3?e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]):void 0}_DomainWarpSingle(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y,o=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=a+r,t=-.211324865405187*e;o*=.577350269189626,a+=t-o,r=r+t-o,o+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=a+o,t=-.211324865405187*e;r*=.577350269189626,a+=t-r,o+=t-r,r+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:let e=(a+r+o)*(2/3);a=e-a,r=e-r,o=e-o}this._DoSingleDomainWarp(t,i,s,e,a,r,o)};return 1===arguments.length&&arguments[0]instanceof Vector2?(e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency,a=e.x,r=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(a+r)*(.5*(1.7320508075688772-1));a+=e,r+=e}this._DoSingleDomainWarp(t,i,s,e,a,r)})(arguments[0]):1===arguments.length&&arguments[0]instanceof Vector3?e(arguments[0]):void 0}_DomainWarpFractalProgressive(){let e=e=>{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=this._Seed,i=this._DomainWarpAmp*this._FractalBounding,s=this._Frequency;for(let a=0;a{let t=e.x,i=e.y,s=e.z;switch(this._WarpTransformType3D){case FastNoiseLite.TransformType3D.ImproveXYPlanes:{let e=t+i,a=-.211324865405187*e;s*=.577350269189626,t+=a-s,i=i+a-s,s+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.ImproveXZPlanes:{let e=t+s,a=-.211324865405187*e;i*=.577350269189626,t+=a-i,s+=a-i,i+=.577350269189626*e}break;case FastNoiseLite.TransformType3D.DefaultOpenSimplex2:{let e=(t+i+s)*(2/3);t=e-t,i=e-i,s=e-s}}let a=this._Seed,r=this._DomainWarpAmp*this._FractalBounding,o=this._Frequency;for(let l=0;l{let t=e.x,i=e.y;switch(this._DomainWarpType){case FastNoiseLite.DomainWarpType.OpenSimplex2:case FastNoiseLite.DomainWarpType.OpenSimplex2Reduced:let e=(t+i)*(.5*(1.7320508075688772-1));t+=e,i+=e}let s=this._Seed,a=this._DomainWarpAmp*this._FractalBounding,r=this._Frequency;for(let o=0;o{let l=a*i,h=r*i,n=o*i,_=Math.floor(l),c=Math.floor(h),p=Math.floor(n),d=FastNoiseLite._InterpHermite(l-_),m=FastNoiseLite._InterpHermite(h-c),u=FastNoiseLite._InterpHermite(n-p);_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),p=Math.imul(p,this._PrimeZ);let R=_+this._PrimeX,L=c+this._PrimeY,F=p+this._PrimeZ,D=1020&this._HashR3(e,_,c,p),C=1020&this._HashR3(e,R,c,p),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d);D=1020&this._HashR3(e,_,L,p),C=1020&this._HashR3(e,R,L,p);let y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),S=FastNoiseLite._Lerp(N,y,m),g=FastNoiseLite._Lerp(P,T,m),M=FastNoiseLite._Lerp(V,f,m);D=1020&this._HashR3(e,_,c,F),C=1020&this._HashR3(e,R,c,F),N=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),P=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),V=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),D=1020&this._HashR3(e,_,L,F),C=1020&this._HashR3(e,R,L,F),y=FastNoiseLite._Lerp(this._RandVecs3D[D],this._RandVecs3D[C],d),T=FastNoiseLite._Lerp(this._RandVecs3D[1|D],this._RandVecs3D[1|C],d),f=FastNoiseLite._Lerp(this._RandVecs3D[2|D],this._RandVecs3D[2|C],d),s.x+=FastNoiseLite._Lerp(S,FastNoiseLite._Lerp(N,y,m),u)*t,s.y+=FastNoiseLite._Lerp(g,FastNoiseLite._Lerp(P,T,m),u)*t,s.z+=FastNoiseLite._Lerp(M,FastNoiseLite._Lerp(V,f,m),u)*t};6===arguments.length&&arguments[3]instanceof Vector2&&((e,t,i,s,a,r)=>{let o=a*i,l=r*i,h=Math.floor(o),n=Math.floor(l),_=FastNoiseLite._InterpHermite(o-h),c=FastNoiseLite._InterpHermite(l-n);h=Math.imul(h,this._PrimeX),n=Math.imul(n,this._PrimeY);let p=h+this._PrimeX,d=n+this._PrimeY,m=510&this._HashR2(e,h,n),u=510&this._HashR2(e,p,n),R=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),L=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);m=510&this._HashR2(e,h,d),u=510&this._HashR2(e,p,d);let F=FastNoiseLite._Lerp(this._RandVecs2D[m],this._RandVecs2D[u],_),D=FastNoiseLite._Lerp(this._RandVecs2D[1|m],this._RandVecs2D[1|u],_);s.x+=FastNoiseLite._Lerp(R,F,c)*t,s.y+=FastNoiseLite._Lerp(L,D,c)*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]),7===arguments.length&&arguments[3]instanceof Vector3&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6])}_SingleDomainWarpOpenSimplex2Gradient(){let e=(e,t,i,s,a,r,o,l)=>{r*=i,o*=i,l*=i;let h,n,_,c=Math.round(r),p=Math.round(o),d=Math.round(l),m=r-c,u=o-p,R=l-d,L=-m-1|1,F=-u-1|1,D=-R-1|1,C=L*-m,N=F*-u,P=D*-R;c=Math.imul(c,this._PrimeX),p=Math.imul(p,this._PrimeY),d=Math.imul(d,this._PrimeZ),h=n=_=0;let V=.6-m*m-(u*u+R*R);for(let t=0;;t++){if(V>0){let t,i,s,r=V*V*(V*V);if(a){let a=1020&this._HashR3(e,c,p,d);t=this._RandVecs3D[a],i=this._RandVecs3D[1|a],s=this._RandVecs3D[2|a]}else{let a=this._HashR3(e,c,p,d),r=252&a,o=a>>6&1020,l=m*this._Gradients3D[r]+u*this._Gradients3D[1|r]+R*this._Gradients3D[2|r];t=l*this._RandVecs3D[o],i=l*this._RandVecs3D[1|o],s=l*this._RandVecs3D[2|o]}h+=r*t,n+=r*i,_+=r*s}let i=V,s=c,r=p,o=d,l=m,y=u,T=R;if(C>=N&&C>=P?(l+=L,i=i+C+C,s-=L*this._PrimeX):N>C&&N>=P?(y+=F,i=i+N+N,r-=F*this._PrimeY):(T+=D,i=i+P+P,o-=D*this._PrimeZ),i>1){i-=1;let t,c,p,d=i*i*(i*i);if(a){let i=1020&this._HashR3(e,s,r,o);t=this._RandVecs3D[i],c=this._RandVecs3D[1|i],p=this._RandVecs3D[2|i]}else{let i=this._HashR3(e,s,r,o),a=252&i,h=i>>6&1020,n=l*this._Gradients3D[a]+y*this._Gradients3D[1|a]+T*this._Gradients3D[2|a];t=n*this._RandVecs3D[h],c=n*this._RandVecs3D[1|h],p=n*this._RandVecs3D[2|h]}h+=d*t,n+=d*c,_+=d*p}if(1===t)break;C=.5-C,N=.5-N,P=.5-P,m=L*C,u=F*N,R=D*P,V+=.75-C-(N+P),c+=L>>1&this._PrimeX,p+=F>>1&this._PrimeY,d+=D>>1&this._PrimeZ,L=-L,F=-F,D=-D,e+=1293373}s.x+=h*t,s.y+=n*t,s.z+=_*t};7===arguments.length&&((e,t,i,s,a,r,o)=>{const l=.21132486540518713;r*=i,o*=i;let h,n,_=Math.floor(r),c=Math.floor(o),p=r-_,d=o-c,m=(p+d)*l,u=p-m,R=d-m;_=Math.imul(_,this._PrimeX),c=Math.imul(c,this._PrimeY),h=n=0;let L=.5-u*u-R*R;if(L>0){let t,i,s=L*L*(L*L);if(a){let s=510&this._HashR2(e,_,c);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let s=this._HashR2(e,_,c),a=254&s,r=s>>7&510,o=u*this._Gradients2D[a]+R*this._Gradients2D[1|a];t=o*this._RandVecs2D[r],i=o*this._RandVecs2D[1|r]}h+=s*t,n+=s*i}let F=3.1547005383792506*m+(-.6666666666666666+L);if(F>0){let t,i,s=u+(2*l-1),r=R+(2*l-1),o=F*F*(F*F);if(a){let s=510&this._HashR2(e,_+this._PrimeX,c+this._PrimeY);t=this._RandVecs2D[s],i=this._RandVecs2D[1|s]}else{let a=this._HashR2(e,_+this._PrimeX,c+this._PrimeY),o=254&a,l=a>>7&510,h=s*this._Gradients2D[o]+r*this._Gradients2D[1|o];t=h*this._RandVecs2D[l],i=h*this._RandVecs2D[1|l]}h+=o*t,n+=o*i}if(R>u){let t=u+l,i=R+(l-1),s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_,c+this._PrimeY);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_,c+this._PrimeY),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}else{let t=u+(l-1),i=R+l,s=.5-t*t-i*i;if(s>0){let r,o,l=s*s*(s*s);if(a){let t=510&this._HashR2(e,_+this._PrimeX,c);r=this._RandVecs2D[t],o=this._RandVecs2D[1|t]}else{let s=this._HashR2(e,_+this._PrimeX,c),a=254&s,l=s>>7&510,h=t*this._Gradients2D[a]+i*this._Gradients2D[1|a];r=h*this._RandVecs2D[l],o=h*this._RandVecs2D[1|l]}h+=l*r,n+=l*o}}s.x+=h*t,s.y+=n*t})(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]),8===arguments.length&&e(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7])}}class Vector2{constructor(e,t){this.x=e,this.y=t}}class Vector3{constructor(e,t,i){this.x=e,this.y=t,this.z=i}} - /* eslint-enable */ - /* prettier-enable */ -======= class FastNoiseLite { static NoiseType = Object.freeze({ OpenSimplex2: "OpenSimplex2", @@ -3511,7 +3500,6 @@ this.z = z; } } ->>>>>>> parent of 95e6823 (minified) Scratch.extensions.register(new Noise()); })(Scratch); From b30630c5e770153212956fcfd90e9107cf79d2fb Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Thu, 26 Dec 2024 20:16:47 -0700 Subject: [PATCH 33/36] 2d noise performance improvement --- docs/Corbnorb/noise.md | 2 +- extensions/Corbnorb/noise.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/Corbnorb/noise.md b/docs/Corbnorb/noise.md index a21e061009..2e8b851c15 100644 --- a/docs/Corbnorb/noise.md +++ b/docs/Corbnorb/noise.md @@ -16,7 +16,7 @@ There are 2 blocks: 1. [create noise](#createNoise) 2. [get noise](#getNoise) -Although the [get noise](#getNoise) block has 3D coordinates, you can use just X and Y if you want 2D noise +Although the [get noise](#getNoise) block has 3D coordinates, leave the Z value blank to use 2D noise instead, which should run roughly twice as fast ### Create Noise diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 8b09604a78..991ef3d5a7 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -182,7 +182,10 @@ const easing = Cast.toString(args.EASING); const inverted = Cast.toBoolean(args.INVERTED); if (id in noises) { - let value = noises[id].GetNoise(args.X, args.Y, args.Z); + let value = + args.Z.toString() == "" + ? noises[id].GetNoise(args.X, args.Y) + : noises[id].GetNoise(args.X, args.Y, args.Z); value = inverted == true ? -value : value; value = (value + 1) / 2; switch (easing) { From 8a3456671343610ce5ef269b1d8a7e1b15f3d56a Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Sat, 28 Dec 2024 00:16:10 -0700 Subject: [PATCH 34/36] fixed fractal default value --- extensions/Corbnorb/noise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 991ef3d5a7..2477c52b66 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -55,7 +55,7 @@ FRACTAL: { type: ArgumentType.STRING, menu: "FRACTAL_TYPE", - defaultValue: "FBm", + defaultValue: "fbm", }, }, }, From e0da06caf0574320d7001bf2aa8fe5bd9582c3bd Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Mon, 30 Dec 2024 21:19:17 -0700 Subject: [PATCH 35/36] menu --- extensions/Corbnorb/noise.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index 2477c52b66..f65aef47cc 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -9,6 +9,7 @@ "use strict"; const noises = Object.create(null); + const noiseMenu = [{text: "myNoise", value: "myNoise"}] const BlockType = Scratch.BlockType; const ArgumentType = Scratch.ArgumentType; @@ -68,7 +69,7 @@ arguments: { ID: { type: ArgumentType.STRING, - defaultValue: "myNoise", + menu: "NOISES", }, X: { type: ArgumentType.NUMBER, @@ -96,6 +97,10 @@ }, ], menus: { + NOISES: { + acceptReporters: true, + items: "getNoises" + }, NOISE_TYPE: { acceptReporters: true, items: [ @@ -126,6 +131,11 @@ }; } + getNoises() + { + return noiseMenu; + } + initNoise(args) { const id = Cast.toString(args.ID); const seed = Cast.toNumber(args.SEED); @@ -133,6 +143,7 @@ const frequency = Cast.toNumber(args.FREQUENCY); const octaves = Cast.toNumber(args.OCTAVES); noises[id] = new FastNoiseLite(seed); + if(!noiseMenu.some(e => e.value === id)) {noiseMenu.push({text:id, value:id})} switch (args.TYPE) { case "openSimplex2": noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); From 693e987b4ee66ce9da45fc357d6ba4e09f71f5fb Mon Sep 17 00:00:00 2001 From: OGDemonZ <71907588+OGDemonZ@users.noreply.github.com> Date: Sat, 4 Jan 2025 00:33:53 -0700 Subject: [PATCH 36/36] format --- extensions/Corbnorb/noise.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/extensions/Corbnorb/noise.js b/extensions/Corbnorb/noise.js index f65aef47cc..a7acd92363 100644 --- a/extensions/Corbnorb/noise.js +++ b/extensions/Corbnorb/noise.js @@ -9,7 +9,7 @@ "use strict"; const noises = Object.create(null); - const noiseMenu = [{text: "myNoise", value: "myNoise"}] + const noiseMenu = [{ text: "myNoise", value: "myNoise" }]; const BlockType = Scratch.BlockType; const ArgumentType = Scratch.ArgumentType; @@ -99,7 +99,7 @@ menus: { NOISES: { acceptReporters: true, - items: "getNoises" + items: "getNoises", }, NOISE_TYPE: { acceptReporters: true, @@ -131,8 +131,7 @@ }; } - getNoises() - { + getNoises() { return noiseMenu; } @@ -143,7 +142,9 @@ const frequency = Cast.toNumber(args.FREQUENCY); const octaves = Cast.toNumber(args.OCTAVES); noises[id] = new FastNoiseLite(seed); - if(!noiseMenu.some(e => e.value === id)) {noiseMenu.push({text:id, value:id})} + if (!noiseMenu.some((e) => e.value === id)) { + noiseMenu.push({ text: id, value: id }); + } switch (args.TYPE) { case "openSimplex2": noises[id].SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);