So I have been working on a custom 3D rendering engine. (which is very cool and all, but it seems to run horribly due to some variables I have in the code. I have no idea why this is happening. and I have done tests and I can confirm that it’s the two variables in the code below.
Some help would be greatly appreciated as always!
local function RenderObjects()
-- Update the picture
for ObjectIndex, Object in pairs(Objects) do
local TriangleFaces = Object.TriangleFaces
local Vertices = Object.Vertices
for FaceIndex, Triangle in pairs(TriangleFaces) do
-- These are the variables that are causing lag in the code. If i comment these out the game will run 60 FPS
local TriangleImg1 = Canvas["Triangle" .. ObjectIndex .. "|" .. FaceIndex .. "|1"] -- This is an ImageLabel in a frame in a GUI
local TriangleImg2 = Canvas["Triangle" .. ObjectIndex .. "|" .. FaceIndex .. "|2"] -- This is an ImageLabel in a frame in a GUI
--[[
Normally there would be over 100 lines of code here, but none of it seemed to affect the frame rate at all when I commented out the above variables.
]]
end
end
end