fenomas / noa

Experimental voxel game engine.
MIT License
608 stars 86 forks source link

render single cube #166

Closed itzTheMeow closed 2 years ago

itzTheMeow commented 2 years ago

I want to render a single cube as a block preview (like classic.minecraft.net, but autogenerated) i noticed this but it seems like it would have a huge impact on performance being done several times for each block. The render would only need to be done once, as it's a static preview, it would also only need 3 sides, like this: image

fenomas commented 2 years ago

Hi, you mean showing a phantom block where the user's cursor is pointing? That can be done by overriding the default block highlight function with similar code - just showing a solid block mesh rather than the outline the engine uses by default.

If you mean how to make the mesh itself, the straightforward way would be to call Babylon's meshbuilder "createBox" once, then just keep a reference to that mesh but change its texture depending on which block you want to show.

Does that help? Not quite sure what you're asking!

itzTheMeow commented 2 years ago

sorry it's a little unclear lol

i'm trying to make an cube icon for the block in a hotbar rather than just using the flat texture to indicate what block you are building with

fenomas commented 2 years ago

Ah I get you. If you want to render out a mesh into a png or similar, that'd be a Babylon question. I imagine you'd want to make a textured Box mesh and draw it to a separate render target, but that's just guessing.

In my experience the best place for Babylon info is their forum, every time I've asked questions there I've gotten a lot of help.