Camera zoom to center fit object with CSS3D

Hello all!

I want to achieve something similar as was discussed here: Camera Zoom To Fit Object

However I’m using CSS3DRenderer only and tried to adjust the examples given to my use case. But I can’t make it work. I assume Box3 is simply not working with CSS3DObjects, so I adjusted it by using the actual width and height of the div - that’s also not working properly.

I put together a simple example here: CSS3D Centering - CodeSandbox

Do you know what’s wrong with my current centerObject function to simply zoom in/out of the given div for different sizes?
My current code shows somewhat random results for different div sizes.

Thank you so much for your help! :slight_smile: