Help Reduce Lag from custom "Tilemap"

So, I made a custom Tilemap system to help make the world, but it has an incredible amount of entities that are loaded, 624 specifically. I wanted to have more space for enemies to interact with the walls and reduce how many get stuck in the walls, which is why there are a lot, But sometimes, the frame rate on my computer dropped by 12 when running at 60 FPS, but only 3 in 30 FPS, but that’s not importaint rn, so is there a really good way to reduce the amount of lag that the Tiles produce? Any Good optimizations I can add?

Note: I did make a buffer period of 15 frames for 14 different groups, with one frame drop(one frame where none of the tiles check if they should update)

Test Scene for Tilemap: PlayCanvas | HTML5 Game Engine

Tilemap Script: PlayCanvas | HTML5 Game Engine

Note: I had to hand-type the list that shows what the 3 rooms look like, and so I’m working on a way to make it so that I can have a bunch of rooms generate automatically for both of the sectors.

Personally, I’d go for a dynamic mesh generation.

As an example see this, it dynamically adds quads to render those hearts.
You could grab code from there, which creates and updates mesh, meshInstance and entity with a render component, and add quads for your texture parts. Ideally you have all sub-textures in a larger atlas, and just change UVs.

https://playcanvas.vercel.app/#/graphics/mesh-decals

Cool, what exactly does that do?

I don’t understand how it’s working.

Does it essentially just do the “Paint” function that Scratch.mit.edu does, where it makes a clone that can’t do anything? not even be interactible unless needed with a different function?