Advertisement
DragRacer31

Leaked perlin noise script from BLOX survival

Sep 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. -- Globals
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3.  
  4. -- Libraries
  5. local Class = require(ReplicatedStorage.Libraries.Class)
  6. local Arrays = require(ReplicatedStorage.Libraries.Arrays)
  7.  
  8. -- Modules
  9.  
  10. --[[
  11.     NoiseGeneratorPerlin
  12.     Type: Class module
  13.    
  14.     Provides a simple interface for seeded perlin noise.
  15. --]]
  16.  
  17. local NoiseGeneratorPerlin = Class()
  18.  
  19. --[[
  20.     Called to initialise a new module.
  21. --]]
  22. function NoiseGeneratorPerlin:constructor(random)
  23.     self.xOffset = random:NextNumber(-256, 256)
  24.     self.yOffset = random:NextNumber(-256, 256)
  25.     self.zOffset = random:NextNumber(-256, 256)
  26. end
  27.  
  28.  
  29. --[[
  30.     Returns a sample of noise at the given location in 3D space.
  31. --]]
  32. function NoiseGeneratorPerlin:sample(x, y, z)
  33.     return math.noise(x + self.xOffset, y + self.yOffset, z + self.zOffset)
  34. end
  35.  
  36. --[[
  37.     Returns a sample of noise at the given location in 2D space.
  38. --]]
  39. function NoiseGeneratorPerlin:sample2D(x, z)
  40.     return NoiseGeneratorPerlin:sample(x, 0, z)
  41. end
  42.  
  43.  
  44. return NoiseGeneratorPerlin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement