Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Globals
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- -- Libraries
- local Class = require(ReplicatedStorage.Libraries.Class)
- local Arrays = require(ReplicatedStorage.Libraries.Arrays)
- -- Modules
- --[[
- NoiseGeneratorPerlin
- Type: Class module
- Provides a simple interface for seeded perlin noise.
- --]]
- local NoiseGeneratorPerlin = Class()
- --[[
- Called to initialise a new module.
- --]]
- function NoiseGeneratorPerlin:constructor(random)
- self.xOffset = random:NextNumber(-256, 256)
- self.yOffset = random:NextNumber(-256, 256)
- self.zOffset = random:NextNumber(-256, 256)
- end
- --[[
- Returns a sample of noise at the given location in 3D space.
- --]]
- function NoiseGeneratorPerlin:sample(x, y, z)
- return math.noise(x + self.xOffset, y + self.yOffset, z + self.zOffset)
- end
- --[[
- Returns a sample of noise at the given location in 2D space.
- --]]
- function NoiseGeneratorPerlin:sample2D(x, z)
- return NoiseGeneratorPerlin:sample(x, 0, z)
- end
- return NoiseGeneratorPerlin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement