Advertisement
Quoteory

3D Perlin Noise Disintegration

Aug 9th, 2020
1,518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. local RunService = game:GetService("RunService")
  2. local cube = game.ReplicatedStorage.Cube
  3. local count = 10
  4. local scale = 3
  5. local seed = math.randomseed(tick())
  6. local cubes = {}
  7.  
  8. for x = 1, count do
  9.     for y = 1, count do
  10.         for z = 1, count do
  11.             local xNoise = math.noise(y/scale, z/scale, seed)
  12.             local yNoise = math.noise(x/scale, z/scale, seed)
  13.             local zNoise = math.noise(x/scale, y/scale, seed)
  14.             local density = (1 + xNoise + yNoise + zNoise)/2
  15.            
  16.             local part = cube:Clone()
  17.             part.Position = Vector3.new(x, y, z) * 5 -- 5 is the part size, this is so there isn't overlap
  18.             part.Parent = workspace
  19.            
  20.             table.insert(cubes, {
  21.                 part = part,
  22.                 density = density
  23.             })
  24.         end
  25.     end
  26. end
  27.  
  28. wait(2)
  29.  
  30. local threshold = 2
  31. while true do
  32.     for _, cube in ipairs(cubes) do
  33.         if cube.density < threshold then
  34.             cube.part.Transparency = 0
  35.         else
  36.             cube.part.Transparency = 1
  37.         end
  38.     end
  39.     threshold = threshold - .01
  40.     RunService.Heartbeat:Wait()
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement